Y_INI Loads Help!
#1

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.
Reply
#2

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
Reply
#3

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?
Reply
#4

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);".
Reply
#5

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...
Reply
#6

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));
Reply
#7

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.
Reply
#8

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)