#include <a_samp>#include <dutils>#include <dudb>#include <dini>new nev[MAX_PLAYER_NAME];new Pont[100];public OnPlayerDisconnect(playerid){ GetPlayerName(playerid, nev, sizeof(nev)); format(Pont, sizeof(Pont), \"/Szerver/%s.ini\",nev); if(!dini_Exists(Pont)) { } else{ dini_IntSet(Pont, \"Score\", GetPlayerScore(playerid)); }}public OnPlayerConnect(playerid){ GetPlayerName(playerid, nev, sizeof(nev)); format(Pont, sizeof(Pont), \"/Szerver/%s.ini\",nev); if(!dini_Exists(Pont)) { dini_Create(Pont); dini_IntSet(Pont, \"Score\", 0); SetPlayerScore(playerid, dini_Int(Pont, \"Score\")); } else{ SetPlayerScore(playerid, dini_Int(Pont, \"Score\")); } return 1;}
#include <a_samp>#include <YSI\\y_ini>#define DIALOG_REGISTER 1#define DIALOG_LOGIN 2#define PATH \"/ROOCKadmin/Users/%s.rock\"enum pInfo{ pPass, pCash, pScore,}new PlayerInfo[MAX_PLAYERS][pInfo];forward LoadUser_data(playerid,name[],value[]);public LoadUser_data(playerid,name[],value[]){ INI_Int(\"Password\",PlayerInfo[playerid][pPass]); INI_Int(\"Cash\",PlayerInfo[playerid][pCash]); INI_Int(\"Score\",PlayerInfo[playerid][pScore]); return 1;}public OnPlayerConnect(playerid){ if(fexist(UserPath(playerid))) { INI_ParseFile(UserPath(playerid), \"LoadUser_%s\", .bExtra = true, .extra = playerid); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,\"Bejelentkezés\",\"{FFFFFF}Ird be a a jelszavad\",\"Login\",\"Quit\"); }else{ ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,\"Regisztráció...\",\"{FFFFFF}Ird be a jelszavad az új acountért.\",\"Register\",\"Quit\");}return 1;}public OnPlayerDisconnect(playerid, reason){ new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,\"data\"); INI_WriteInt(File,\"Cash\",GetPlayerMoney(playerid)); INI_WriteInt(File,\"Score\",GetPlayerScore(playerid)); INI_Close(File);}public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){ switch( dialogid ) { case DIALOG_REGISTER: { if (!response) return Kick(playerid); if(response) { if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, \"Regisztráció...\",\"{F81414}Rossz jelszót adtál meg.\\n{FFFFFF}Ird be a jelszavad az új acountért.\",\"Register\",\"Quit\"); new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,\"data\"); INI_WriteInt(File,\"Password\",udb_hash(inputtext)); INI_WriteInt(File,\"Cash\",0); INI_WriteInt(File,\"Score\",0); INI_Close(File); SendClientMessage(playerid, 0x1eff00AA, \"Beregisztráltál!!\"); } } case DIALOG_LOGIN: { if ( !response ) return Kick ( playerid ); if( response ) { if(udb_hash(inputtext) == PlayerInfo[playerid][pPass]) { INI_ParseFile(UserPath(playerid), \"LoadUser_%s\", .bExtra = true, .extra = playerid); GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]); SetPlayerScore(playerid, PlayerInfo[playerid][pScore]); SendClientMessage(playerid, 0x1eff00AA, \"Bejelentkeztél!\"); } else { ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,\"Login\",\"{F81414}Nem helyes jelszót adtál meg\\n{FFFFFF}Ird be újra a belépéshez\",\"Login\",\"Quit\"); } return 1; } return 1; }}return 0;}stock UserPath(playerid){ new string[128],playername[MAX_PLAYER_NAME]; GetPlayerName(playerid,playername,sizeof(playername)); format(string,sizeof(string),PATH,playername); return string;}stock udb_hash(buf[]) { new length=strlen(buf); new s1 = 1; new s2 = 0; new n; for (n=0; n<length; n++) { s1 = (s1 + buf[n]) % 65521; s2 = (s2 + s1) % 65521; } return (s2 << 16) + s1;}