It doesnt load the cash,to give it - 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: It doesnt load the cash,to give it (
/showthread.php?tid=473065)
It doesnt load the cash,to give it -
Tagathron - 01.11.2013
Код:
#define PATH "/Users/%s.ini"
new pCash[MAX_PLAYERS];
forward LoadUser_data(playerid, name[], value[]);
public LoadUser_data(playerid, name[], value[])
{
INI_Int("Player Money", pCash[playerid]);
return 1;
}
stock UserPath(playerid)
{
new string[128],pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string,sizeof(string), PATH, pName);
return string;
}
main()
{
print("\n----------------------------------");
print(" Reg system testing");
print("----------------------------------\n");
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File, "data");
INI_WriteInt(File, "Player Money", GetPlayerMoney(playerid));
INI_Close(File);
return 1;
}
public OnPlayerSpawn(playerid)
{
if(fexist(UserPath(playerid)))
{
SendClientMessage(playerid, 0xFFF0F0FC, "You're already registered.Your money is saved");
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra=true, .extra=playerid);
GivePlayerMoney(playerid, pCash[playerid]);
}
else
{
SendClientMessage(playerid, 0xFFF0F0FC, "You're not registered.");
}
return 1;
}
This is the file where the cash is stored:
Код:
[data]
Player Money = 1000
When you come ingame for first time,it sets the money to 0,but i edited it and set it to 1000,to check if it will load it on next come in game,and give it to player.But it doesn't.I does says you're registered when you come second time,but won't give the cash.
Re: It doesnt load the cash,to give it -
RowdyrideR - 01.11.2013
It's just all messed up, Follow Kush's tutorial:
https://sampforum.blast.hk/showthread.php?tid=273088
Re: It doesnt load the cash,to give it -
Tagathron - 01.11.2013
I followed it,but i tried to leave out some things...i'll just follow the whole thing and then inspect it...
Re: It doesnt load the cash,to give it -
Beckett - 01.11.2013
This code is completely messed up, i recommend you to follow one of the tutorials.
Re: It doesnt load the cash,to give it -
Wizzy951 - 01.11.2013
I'm not sure if this will work in your case but you can try it:
pawn Код:
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, pInfo[playerid][pCash]);
EDIT: Don't you use an enumerator ?