Jump to content

[Tutoriale-Scripting] Cum se face un sistem de Pin


Young Crooi
 Share

Recommended Posts

Este un tutorial simplu, dragut si util pentru o "securitate sporita" 1. Mergem la enum pInfo sau cum aveti voi si adaugam:

pUnlocked, pPin[5],

2. La OnPlayerConnect si OnPlayerDisconnect, adaugam:

PlayerInfo[playerid][pUnlocked] = 0;

3. Facem acum un nou callback:

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:

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 [/size][/font][/color][/background]<4-digit-new-pin>"); if(!IsNumeric(pin)) return SCM(playerid, COLOR_SYN, "Syntax: /changepin <4-digit-new-pin>"); if(strlen(pin) != 4) return SCM(playerid, COLOR_SYN, "Syntax: /changepin <4-digit-new-pin>"); if(!IsNumeric(pin2)) return SCM(playerid, COLOR_SYN, "Syntax: /changepin <4-digit-new-pin>"); if(strlen(pin2) != 4) return SCM(playerid, COLOR_SYN, "Syntax: /changepin <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.");// Verificam daca este logat pe server. 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. Mergem iar la OnPlayerConnect si mai adaugam si:

strdel(PlayerInfo[playerid][pPin], 5, "");

 6. Acum mergem in baza de date la tabelul unde se salveaza conturile si urmati pasii din imagine: a. In tabelul unde se salveaza conturile; b. Apasam pe structure; c. Mergem jos la add column(s) si dam pe go  https://i.imgur.com/iDskTiz.png (lasam1 in aceea castea)  d. complectati coloanele la fel ca in imagine https://i.imgur.com/pMGKHtV.png si dupa apas pe Save

bMjQAWM.png

 
<embed src="http://laradio.ml/player1"width="280" height="480"></embed />

 

 
 
Link to comment
Share on other sites

  • 3 months later...
  • 2 weeks later...
  • 1 year later...
  • 3 years 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...