PDA

View Full Version : server sided money question


tommzy09
03/06/2016, 11:33 AM
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

justjamie
03/06/2016, 11:34 AM
Hmm give me the command / a function where you add money

oMa37
03/06/2016, 11:38 AM
Something like this.


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

tommzy09
03/06/2016, 11:40 AM
if(strcmp(cmd, "/money", true) == 0)
{
if(pInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, WHITE, "SERVER: Unknown command.");
if(pInfo[playerid][pLogin] == 0) return SendClientMessage(playerid, RED, "Register or Login first before using this command!");
new stringadm[64];
if (pInfo[playerid][pAdmin] >= 4){
GivePlayerCash(playerid, 1000000);
format(stringadm,sizeof(stringadm),"[ADM]: %s used /money",GetName(playerid));
SendToAdmin(COLOR_ADM,stringadm);
}
return 1;
}

Infinity
03/06/2016, 11:41 AM
Something like this.


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.

justjamie
03/06/2016, 11:43 AM
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.

tommzy09
03/06/2016, 11:49 AM
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

tommzy09
03/06/2016, 12:35 PM
fixed it myself with a bit more extensive trial and error. thanks for the help guys

ilijap
03/06/2016, 12:59 PM
Btw try with adding temp 100$ on player's money And then check

Stinged
03/06/2016, 01:05 PM
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.