Cash Money lost
#1

If i died. and it stole some of the cash. as i search it was a money default takes -100 cash from you.
Anyhow to do this? like it shows the fake money then if i spawn again. it show the real money

Save / load in mysql
Код:
PlayerInfo[playerid][Money]
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new currentCash = GetPlayerMoney(playerid);
    if (currentCash >= 100) currentCash += 100;
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid, currentCash);
  	return 1;
}
Reply
#2

If you don't want like that, i suggest you use server side money.
Because that's -100 money is default on the based game.
Reply
#3

Quote:
Originally Posted by haikalbintang
Посмотреть сообщение
If you don't want like that, i suggest you use server side money.
Because that's -100 money is default on the based game.
example on side money?

i never had this problem before.
I know there are side money but which one is the best code?
Reply
#4

bump
Reply
#5

Read this :
https://sampforum.blast.hk/showthread.php?tid=71136
Reply
#6

Quote:
Originally Posted by haikalbintang
Посмотреть сообщение
Still the same it kept showing fake money.
Reply
#7

bump
Reply
#8

A simple solution to this is to always update your player's money on OnPlayerUpdate.

Код:
public OnPlayerUpdate(playerid)
{
        if (GetPlayerMoney(playerid) != PlayerInfo[playerid][Money])
	{
		ResetPlayerMoney(playerid);
		GivePlayerMoney(playerid, PlayerInfo[playerid][Money]);
	}
        return 1;
}
This way everytime the player does anything (or just stands still for that matter) their money gets updated if the displayed amount of cash is not the same as the server-sided money is.

Edit: Just to add, the problem itself can never be removed as above respondants have answered but this way is what I found to be the least "not noticeable" way, I never noticed the money change with this at least.
Reply
#9

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
A simple solution to this is to always update your player's money on OnPlayerUpdate.

Код:
public OnPlayerUpdate(playerid)
{
        if (GetPlayerMoney(playerid) != PlayerInfo[playerid][Money])
	{
		ResetPlayerMoney(playerid);
		GivePlayerMoney(playerid, PlayerInfo[playerid][Money]);
	}
        return 1;
}
This way everytime the player does anything (or just stands still for that matter) their money gets updated if the displayed amount of cash is not the same as the server-sided money is.
It still shows the fake cash
Reply
#10

Then you haven't used your variable "PlayerInfo[playerid][Money]" properly. That thing right there literally will reset the money and then give the player the real amount of money IF and ONLY IF the player's money and server-sided money is not same.

Check where you have used PlayerInfo[playerid][Money] and where you have used "GivePlayerMoney".

Edit: Alternatively add a new function:

Код:
GivePlayerMoneyEx(playerid, amount)
{
    ResetPlayerMoney(playerid);
    PlayerInfo[playerid][Money] += amount;
    GivePlayerMoney(playerid, PlayerInfo[playerid][Money]);
}
and replace it with all the "GivePlayerMoney".
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)