25.05.2017, 16:07
Hey guys.
I'm currently writing a game mode with a simple y_ini register/login system.
The problem is when I exit the game and reconnect to the server again, the server says my password is incorrect (dialog). Can you help me with this one? Also, loading the saved position is not working properly (spawning at 0,0,0);
I'm currently writing a game mode with a simple y_ini register/login system.
The problem is when I exit the game and reconnect to the server again, the server says my password is incorrect (dialog). Can you help me with this one? Also, loading the saved position is not working properly (spawning at 0,0,0);
Код:
#include <a_samp> #include <zcmd> #include <YSI\y_ini> #include <fixchars.h> #include <streamer> main( ) { } #define COLOR_WHITE 0xFFFFFFAA #define PATH "/Users/%s.ini" #define dialog_reg 1 #define dialog_log 2 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; } enum pInfo { pJelszo, //PASSWORD Float:pPosX, Float:pPosY, Float:pPosZ, Float:pPosA } new PlayerInfo[MAX_PLAYERS][pInfo]; forward LoadUser_data(playerid, name[], value[]); public LoadUser_data(playerid, name[], value[]) { INI_Int("Jelszу", PlayerInfo[playerid][pJelszo]); //PASSWORD INI_Float("PosX", PlayerInfo[playerid][pPosX]); INI_Float("PosY", PlayerInfo[playerid][pPosY]); INI_Float("PosZ", PlayerInfo[playerid][pPosZ]); INI_Float("PosA", PlayerInfo[playerid][pPosA]); return 1; } public OnPlayerConnect(playerid) { if(fexist(UserPath(playerid))) { INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); ShowPlayerDialog(playerid, dialog_log, DIALOG_STYLE_INPUT, "{FFFFFF}Bejelentkezйs", "Нrd be a jelszavad a bejelentkezйshez:", "Tovбbb", "Kilйpйs"); //LOGIN DIALOG } else { ShowPlayerDialog(playerid, dialog_reg, DIALOG_STYLE_INPUT, "{FFFFFF}Regisztrбciу", "Нrj be egy kнvбnt jelszуt:", "Tovбbb", "Kilйpйs"); //REGISTER DIALOG } return 1; } public OnPlayerDisconnect(playerid, reason) { new INI:File = INI_Open(UserPath(playerid)); new Float:x, Float:y, Float:z, Float:a; GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, a); INI_SetTag(File, "Data"); INI_WriteFloat(File, "PosX", x); INI_WriteFloat(File, "PosY", y); INI_WriteFloat(File, "PosZ", z); INI_WriteFloat(File, "PosA", a); INI_Close(File); return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == dialog_reg) { if(!response) return Kick(playerid); if(response) { if(!strlen(inputtext)) return ShowPlayerDialog(playerid, dialog_reg, DIALOG_STYLE_INPUT, "{FFFFFF}Regisztrбciу", "Az бltalad megadott jelszу hibбs karaktert tartalmaz.\nPrуbбlj meg egy mбsikat:", "Tovбbb", "Kilйpйs"); //BAD CHARS IN PASSWORD new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File, "Data"); INI_WriteInt(File, "Jelszу", udb_hash(inputtext)); //PASSWORD INI_WriteInt(File, "Admin", 0); INI_WriteInt(File, "Szint", 1); INI_WriteInt(File, "Bank", 0); INI_WriteInt(File, "Munkanйlkьli", 1); INI_WriteInt(File, "Rendőr", 0); INI_WriteInt(File, "Mentős", 0); INI_WriteInt(File, "Tűzoltу", 0); //these are random stuff INI_WriteInt(File, "Szerelő", 0); INI_WriteInt(File, "Taxis", 0); INI_WriteInt(File, "Rбdiуs", 0); INI_WriteInt(File, "Buszos", 0); INI_WriteInt(File, "Pizzafutбr", 0); INI_WriteInt(File, "Ъttisztнtу", 0); INI_WriteInt(File, "Halбsz", 0); INI_WriteInt(File, "Favбgу", 0); INI_WriteInt(File, "Fűnyнrуs", 0); INI_WriteInt(File, "Йtelszбllнtу", 0); INI_WriteInt(File, "Csomagkihordу", 0); INI_WriteInt(File, "Postбs", 0); INI_WriteInt(File, "Villanyszerelő", 0); INI_WriteInt(File, "Kukбs", 0); INI_WriteInt(File, "Farmer", 0); INI_WriteInt(File, "Kőműves", 0); INI_WriteInt(File, "Mйrnцk", 0); INI_Close(File); ShowPlayerDialog(playerid, dialog_sk, DIALOG_STYLE_MSGBOX, "{FFFFFF}RP-kйrdйs 1/7", "{FFFFFF}Hogyan rцvidнtjьk a kцvetkezőt?:\nEgy jбtйkost a kezdőhelyйn megцlni.","SK","DB"); //stuff } } if(dialogid == dialog_log) { if(!response) Kick(playerid); if(response) { if(udb_hash(inputtext) == PlayerInfo[playerid][pJelszo]) { INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); ShowPlayerDialog(playerid, dialog_logsucc, DIALOG_STYLE_MSGBOX, "{FFFFFF}Bejelentkezйs", "{FFFFFF}Sikeresen bejelentkeztйl.","Tovбbb",""); GivePlayerMoney(playerid, PlayerInfo[playerid][pPenz]); admin[playerid] = PlayerInfo[playerid][pAdmin]; nem[playerid] = PlayerInfo[playerid][pNem]; kor[playerid] = PlayerInfo[playerid][pKor]; szarmazas[playerid] = PlayerInfo[playerid][pSzarmazas]; munkanelkuli[playerid] = PlayerInfo[playerid][pMunkanelkuli]; rendor[playerid] = PlayerInfo[playerid][pRendor]; mentos[playerid] = PlayerInfo[playerid][pMentos]; tuzolto[playerid] = PlayerInfo[playerid][pTuzolto]; szerelo[playerid] = PlayerInfo[playerid][pSzerelo]; taxis[playerid] = PlayerInfo[playerid][pTaxis]; radios[playerid] = PlayerInfo[playerid][pRadios]; buszos[playerid] = PlayerInfo[playerid][pBuszos]; pizzafutar[playerid] = PlayerInfo[playerid][pPizzafutar]; uttisztito[playerid] = PlayerInfo[playerid][pUttisztito]; halasz[playerid] = PlayerInfo[playerid][pHalasz]; favago[playerid] = PlayerInfo[playerid][pFavago]; funyiros[playerid] = PlayerInfo[playerid][pFunyiros]; etelszallito[playerid] = PlayerInfo[playerid][pEtelszallito]; csomagkihordo[playerid] = PlayerInfo[playerid][pCsomagkihordo]; postas[playerid] = PlayerInfo[playerid][pPostas]; villanyszerelo[playerid] = PlayerInfo[playerid][pVillanyszerelo]; kukas[playerid] = PlayerInfo[playerid][pKukas]; farmer[playerid] = PlayerInfo[playerid][pFarmer]; komuves[playerid] = PlayerInfo[playerid][pKomuves]; mernok[playerid] = PlayerInfo[playerid][pMernok]; SpawnPlayer(playerid); SetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]); SetPlayerFacingAngle(playerid, PlayerInfo[playerid][pPosA]); } else { ShowPlayerDialog(playerid, dialog_log, DIALOG_STYLE_PASSWORD, "{FFFFFF}Bejelentkezйs", "{FFFFFF}Hibбs jelszу!","Tovбbb","Kilйpйs"); } return 1; } } //NOW SOMETHING IS NOT WORKING UP HERE return 1; }