SA-MP Forums Archive
Y_INI Loads Help! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Y_INI Loads Help! (/showthread.php?tid=396565)



Y_INI Loads Help! - 69 - 01.12.2012

Right, so basically, I have a user account using Y_Ini. It has all that money, admin level, skin, etc... saves.
Basically, what I want is when a player changes skin it saves on the skin thing, but most of all, when a player connects, the money he has on Y_INI should go to his hands because as now, the money is just a number on his y_ini file.
I would also like that whenever a player gains or loses money, it edits the file with the money he currently has.
thx.


Re: Y_INI Loads Help! - [HK]Ryder[AN] - 01.12.2012

to give money to the player when he connects give him the amount of cash in his player variable (something like PlayerInfo[playerid][pMoney])

And instead of writing into the file on every loss or gain of money, simply update his variablle and save it in onplayerdisconnect


Re : Re: Y_INI Loads Help! - 69 - 01.12.2012

Quote:
Originally Posted by [HK]Ryder[AN]
Посмотреть сообщение
to give money to the player when he connects give him the amount of cash in his player variable (something like PlayerInfo[playerid][pMoney])

And instead of writing into the file on every loss or gain of money, simply update his variablle and save it in onplayerdisconnect
Mind elaborating/show me a script sample?


Re: Y_INI Loads Help! - gtakillerIV - 01.12.2012

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"Info");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][Admin]);
    INI_WriteInt(File,"Vip",PlayerInfo[playerid][Vip]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][Kills]);
    INI_WriteInt(File, "Score", GetPlayerScore(playerid));
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][Deaths]);
}
That's an example.

Load the user's file when he enters the correct password, from there you can use the function "GivePlayerMoney(playerid, PlayerInfo[playerid][Cash);".


Re : Y_INI Loads Help! - 69 - 01.12.2012

How do I make it so that whenever a player logs of it saves the amount of money he has in hand and not just a random number? Because for now it just knows that the thing is [Money] but it doesn't really know what it defines.
Same for skins, etc...


Re: Y_INI Loads Help! - Lz - 01.12.2012

pawn Код:
//Add this to when your server loads the players data.
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
pawn Код:
//Add this to your stock
INI_Int("Cash",PlayerInfo[playerid][pCash]);
And make sure you have cash added into your players enum, You'll have to edit the variables etc yourself as i don't know your script

Edit - To save when they log off add this to your OnPlayerDisconnect

pawn Код:
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));



Re : Y_INI Loads Help! - 69 - 01.12.2012

Got it, got it, thanks. I'd like to know how to make Y_INI save user files every 10 seconds and not just on player's logging off.


Re: Y_INI Loads Help! - gtakillerIV - 01.12.2012

Use a Timer and a loop to loop through each player and save his/her data.

https://sampwiki.blast.hk/wiki/SetTimer

https://sampwiki.blast.hk/wiki/Loops