Money problem(-100$)
#1

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

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;
}
Reply
#3

I want to remove, but my OnPlayerDeath dont have lines.
Reply
#4

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(playeridkilleridreason)
{
   
GivePlayerMoney(playerid, -100);
   return 
1;

Reply
#5

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

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

The game itself takes $100 away from the player upon death. The solution is simple: server-side money.
Reply
#8

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;
}
Reply
#9

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)