05.06.2010, 10:13
Hi! I made a login/register system whit mysql plugin for samp, I've used *****'s include for make MD5 hash but sometime my code do not work. When the user insert the password in the dialog the code stops before "LoginPlayer()", and the Login don't work, but other query work correctly, for example:
can you help me? this is the surce code:
onplayerrequestclass
ondialogresponse:
Table structure
PHPMA screen
[TLK]StanleY=me
[TLK]Flash=my brother
this work whit my computer but, in my brother's computer no.
i can't resolve this problem please help me!
Код:
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);
onplayerrequestclass
Код:
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,"***********************************************************************************************************************************"); }
PHPMA screen
[TLK]StanleY=me
[TLK]Flash=my brother
this work whit my computer but, in my brother's computer no.
i can't resolve this problem please help me!