Money problem(-100$) -
myhay9898 - 11.09.2018
Hello, i have a gamemode from 0 and if a player is death drop -100$.
How can i solve this problem?
Im so sorry for my bad eng.
Re: Money problem(-100$) -
UFF - 11.09.2018
I don't understand what you mean whether you want to add it or remove it. Anyways here is code
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
GivePlayerMoney(playerid, -100); // Takes off 100$ from the player who is dead.
return 1;
}
Re: Money problem(-100$) -
myhay9898 - 11.09.2018
I want to remove, but my OnPlayerDeath dont have lines.
Re: Money problem(-100$) -
akib - 11.09.2018
Quote:
Originally Posted by myhay9898
I want to remove, but my OnPlayerDeath dont have lines.
|
Just put these code in anywhere (under OnGameModeInit)
PHP код:
public OnPlayerDeath(playerid, killerid, reason)
{
GivePlayerMoney(playerid, -100);
return 1;
}
Re: Money problem(-100$) -
UFF - 11.09.2018
Quote:
Originally Posted by myhay9898
I want to remove, but my OnPlayerDeath dont have lines.
|
Do you mean that in your gamemode OnPlayerDeath has no lines but -100$ is taken off from the player who die?
Re: Money problem(-100$) -
B-rian - 11.09.2018
I'm pretty sure he means he doesn't want players to lose 100$ when they die.
Try doing the opposite, and OnPlayerDeath give the player 100$
As so:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
GivePlayerMoney(playerid, 100);
return 1;
}
This is because the money loss is trigerred on spawn, so if you give them 100$ when they die, the 100$ will then be removed when they spawn, so no money is lost.
Re: Money problem(-100$) -
Calisthenics - 11.09.2018
The game itself takes $100 away from the player upon death. The solution is simple: server-side money.
Re: Money problem(-100$) -
Alteh - 12.09.2018
Quote:
Originally Posted by B-rian
I'm pretty sure he means he doesn't want players to lose 100$ when they die.
Try doing the opposite, and OnPlayerDeath give the player 100$
As so:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
GivePlayerMoney(playerid, 100);
return 1;
}
This is because the money loss is trigerred on spawn, so if you give them 100$ when they die, the 100$ will then be removed when they spawn, so no money is lost.
|
That is wrong.
The problem of losing money when dyingh happens sometimes.
Solution:
Код:
#include <a_samp>
new Money[MAX_PLAYERS];
public OnPlayerUpdate(playerid)
{
if(GetPlayerMoney(playerid) != Money[playerid])
{
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,Money[playerid]);
}
return 1;
}
Re: Money problem(-100$) -
UFF - 12.09.2018
Quote:
Originally Posted by Alteh
That is wrong.
The problem of losing money when dyingh happens sometimes.
Solution:
Код:
#include <a_samp>
new Money[MAX_PLAYERS];
public OnPlayerUpdate(playerid)
{
if(GetPlayerMoney(playerid) != Money[playerid])
{
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, Money[playerid]);
}
return 1;
}
|
Seriously? can you explain how does that Money[playerid] will return the $100 back to the player when a player die?
Re: Money problem(-100$) -
Burridge - 12.09.2018
If the Money variable is set to an amount then OnPlayerUpdate will run that check to see if the player's shown money is the same as the variable, if not then it'll reset the money to 0 and then give the player the amount saved in the Money variable.
However, I would advise not using OnPlayerUpdate for such a check. Just use a timer.