SA-MP Forums Archive
serverside money - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: serverside money (/showthread.php?tid=256875)



serverside money - Headshot1108 - 22.05.2011

i have a problem with my serverside money.
all works fine, but when i buy something from ammu nation or from the soda machine my old money will be restored what is annoying.

my current code:

pawn Code:
forward MoneyHack();
public MoneyHack()
{
    foreach(Player, i)
    {
        if(GetPlayerCash(i) != GetPlayerMoney(i))
        {
            SetPlayerCash(i, GetPlayerCash(i));
        }
    }
}
this one is the best.

for example when I use

if(GetPlayerCash(i) > GetPlayerMoney(i)) (so he bought a soda or something)
to set the new money it will bug sometimes (when they received money with my 'GivePlayerCash' function, it will restored).

best solution would be to check if the player is using the soda machine / ammu nation.


Respuesta: serverside money - admantis - 22.05.2011

You need to script the soda machines / ammu nations to fit with your anti cheat not use the default GTA ones.


Re: serverside money - Headshot1108 - 22.05.2011

what exactly you mean?
how can i script them??


Re: serverside money - xalith - 22.05.2011

you need to exclude them from your anticheat, which may not be possible with the default samp soda machine ( i think)


Re: serverside money - Headshot1108 - 22.05.2011

i know that i must exclude / script them, the question is how and if that is possible..


Re: serverside money - Headshot1108 - 23.05.2011

bump***********


Re: serverside money - AlternativeDC - 23.05.2011

you can see moneys? in textdraw?


Re: serverside money - Headshot1108 - 23.05.2011

what?
i dont have money in textdraws.


Re: serverside money - Babul - 23.05.2011

add a check for the players client money compared to your server money variable
if the client (game) GetPlayerMoney is bigger, then the player cheated.
if its smaller, then set the serversided variable to the one you got from the client. no cheater will set his money to $0 i bet...
Code:
forward MoneyHack();public MoneyHack(){
	new ClientCash;
	foreach(Player, i)
	{
		ClientCash=GetPlayerMoney(i);
		if(ClientCash < GetPlayerCash(i))//like a SyncPlayerServerMoneyToClientMoneyWhenBoughtSomethin()
		{
			SetPlayerCash(i, ClientCash);
		}
		else if(ClientCash > GetPlayerCash(i))
		{
			//player got too much cash :)
		}
	}
	return 1;
}



Re: serverside money - Headshot1108 - 23.05.2011

i have this code already.
and from my players the money sometimes suddenly restores (to zero)..
also when im spawning i scripted that you will get $1000, but sometimes my $1000 will be restored to my old money. so i think the problems belong together.

i think it's because of the ClientCash < GetPlayerCash(i), because when i only do the code from my first post, my spawn money will not be restored.