Problem in YSI/y_ini user data
#1

I have the following code.
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(playeridreason)                 //===========================================================REGISTER===========================================
{
    
TextDrawHideForPlayer(playeridTime), TextDrawHideForPlayer(playeridDate);
    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(playeriddialogidresponselistiteminputtext[])
{
    switch( 
dialogid )
    {
        case 
DIALOG_REGISTER:
        {
            if (!
response) return Kick(playerid);                  
            if(
response)
            {
                if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_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(playerid00,2135.9507,1398.3468,10.4452,0.6267000000);
                
SpawnPlayer(playerid);
                
ShowPlayerDialog(playeridDIALOG_SUCCESS_1DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
               }
        }
  }

And according to this a player when registered for first time, he will spawn with 1000 $... but actually it spwans with no money.
Reply
#2

I didn't read the code because I'm gonna ask this first:
Are you actually giving the money?
Reply
#3

Ya i know its annoying to read such code. Sorry for that. Yes I want player to be spawned with 1000 $ when registered for first time. No I am not doing anything like "GivePlayerMoney(playerid,1000);" under first time register dialog because i think according to the above code it saves '1000' in "Cash" , inside scriptfiles.
Reply
#4

Yes, it saves it into a file.
But you still need to use GivePlayerMoney.

You should also set the player's money variable/enum thingy to 1000 when the player registers.
And then under OnPlayerSpawn:
Код:
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
And whenever you want to give the player money, you have to also update PlayerInfo[playerid][pCash].

Also, udh_hash (adler32) is very bad in terms of security.
You should use SHA256, or a plugin like Whirlpool.
Reply
#5

Thanks for help and I will definitely use SHA256. Can I ask one little question?
I have stored a value in "PlayerInfo[playerid][pCar1posx]" like:-
PHP код:
PlayerInfo[playerid][pCar1posx] = 2440.2104
It gives warning: Tag mismatch. I know it is because I have not declared it as float. But when I changed "pCar1posx" to "Float: pCar1posx" under 'enum', then a new warning occoured on :-
PHP код:
INI_Int("Car1posx",PlayerInfo[playerid][pCar1posx]);  // under public LoadUser_data(playerid,name[],value[]) 
How to fix this??
Reply
#6

Quote:
Originally Posted by rishabh
Посмотреть сообщение
Thanks for help and I will definitely use SHA256. Can I ask one little question?
I have stored a value in "PlayerInfo[playerid][pCar1posx]" like:-
PHP код:
PlayerInfo[playerid][pCar1posx] = 2440.2104
It gives warning: Tag mismatch. I know it is because I have not declared it as float. But when I changed "pCar1posx" to "Float: pCar1posx" under 'enum', then a new warning occoured on :-
PHP код:
INI_Int("Car1posx",PlayerInfo[playerid][pCar1posx]);  // under public LoadUser_data(playerid,name[],value[]) 
How to fix this??
Use INI_Float instead of INI_Int
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)