SA-MP Forums Archive
Code for cash 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: Code for cash on spawn (/showthread.php?tid=218151)



Code for cash on spawn - David5290 - 29.01.2011

Anyone have code to set everyones money on Spawn?

Ex:
public OnPlayerSpawn()
{
GivePlayerMoney(playerid, 5000)
}


Re: Code for cash on spawn - armyoftwo - 29.01.2011

pawn Код:
public OnPlayerSpawn(playerid)
{
        GivePlayerMoney(playerid, 5000)
        return 1;
}



- David5290 - 29.01.2011

Thanks, I knew it was something like that, I thought I had that already in the OnPlayerSpawn >.<

Problem, everytime I die, I recieve the 5000 again.

Ex: I start out with 5000
/kill..I restart and now I have 10000
etc.

Would I add something to OnPlayerDeath?


Re: Code for cash on spawn - [P4] - 29.01.2011

-removed-
And im stupid


Re: Code for cash on spawn - JaTochNietDan - 29.01.2011

Then just use the following to make sure the player only has $5000 on spawn, since you did say you want to set their money and not give them money:

pawn Код:
public OnPlayerSpawn(playerid)
{
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid,5000);
    return 1;
}
You need to use some algorithmic problem solving


Re: Code for cash on spawn - David5290 - 29.01.2011

Alright, what I really wanted was a system where when you die, it takes a certain amount of money away.
Instead of just resetting to 5000 every time ><


Re: Code for cash on spawn - admantis - 29.01.2011

pawn Код:
// This function sets a random money between 2000-5000 when you spawn.
public OnPlayerSpawn(playerid)
{
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid,2000+random(3000));
    return 1;
}
I dont know if you mean this


Re: Code for cash on spawn - JaTochNietDan - 29.01.2011

Okay well then make use of OnPlayerDeath and OnPlayerConnect.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    GivePlayerMoney(playerid,-2000);
    return 1;
}

public OnPlayerConnect(playerid)
{
    GivePlayerMoney(playerid,5000);
    return 1;
}
I hope that helps!


Re: Code for cash on spawn - David5290 - 29.01.2011

Quote:
Originally Posted by admantis
Посмотреть сообщение
pawn Код:
// This function sets a random money between 2000-5000 when you spawn.
public OnPlayerSpawn(playerid)
{
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid,2000+random(3000));
    return 1;
}
I dont know if you mean this
Like when you die, it takes part of your money away.

Ex: I start out with 5000
And I die and my cash goes to 4000
And I die again and it goes to 3000 and so on


Re: Code for cash on spawn - David5290 - 29.01.2011

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Okay well then make use of OnPlayerDeath and OnPlayerConnect.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    GivePlayerMoney(playerid,-2000);
    return 1;
}

public OnPlayerConnect(playerid)
{
    GivePlayerMoney(playerid,5000);
    return 1;
}
I hope that helps!
It works, it takes away 2k but after I die it goes to 5000 again lol