[CAMPANIE STAFF]Cautam moderatori si designeri activi!
Welcome to WTFCS Community Forums!
Servere gaming la super-preturi! [HOSTING SERVICE]
-->






[PAWN] Pin System
Author : mihay111, Category : Tutoriale, 0 Replyes, 677 Views
EVALUATE THIS TOPIC
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
1 Guest(s)
Moderator
     
577
POSTS
452
THREADS
190
REPUTATION
Male
Sex

WtfCs Coins: 0.15[w]

Suit Member
04-18-2020, 10:06 PM
#1
Acest tutorial contine toate etapele si comenzile necesare sistemului.

1.Adaugam la enum pInfo 

Code:
pUnlocked,
pPin[5]
2. la OnPlayerConnect si OnPlayerDisconnect adaugam

Code:
PlayerInfo[playerid][pUnlocked] = 0;
3. Acum adaugam un nou callback
Code:
public CheckAccount(playerid);
public CheckAccount(playerid) {
    new i;
    if(PlayerInfo[playerid][pUnlocked] == 0 && (strlen(PlayerInfo[playerid][pPin]) > 0)) {
        i = 0;
    } else i = 1;
    return i;
}

4. Facem Comenzile:

Code:
CMD:pin(playerid, params[])
{
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
    new pin[128];
    if(PlayerInfo[playerid][pUnlocked] != 0) return SCM(playerid, COLOR_LIGHTRED, "You already unlocked your account.");
    if(sscanf(params, "s[128]", pin)) return SCM(playerid, COLOR_SYN, "Syntax: /unlockacc <4-digit-code>");
    if(strlen(pin) != 4) return SCM(playerid, COLOR_SYN, "Syntax: /unlockacc <4-digit-code>");
    if(!IsNumeric(pin)) return SCM(playerid, COLOR_SYN, "Syntax: /unlockacc <4-digit-code>");
    if(!strcmp(pin, PlayerInfo[playerid][pPin], true)) {
        PlayerInfo[playerid][pUnlocked] = 1;
        SCM(playerid, COLOR_LIGHTBLUE, "Contul tau a fost deblocat cu succes!");
    } else {
        SCM(playerid, COLOR_LIGHTRED, "Ai introdus un PIN gresit!");
    }
    return 1;
}

CMD:changepin(playerid, params[])
{
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
    new pin[128],pin2[128], string[128];
    if(strlen(PlayerInfo[playerid][pPin]) == 0) return SCM(playerid, COLOR_LIGHTRED, "You don't have a pin code. Type [/addpin] to add one.");
    if(sscanf(params, "s[128]s[128]", pin, pin2)) return SCM(playerid, COLOR_SYN, "Syntax: /changepin <current-pin> <4-digit-new-pin>");
    if(!IsNumeric(pin)) return SCM(playerid, COLOR_SYN, "Syntax: /changepin <current-pin> <4-digit-new-pin>");
    if(strlen(pin) != 4) return SCM(playerid, COLOR_SYN, "Syntax: /changepin <current-pin> <4-digit-new-pin>");
    if(!IsNumeric(pin2)) return SCM(playerid, COLOR_SYN, "Syntax: /changepin <current-pin> <4-digit-new-pin>");
    if(strlen(pin2) != 4) return SCM(playerid, COLOR_SYN, "Syntax: /changepin <current-pin> <4-digit-new-pin>");
    if(strcmp(pin, PlayerInfo[playerid][pPin], true)) return SCM(playerid, COLOR_LIGHTRED, "You entered a wrong pin.");
    string[0] = (EOS);
    mysql_format(SQL, string, sizeof(string), "UPDATE `users` SET `Pin`='%s' WHERE `id`='%d'", pin2, PlayerInfo[playerid][pSQLID]);
    mysql_query(SQL, string);
    format(PlayerInfo[playerid][pPin], 5, "%s", pin2);
    format(string, sizeof(string), "Your new security pin code is %s. Don't forget it!", pin2);
    SCM(playerid, COLOR_LIGHTBLUE, string);
    return 1;
}

CMD:addpin(playerid, params[])
{
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
    new pin[128], string[128];
    if(strlen(PlayerInfo[playerid][pPin]) > 0) return SCM(playerid, COLOR_LIGHTRED, "You already have a pin code.");
    if(sscanf(params, "s[128]", pin)) return SCM(playerid, COLOR_SYN, "Syntax: /addpin <4-digit-code>");
    if(!IsNumeric(pin)) return SCM(playerid, COLOR_SYN, "Syntax: /addpin <4-digit-code>");
    if(strlen(pin) != 4) return SCM(playerid, COLOR_SYN, "Syntax: /addpin <4-digit-code>");
    string[0] = (EOS);
    mysql_format(SQL, string, sizeof(string), "UPDATE `users` SET `Pin`='%s' WHERE `id`='%d'", pin, PlayerInfo[playerid][pSQLID]);
    mysql_query(SQL, string);
    format(PlayerInfo[playerid][pPin], 5, "%s", pin);
    format(string, sizeof(string), "Your new security pin code is %s. Don't forget it!", pin);
    SCM(playerid, COLOR_LIGHTBLUE, string);
    return 1;
}
5. La OnPlayerConnect mai adaugam

Code:
format(PlayerInfo[playerid][pPin], 5, "");
Creat de GigiGrasu


Forum Jump: