09.06.2016, 18:02
I have the following code.
And according to this a player when registered for first time, he will spawn with 1000 $... but actually it spwans with no money.
PHP код:
#include <YSI\y_ini>
enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths,
pBuisness,
pFaction,
pFacrank,
pFacleader,
pWantedlevel,
pLals,
pLalsrank,
pDrivinglic,
pWeaponlic,
pFlyinglic,
pSailinglic,
pDruglic,
pSec,
pBankcash,
pHour,
pMin,
pRespect,
pLevel,
pNewres,
pMateriallic,
pCar1,
pCar1col1,
pCar1col2,
pCar1plate,
pCar1fuel,
pCar1pos,
pCar2,
pCar2col1,
pCar2col2,
pCar2plate,
pCar2fuel,
pCar2pos,
pCar3,
pCar3col1,
pCar3col2,
pCar3plate,
pCar3fuel,
pCar3pos,
pLvtaxi,
pLalv
}
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("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
INI_Int("Buisness",PlayerInfo[playerid][pBuisness]);
INI_Int("Faction",PlayerInfo[playerid][pFaction]);//when the player logs in it will load his faction id
INI_Int("Facrank",PlayerInfo[playerid][pFacrank]);// when the player logs in it will load his faction rank
INI_Int("Facleader",PlayerInfo[playerid][pFacleader]);//when the player logs in it will load his leadership status
INI_Int("Wantedlevel",PlayerInfo[playerid][pWantedlevel]);
INI_Int("Lals",PlayerInfo[playerid][pLals]);
INI_Int("Lalsrank",PlayerInfo[playerid][pLalsrank]);
INI_Int("DrivingLic",PlayerInfo[playerid][pDrivinglic]);
INI_Int("WeaponLic",PlayerInfo[playerid][pWeaponlic]);
INI_Int("FlyingLic",PlayerInfo[playerid][pFlyinglic]);
INI_Int("SailingLic",PlayerInfo[playerid][pSailinglic]);
INI_Int("DrugLic",PlayerInfo[playerid][pDruglic]);
INI_Int("Sec",PlayerInfo[playerid][pSec]);
INI_Int("Bankcash",PlayerInfo[playerid][pBankcash]);
INI_Int("Hour",PlayerInfo[playerid][pHour]);
INI_Int("Min",PlayerInfo[playerid][pMin]);
INI_Int("Respect",PlayerInfo[playerid][pRespect]);
INI_Int("Level",PlayerInfo[playerid][pLevel]);
INI_Int("Newres",PlayerInfo[playerid][pNewres]);
INI_Int("Materiallic",PlayerInfo[playerid][pMateriallic]);
INI_Int("Car1",PlayerInfo[playerid][pCar1]);
INI_Int("Car1col1",PlayerInfo[playerid][pCar1col1]);
INI_Int("Car1col2",PlayerInfo[playerid][pCar1col2]);
INI_Int("Car1plate",PlayerInfo[playerid][pCar1plate]);
INI_Int("Car1fuel",PlayerInfo[playerid][pCar1fuel]);
INI_Int("Car1pos",PlayerInfo[playerid][pCar1pos]);
INI_Int("Car2",PlayerInfo[playerid][pCar2]);
INI_Int("Car2col1",PlayerInfo[playerid][pCar2col1]);
INI_Int("Car2col2",PlayerInfo[playerid][pCar2col2]);
INI_Int("Car2plate",PlayerInfo[playerid][pCar2plate]);
INI_Int("Car2fuel",PlayerInfo[playerid][pCar2fuel]);
INI_Int("Car2pos",PlayerInfo[playerid][pCar2pos]);
INI_Int("Car3",PlayerInfo[playerid][pCar3]);
INI_Int("Car3col1",PlayerInfo[playerid][pCar3col1]);
INI_Int("Car3col2",PlayerInfo[playerid][pCar3col2]);
INI_Int("Car3plate",PlayerInfo[playerid][pCar3plate]);
INI_Int("Car3fuel",PlayerInfo[playerid][pCar3fuel]);
INI_Int("Car3pos",PlayerInfo[playerid][pCar3pos]);
INI_Int("Lvtaxi",PlayerInfo[playerid][pLvtaxi]);
INI_Int("Lalv",PlayerInfo[playerid][pLalv]);
return 1;
}
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
public OnPlayerDisconnect(playerid, reason) //===========================================================REGISTER===========================================
{
TextDrawHideForPlayer(playerid, Time), TextDrawHideForPlayer(playerid, Date);
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,"Buisness",PlayerInfo[playerid][pBuisness]);
INI_WriteInt(File,"Faction",PlayerInfo[playerid][pFaction]);
INI_WriteInt(File,"Facrank",PlayerInfo[playerid][pFacrank]);
INI_WriteInt(File,"Facleader",PlayerInfo[playerid][pFacleader]);
INI_WriteInt(File,"Wantedlevel",PlayerInfo[playerid][pWantedlevel]);
INI_WriteInt(File,"Lals",PlayerInfo[playerid][pLals]);
INI_WriteInt(File,"Lalsrank",PlayerInfo[playerid][pLalsrank]);
INI_WriteInt(File,"DrivingLic",PlayerInfo[playerid][pDrivinglic]);
INI_WriteInt(File,"WeaponLic",PlayerInfo[playerid][pWeaponlic]);
INI_WriteInt(File,"FlyingLic",PlayerInfo[playerid][pFlyinglic]);
INI_WriteInt(File,"SailingLic",PlayerInfo[playerid][pSailinglic]);
INI_WriteInt(File,"DrugLic",PlayerInfo[playerid][pDruglic]);
INI_WriteInt(File,"Sec",PlayerInfo[playerid][pSec]);
INI_WriteInt(File,"Bankcash",PlayerInfo[playerid][pBankcash]);
INI_WriteInt(File,"Hour",PlayerInfo[playerid][pHour]);
INI_WriteInt(File,"Min",PlayerInfo[playerid][pMin]);
INI_WriteInt(File,"Respect",PlayerInfo[playerid][pRespect]);
INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
INI_WriteInt(File,"Newres",PlayerInfo[playerid][pNewres]);
INI_WriteInt(File,"Materiallic",PlayerInfo[playerid][pMateriallic]);
INI_WriteInt(File,"Car1",PlayerInfo[playerid][pCar1]);
INI_WriteInt(File,"Car1col1",PlayerInfo[playerid][pCar1col1]);
INI_WriteInt(File,"Car1col2",PlayerInfo[playerid][pCar1col2]);
INI_WriteInt(File,"Car1plate",PlayerInfo[playerid][pCar1plate]);
INI_WriteInt(File,"Car1fuel",PlayerInfo[playerid][pCar1fuel]);
INI_WriteInt(File,"Car1pos",PlayerInfo[playerid][pCar1pos]);
INI_WriteInt(File,"Car2",PlayerInfo[playerid][pCar2]);
INI_WriteInt(File,"Car2col1",PlayerInfo[playerid][pCar2col1]);
INI_WriteInt(File,"Car2col2",PlayerInfo[playerid][pCar2col2]);
INI_WriteInt(File,"Car2plate",PlayerInfo[playerid][pCar2plate]);
INI_WriteInt(File,"Car2fuel",PlayerInfo[playerid][pCar2fuel]);
INI_WriteInt(File,"Car2pos",PlayerInfo[playerid][pCar2pos]);
INI_WriteInt(File,"Car3",PlayerInfo[playerid][pCar3]);
INI_WriteInt(File,"Car3col1",PlayerInfo[playerid][pCar3col1]);
INI_WriteInt(File,"Car3col2",PlayerInfo[playerid][pCar3col2]);
INI_WriteInt(File,"Car3plate",PlayerInfo[playerid][pCar3plate]);
INI_WriteInt(File,"Car3fuel",PlayerInfo[playerid][pCar3fuel]);
INI_WriteInt(File,"Car3pos",PlayerInfo[playerid][pCar3pos]);
INI_WriteInt(File,"Lvtaxi",PlayerInfo[playerid][pLvtaxi]);
INI_WriteInt(File,"Lalv",PlayerInfo[playerid][pLalv]);
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",1000);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Buisness",0);
INI_WriteInt(File,"Faction",0);
INI_WriteInt(File,"Facrank",0);
INI_WriteInt(File,"Facleader",0);
INI_WriteInt(File,"Wantedlevel",0);
INI_WriteInt(File,"Lals",0);
INI_WriteInt(File,"Lalsrank",0);
INI_WriteInt(File,"DrivingLic",0);
INI_WriteInt(File,"WeaponLic",0);
INI_WriteInt(File,"FlyingLic",0);
INI_WriteInt(File,"SailingLic",0);
INI_WriteInt(File,"DrugLic",0);
INI_WriteInt(File,"Sec",0);
INI_WriteInt(File,"Bankcash",1000);
INI_WriteInt(File,"Hour",0);
INI_WriteInt(File,"Min",0);
INI_WriteInt(File,"Respect",1);
INI_WriteInt(File,"Level",1);
INI_WriteInt(File,"Newres",3);
INI_WriteInt(File,"Materiallic",0);
INI_WriteInt(File,"Lictime",0);
INI_WriteInt(File,"Car1",510);
INI_WriteInt(File,"Car1col1",46);
INI_WriteInt(File,"Car1col2",46);
INI_WriteInt(File,"Car1plate",0);
INI_WriteInt(File,"Car1fuel",0);
INI_WriteInt(File,"Car1pos",0);
INI_WriteInt(File,"Car2",0);
INI_WriteInt(File,"Car2col1",0);
INI_WriteInt(File,"Car2col2",0);
INI_WriteInt(File,"Car2plate",0);
INI_WriteInt(File,"Car2fuel",0);
INI_WriteInt(File,"Car2pos",0);
INI_WriteInt(File,"Car3",0);
INI_WriteInt(File,"Car3col1",0);
INI_WriteInt(File,"Car3col2",0);
INI_WriteInt(File,"Car3plate",0);
INI_WriteInt(File,"Car3fuel",0);
INI_WriteInt(File,"Car3pos",0);
INI_WriteInt(File,"Lvtaxi",0);
INI_WriteInt(File,"Lalv",0);
INI_Close(File);
SetSpawnInfo(playerid, 0, 0,2135.9507,1398.3468,10.4452,0.6267, 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","");
}
}
}
}