24.06.2012, 03:58
(
Последний раз редактировалось JustinAn; 24.06.2012 в 14:24.
)
Hey guys, I have a problem. Well first on my script when the player registers it sets their skin id '299' (claude skin)
Then when I log back in it sets it to CJ skin.
Here's my code
For On Dialog Response
Here's my onplayerdisconnect which saves the skin.
And finally here's my enum.
Didn't I do this all correctly? When the player disconnects it saves the skin.
And when the player registers, on setspawninfo, it sets the player's skin id '299'(claude skin).
Also I got the enum, for skin.
Then when I log back in it sets it to CJ skin.
Here's my code
For On Dialog Response
pawn Код:
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",10000);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Level",1);
INI_WriteInt(File,"Skin",299);
INI_Close(File);
SetSpawnInfo(playerid, 0, 299, 1642.3607, -2237.6353, 13.4985, 178.3274, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
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","");
}
}
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][pLevel]);
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
SpawnPlayer(playerid);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
}
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;
}
}
}
return 1;
}
pawn Код:
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",GetPlayerScore(playerid));
INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
INI_Close(File);
return 1;
}
pawn Код:
enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths,
pLevel,
pSkin
}
new PlayerInfo[MAX_PLAYERS][pInfo];
And when the player registers, on setspawninfo, it sets the player's skin id '299'(claude skin).
Also I got the enum, for skin.