new Arma1,Arma2,Arma3,tmpstring[20]; new valori[256]; format(query,128,"SELECT * FROM account WHERE Username='%s'",PName(playerid)); samp_mysql_query(query); samp_mysql_store_result(); if(samp_mysql_fetch_row(valori)) { samp_mysql_get_field("Arma1", tmpstring); Arma1=strval(tmpstring); samp_mysql_get_field("Arma2", tmpstring); Arma2=strval(tmpstring); samp_mysql_get_field("Arma3", tmpstring); Arma3=strval(tmpstring); } GivePlayerWeapon(playerid,Arma1,500); GivePlayerWeapon(playerid,Arma2,500); GivePlayerWeapon(playerid,Arma3,500); format(query,128,"UPDATE account SET Skin = '%d' WHERE Username = '%s'",GetPlayerSkin(playerid),PName(playerid)); samp_mysql_query(query);
if(!IsLoggedIn[playerid]) { new query[256],resultline[256]; format(query,sizeof(query),"SELECT * FROM account WHERE Username ='%s'",PName(playerid)); samp_mysql_query(query); samp_mysql_store_result(); if(samp_mysql_fetch_row(resultline)) { samp_mysql_get_field("Indirizzoip", PlayerIP[playerid]) ; if(!strcmp(PlayerIP[playerid],GetPlayerAddres(playerid),true) && Loginauto[playerid]) { new rps[100]; format(rps,100,"AUTO LOGIN: Indirizzo IP: [%s/%s]",PlayerIP[playerid],GetPlayerAddres(playerid)); SendClientMessage(playerid,COLOR_GREY,rps); LoginPlayer(playerid); }else{ new str[150]; format(str,150,"Benvenuto %s\nInserisci la tua password",PlayerName[playerid]); ShowPlayerDialog(playerid,LOGIN_DIALOG,DIALOG_STYLE_INPUT,"Login",str,"Login","Annulla"); } } else { ShowPlayerDialog(playerid,REGISTER_DIALOG,DIALOG_STYLE_INPUT ,"Register","Non hai un account su questo server.\nRegistrati inserendo una password.", "Register","Annulla"); } }
if(dialogid==LOGIN_DIALOG) { if(response) { new valori[128], reale[100], query[128]; format(query,128,"SELECT * FROM account WHERE Username='%s'",PName(playerid)); samp_mysql_query(query); samp_mysql_store_result(); samp_mysql_fetch_row(valori); samp_mysql_get_field("Password", reale); if(!strcmp(reale,MD5_Hash(inputtext),true)) { LoginPlayer(playerid); }else{ new msg[128]; PWErrata[playerid]+=1; format(msg,sizeof(msg),"Password errata [%d/3]",PWErrata[playerid]); ShowPlayerDialog(playerid,LOGIN_DIALOG,DIALOG_STYLE_INPUT,"Login",msg,"Login","Annulla"); if(PWErrata[playerid]==3) { SendClientMessage(playerid,COLOR_RED,"Hai sbagliato la password 3 volte."); Kick(playerid); format(msg,sizeof(msg),">> %s и stato kickato dal server per non aver effettuato correttamente il login",PName(playerid)); SendClientMessageToAll(COLOR_RED,msg); } } } }
forward LoginPlayer(playerid); public LoginPlayer(playerid) { new query[128],valori[256]; format(query,128,">> Login effettuato correttamente."); IsLoggedIn[playerid] = true; SendClientMessage(playerid,0x00ff00aa,query); format(query,128,"SELECT * FROM account WHERE Username='%s'",PName(playerid)); samp_mysql_query(query); samp_mysql_store_result(); samp_mysql_fetch_row(valori); new tmpstr[256]; samp_mysql_get_field("Admin", tmpstr); AdminLevel[playerid]=strval(tmpstr); samp_mysql_get_field("Score",tmpstr); Score[playerid]=strval(tmpstr); samp_mysql_get_field("Entrata", tmpstr); Entrata[playerid]=strval(tmpstr); samp_mysql_get_field("Money", tmpstr); Money[playerid]=strval(tmpstr); samp_mysql_get_field("Skin", tmpstr); SetPlayerSkin(playerid,strval(tmpstr)); SetSpawnInfo(playerid,0,strval(tmpstr),-2421.1748,334.7039,35.4517,240.8429,0,0,0,0,0,0); samp_mysql_get_field("Morti", tmpstr); Death[playerid]=strval(tmpstr); samp_mysql_get_field("Uccisioni", tmpstr); Kill[playerid]=strval(tmpstr); samp_mysql_get_field("AutoRepair", tmpstr); AutoRepair[playerid]=strval(tmpstr); samp_mysql_get_field("SpeedBoost", tmpstr); SpeedBoost[playerid]=strval(tmpstr); samp_mysql_get_field("ASK", tmpstr); AntiSpawnKill[playerid]=strval(tmpstr); samp_mysql_get_field("Loginauto", tmpstr); Loginauto[playerid]=strval(tmpstr); samp_mysql_get_field("DefaultSpawn", tmpstr); DefaultSpawn[playerid]=strval(tmpstr); format(query,200,"UPDATE account SET Indirizzoip = '%s' WHERE Username = '%s'",GetPlayerAddres(playerid),PName(playerid)); samp_mysql_query(query); format(query,200,"UPDATE account SET ENTRATA = '%d' WHERE Username = '%s'",Entrata[playerid]+1,PName(playerid)); samp_mysql_query(query); new msg[200]; format(msg,200,"Ciao %s! Benvenuto nel server!",PlayerName[playerid]); SendClientMessage(playerid,COLOR_RED,"***********************************************************************************************************************************"); SendClientMessage(playerid,COLOR_WHITE,msg); if(AdminLevel[playerid]>0) { format(msg,200,"Ti sei loggato come admin di livello %d",AdminLevel[playerid]); SendClientMessage(playerid,COLOR_WHITE,msg); } format(msg,200,"Hai $%d, e sei di livello: %d, entrata n°: %d",Money[playerid],Score[playerid],Entrata[playerid]); SendClientMessage(playerid,COLOR_WHITE,msg); SendClientMessage(playerid,COLOR_WHITE,"Gamemode in fase di sviluppo, al termine verranno azzerati tutti i dati degli utenti."); SendClientMessage(playerid,COLOR_WHITE,"Accedi al tuo pannello di controllo account su WWW.TLK.GAMEHOSTING.IT inserendo i dati del server."); SendClientMessage(playerid,COLOR_WHITE," "); SendClientMessage(playerid,COLOR_RED,"***********************************************************************************************************************************"); }
SELECT acc_id FROM account WHERE Username='%s' |
SELECT * FROM account WHERE Username='%s' AND Password=MD5('%s')
if(dialogid==LOGIN_DIALOG) { if(response) { new valori[128], query[128], escaped[51]; samp_mysql_real_escape_string(inputtext, escaped); format(query,128,"SELECT * FROM account WHERE Username='%s' AND Password=MD5('%s')",PName(playerid),escaped); samp_mysql_query(query); samp_mysql_store_result(); if(samp_mysql_fetch_row(valori)) { LoginPlayer(playerid); }else{ new msg[128]; PWErrata[playerid]+=1; format(msg,sizeof(msg),"Password errata [%d/3]",PWErrata[playerid]); ShowPlayerDialog(playerid,LOGIN_DIALOG,DIALOG_STYLE_INPUT,"Login",msg,"Login","Annulla"); if(PWErrata[playerid]==3) { SendClientMessage(playerid,COLOR_RED,"Hai sbagliato la password 3 volte."); Kick(playerid); format(msg,sizeof(msg),">> %s и stato kickato dal server per non aver effettuato correttamente il login",PName(playerid)); SendClientMessageToAll(COLOR_RED,msg); } } } }
if(dialogid==REGISTER_DIALOG) { if(response) { if(!strlen(inputtext)) return ShowPlayerDialog(playerid,REGISTER_DIALOG,DIALOG_STYLE_INPUT ,"Errore","Non hai inserito alcuna password.", "Register","Annulla"); if(strlen(inputtext)<5) return ShowPlayerDialog(playerid,REGISTER_DIALOG,DIALOG_STYLE_INPUT ,"Errore","Inserisci una password \ndi almeno 6 caratteri.", "Register","Annulla"); if(strlen(inputtext)>25)return ShowPlayerDialog(playerid,REGISTER_DIALOG,DIALOG_STYLE_INPUT ,"Errore","Inserisci una password \ndi inferiore di 25 caratteri.", "Register","Annulla"); new query[164]; new escaped[51]; samp_mysql_real_escape_string(inputtext, escaped); format(query,128,"INSERT INTO `account` (Username,Password,Entrata,Score,Admin,Nome) VALUES ('%s',md5('%s'),0,0,0,'none')",PName(playerid),escaped); samp_mysql_query(query); ShowPlayerDialog(playerid,NAME_DIALOG,DIALOG_STYLE_INPUT,"Register","Inerisci il tuo nome","Avanti","X"); return 1; }else{ ShowPlayerDialog(playerid,REGISTER_DIALOG,DIALOG_STYLE_INPUT ,"Login","Non hai un account su questo server.\nRegistrati inserendo una password.", "Register","Annulla"); } }