Cash Money lost - 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)
+--- Thread: Cash Money lost (
/showthread.php?tid=628400)
Cash Money lost -
DerickClark - 10.02.2017
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;
}
Re: Cash Money lost -
haikalbintang - 10.02.2017
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.
Re: Cash Money lost -
DerickClark - 10.02.2017
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?
Re: Cash Money lost -
DerickClark - 10.02.2017
bump
Re: Cash Money lost -
haikalbintang - 10.02.2017
Read this :
https://sampforum.blast.hk/showthread.php?tid=71136
Re: Cash Money lost -
DerickClark - 10.02.2017
Quote:
Originally Posted by haikalbintang
|
Still the same it kept showing fake money.
Re: Cash Money lost -
DerickClark - 10.02.2017
bump
Re: Cash Money lost -
Hansrutger - 10.02.2017
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.
Re: Cash Money lost -
DerickClark - 10.02.2017
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
Re: Cash Money lost -
Hansrutger - 10.02.2017
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".