enum pInfo { // other stuff pCash } new PlayerInfo[MAX_PLAYERS][pInfo]; forward LoadUser_data(playerid,name[],value[]); public LoadUser_data(playerid,name[],value[]) { // other stuff INI_Int("Cash",PlayerInfo[playerid][pCash]); return 1; } public OnPlayerConnect(playerid) { PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pAdmin] = 0; if(fexist(UserPath(playerid))) { PlayerInfo[playerid][pLogged] = 0; INI_ParseFile(UserPath(playerid), "LoadUser_data", .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 { PlayerInfo[playerid][pLogged] = 0; ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""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)); // other stuff INI_Close(File); return 1; } 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, ""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); // other stuff INI_Close(File); GivePlayerMoney(playerid, 5000); PlayerInfo[playerid][pLogged] = 1; ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok",""); PlayerInfo[playerid][pFirstSpawn] = 1; } } case DIALOG_LOGIN: { if ( !response ) return Kick ( playerid ); if( response ) { if(udb_hash(inputtext) == PlayerInfo[playerid][pPass]) { INI_ParseFile(UserPath(playerid), "LoadUser_data", .bExtra = true, .extra = playerid); GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]); SetPlayerScore(playerid, PlayerInfo[playerid][pScore]); ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok",""); PlayerInfo[playerid][pLogged] = 1; PlayerInfo[playerid][pFirstSpawn] = 1; } else { PlayerInfo[playerid][pFirstSpawn] = 0; PlayerInfo[playerid][pLogged] = 0; 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; } } } return 1; }
Do you have a folder at scriptfiles where you save the player status or
|
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
PlayerInfo[playerid][pLogged] = 0;
INI_ParseFile(UserPath(playerid), "LoadUser_data", .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
{
PlayerInfo[playerid][pLogged] = 0;
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
}
return 1;
}
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
// other stuff
INI_Int("Cash",GetPlayerMoney(playerid));
return 1;
}
PHP код:
PHP код:
|
D:\gamemodes\Untitled.pwn(483) : error 022: must be lvalue (non-constant)
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
// other stuff
INI_Int("Cash",PlayerInfo[playerid][pCash]);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
// other stuff
INI_Close(File);
return 1;
}
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
PlayerInfo[playerid][pLogged] = 0;
INI_ParseFile(UserPath(playerid), "LoadUser_data", .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
{
PlayerInfo[playerid][pLogged] = 0;
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
}
return 1;
}
PHP код:
PHP код:
PHP код:
|