How do I set Money on spawn? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How do I set Money on spawn? (
/showthread.php?tid=255038)
How do I set Money on spawn? -
Emanuel_Rodriguez - 14.05.2011
Ok, first of all, I am not a noob, I know how to use dini. The only problem is, that i am trying to make it, where when u first spawn, u get 400$.
Re: How do I set Money on spawn? -
dr.pepper - 14.05.2011
Somewhere on top of script...:
pawn Код:
#define StartMoney 400 // Money that player has when he/she spawns
then..
pawn Код:
public OnPlayerSpawn(playerid)
{
GivePlayerMoney(playerid, StartMoney);
return 1;
}
Re: How do I set Money on spawn? -
PotH3Ad - 14.05.2011
This is what you mean I guess...
pawn Код:
public OnPlayerConnect(playerid)
{
SetPVarInt(playerid, "FirstSpawn", 1); //The player is going to spawn for the first time
return 1;
}
public OnPlayerSpawn(playerid)
{
if(GetPVarInt(playerid, "FirstSpawn")) //If its the first time the player has spawned
{
GivePlayerMoney(playerid, 400);
SetPVarInt(playerid, "FirstSpawn", 0);
}
return 1;
}
Re: How do I set Money on spawn? -
Seven_of_Nine - 14.05.2011
That means every time you connect and spawn you get that amount.
You said you aren't a noob to dini.. here you go:
pawn Код:
#define FirstMoney 400
public OnPlayerConnect(playerid)
{
new name[30],file[256];
GetPlayerName(playerid,name,sizeof(name));
format(file,sizeof(file),"Folder/%s.ini",name);
if(!dini_Exists(file)) {
dini_Create(file);
dini_IntSet(file, "Money", FirstMoney);
SetPVarInt(playerid,"Money",-1);
} else {
new money = dini_Int(file, "Money");
SetPVarInt(playerid,"Money",money);
}
return 1;
}
public OnPlayerDisconnect(playerid,reason)
{
new name[30],file[256];
GetPlayerName(playerid,name,sizeof(name));
format(file,sizeof(file),"Folder/%s.ini",name);
if(!dini_Exists(file))
dini_Create(file);
dini_IntSet(file, "Money", GetPlayerMoney(playerid));
return 1;
}
public OnPlayerSpawn(playerid)
{
if(GetPVarInt(playerid,"Money") != -1) {
GivePlayerMoney(playerid,GetPVarInt(playerid,"Money"));
} else {
GivePlayerMoney(playerid,FirstMoney);
}
return 1;
}