01.01.2014, 12:49
I have a problem with my admin system, so basically it creates the players ini fiel in the scriptfiles, but unfortunately it's blank so anytime you go back into the game it does recognize your username (because of the playername.ini) but it doesn't load his password or money or anything because it's blank. SO whats the problem? Is it some plugin,or missing folder? or what? Let me sohw you the code.
ALL PLUGINS
OnPlayerConnect(playerid);
OnDialogResponse
I guess the code looks alright, I've created the empty folder in the scriptfiles with the name " Users" as it's codded,so basically it does save the palyer , Playername.ini" but it's empty.
ALL PLUGINS
Код:
#include <a_samp> #include <ZCMD> #include <YSI\y_ini> #include <sscanf2> #include <dini> #include <streamer> #include <a_angles> #include <sscanf2> #include <foreach>
Код:
#define DIALOG_REGISTER 1 #define DIALOG_LOGIN 2 #define DIALOG_SUCCESS_1 3 #define DIALOG_SUCCESS_2 4 #define PATH "/Users/%s.ini"
Код:
if(fexist(UserPath(playerid))) { INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit"); } else { ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registeration",""COL_WHITE"Type your password below to register a new account.","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,"Admin",PlayerInfo[playerid][pAdmin]); INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]); INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]); INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]); INI_WriteInt(File,"VIP",PlayerInfo[playerid][pVIP]); INI_WriteInt(File,"FightStyle",PlayerInfo[playerid][pFightStyle]); INI_WriteInt(File,"Warnings",PlayerInfo[playerid][pWarnings]); INI_WriteInt(File,"Hours", PlayerInfo[playerid][pPlayingTime]); INI_WriteInt(File,"Kicks", PlayerInfo[playerid][pKicks]); INI_Close(File); return 1; }
Код:
switch( dialogid ) { case DIALOG_REGISTER: { if (!response) return Kick(playerid); if(response) { if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","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,"Admin",0); INI_WriteInt(File,"Kills",0); INI_WriteInt(File,"Deaths",0); INI_WriteInt(File,"Level",0); INI_WriteInt(File,"VIP",0); INI_WriteInt(File,"FightStyle",0); INI_WriteInt(File,"Warnings",0); INI_WriteInt(File,"Hours",0); INI_WriteInt(File,"Kicks",0); INI_Close(File); SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0); SpawnPlayer(playerid); ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You're account was converted, please relog","Ok",""); TogglePlayerControllable(playerid, false); } } 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]); if(PlayerInfo[playerid][pAdmin] == 1 || PlayerInfo[playerid][pAdmin] == 2 || PlayerInfo[playerid][pAdmin] == 3 || PlayerInfo[playerid][pAdmin] == 4 || PlayerInfo[playerid][pAdmin] == 5) { SendClientMessage(playerid, COLOR_GREEN, "AdminMOTD: Stay connected and use your commands wisely"); } } else { ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit"); } return 1; } }