Jump to content

[Tutorial] Name change cu aprobare de la admin


577777
 Share

Recommended Posts

  • Hall of Flame🔥

Username: Alexandru#1337
Creator: 77777 (tot eu)
Tutorial/Ghid: mai jos

 

Pentru inceput facem 2 declaratii globale: new NameOffer[MAX_PLAYERS], namech[25];
Acum comenzile:

YCMD:changename(playerid, params[], help) {
    if(playerVariables[playerid][pPinStatus] == 0) return PinOnly(playerid); // daca nu are pinul bagat ii aruncam un mesaj
    new id, name[25], string[256]; // alte definitii
    if(sscanf(params, "s[25]", name)) return SendUsage(playerid, "/changename <exact name>"); // daca nu completeaza comanda cu numele dorit ii dam mesajul asta
    if(!IsPlayerConnected(playerid)) return 1; //daca nu e conectat returnam
    if(NameOffer[playerid] != 0) return SCM(playerid, COLOR_GREY, "Error: You already have a request pending."); // daca are o cerere deja returnam
    format(string, sizeof string, "{FFFFFF}({FF0000}Notice{FFFFFF}): %s vrea sa-si schimbe numele in %s.", GetName(playerid), name); //ce mesaj sa trimitem la admini
    sendAdmins(COLOR_WARNING, string); // trimitem mesajul adminilor
    SCM(playerid, COLOR_WARNING, "Your name change request has been sent succesfully to the admins."); // trimitem mesaj jucatorului pentru a confirma ca cererea a fost trimisa
    NameOffer[playerid] = playerid; // modificam variabila pt jucator sa fie = cu id-ul lui
    namech = name; // aici actualizam variabila cu numele pe care X il doreste
    return 1; } / /gata comanda

YCMD:acceptname(playerid, params[], help) {
    if(playerVariables[playerid][pPinStatus] == 0) return PinOnly(playerid); // daca nu are pinul bagat ii aruncam un mesaj
    if(playerVariables[playerid][pAdmin] < 2) return AdminOnly(playerid, 2); // daca nu este admin 2 ii aruncam inca un mesaj
    new id, string[256]; // alte definitii
    if(sscanf(params, "u", id)) return SendUsage(playerid, "/acceptname <playerid>"); // daca nu completeaza comanda cu un id ii dam mesajul asta
    if(NameOffer[id] != id) return SCM(playerid, COLOR_GREY, "Error: This player did not requst a name change."); // daca x nu are cerere facuta returnam
    format(string, sizeof string, "{FFFFFF}({FF0000}Notice{FFFFFF}): %s i-a schimbat numele lui %s in %s.", GetName(playerid), GetName(id), namech); //ce mesaj sa trimitem la admini
    sendAdmins(COLOR_WARNING, string); // trimitem mesajul adminilor
    format(string, sizeof string, "Your name change request has been approved by %s, new name: %s. Please relog if name does not update.", GetName(playerid), namech); //ce mesaj sa dam la jucator
    SCM(playerid, COLOR_WARNING, string); // trimitem mesajul jucatorului
    NameOffer[playerid] = 0; // modificam variabila pt jucator sa fie = 0
    new query[128]; // inca o definitie
    mysql_format(fzSQL, query, sizeof(query), "UPDATE `accounts` SET `Name` = '%s' WHERE `Name` = '%s'", namech, GetName(id)); //ce actualizam la baza de date
    mysql_tquery(fzSQL, query);    // trimitem actualizarea, nume nou setat
    SetPlayerName(id, namech); // setam numele jucatoriului in-game
    return 1; } //gata comanda

Ce mai aveti voi de facut este sa interogati baza de date si sa vedeti daca numele respectiv mai exista, nu va dau chair tot. Succes.

*Edit: sa resetati varibilele cand jucatorul intra sau iese de pe server 🙂

ezgif-com-gif-maker-1-00000.png

Not So Zen SRL

Link to comment
Share on other sites

  • 577777 changed the title to [Tutorial] Name change cu aprobare de la admin
  • 3 weeks later...
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...