SA-MP Forums Archive
server sided money question - 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: server sided money question (/showthread.php?tid=608627)



server sided money question - tommzy09 - 03.06.2016

okay, so on my server, when someone dies and loses $100, for some reason the anticheat has a spasm.

if(GetPlayerCash(playerid) < GetPlayerMoney(playerid))
{
-anticheat code here-
}

i was wondering how to make it only detect when say, GetPlayerMoney is more than 101 for example.

if(GetPlayerCash(playerid) < 100 of GetPlayerMoney(playerid))

but adding it like that in the script doesn't work. how do i go about making that check in 1 singular line? by that check i mean the <100


Re: server sided money question - justjamie - 03.06.2016

Hmm give me the command / a function where you add money


Re: server sided money question - oMa37 - 03.06.2016

Something like this.

PHP код:
if(GetPlayerCash(playerid) < (GetPlayerMoney(playerid) == 100)) 



Re: server sided money question - tommzy09 - 03.06.2016

PHP код:
if(strcmp(cmd"/money"true) == 0)
{
if(
pInfo[playerid][pAdmin] == 0) return SendClientMessage(playeridWHITE"SERVER: Unknown command.");
if(
pInfo[playerid][pLogin] == 0) return SendClientMessage(playeridRED"Register or Login first before using this command!");
new 
stringadm[64];
if (
pInfo[playerid][pAdmin] >= 4){
GivePlayerCash(playerid1000000);
format(stringadm,sizeof(stringadm),"[ADM]: %s used /money",GetName(playerid));
SendToAdmin(COLOR_ADM,stringadm);
}
return 
1;




Re: server sided money question - Infinity - 03.06.2016

Quote:
Originally Posted by oMa37
Посмотреть сообщение
Something like this.

PHP код:
if(GetPlayerCash(playerid) < (GetPlayerMoney(playerid) == 100)) 
That makes zero sense whatsoever.

@OP:
You don't want to make exceptions. For every instance that the player gets or loses money in your server, also apply this to the variable. If this is done correctly, your anti cheat will function as expected.


Re: server sided money question - justjamie - 03.06.2016

You wanna make a variable with enums to check if that variable matches the player money.
If it doesn't matches, you can make a message to admins saying "Player's money doesn't matches", or automatically ban him.


Re: server sided money question - tommzy09 - 03.06.2016

i've noticed a bug where if the player dies from an explosion but is still on fire afterwards, they run around for a bit and the client hasn't removed the $100 yet but the server has already acknowledged that they died and removed $100, the check for money hacks runs once every 5 seconds if the players server sided cash is less than the players client sided cash. I want to add an exception of $100 to negate this. I doubt anyone will sit their giving themselves $100 each time they die to bypass the anticheat


Re: server sided money question - tommzy09 - 03.06.2016

fixed it myself with a bit more extensive trial and error. thanks for the help guys


Re: server sided money question - ilijap - 03.06.2016

Btw try with adding temp 100$ on player's money And then check


Re: server sided money question - Stinged - 03.06.2016

Quote:
Originally Posted by tommzy09
Посмотреть сообщение
fixed it myself with a bit more extensive trial and error. thanks for the help guys
I know you already fixed it but I'll just explain why that's happening.

Server sided money is just a number in a variable.
When the server automatically removed $100 on the player's death/spawn, it's not updating that variable.
So you can either decrease the player's variable by 100 when the player dies, or you can remove the -$100 feature by resetting the player's money and giving them the number in their variable.