Code for cash on spawn
#1

Anyone have code to set everyones money on Spawn?

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

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

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

-removed-
And im stupid
Reply
#5

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

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

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

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!
Reply
#9

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)