How is it possible ? -
Shaheen - 19.04.2020
PHP Code:
stock giveMoney(playerid, amount)
{
Player[playerid][playerMoney] += amount;
ResetPlayerMoney(playerid);
return GivePlayerMoney(playerid, Player[playerid][playerMoney]);
}
This is my code for giving money to players. but still they can hack money like i saw one player getting $200m
in 5 or 6 scores. how is it possible and how can i prevent it ??
Helps appreciated.
Thank you.
Re: How is it possible ? -
Kent - 19.04.2020
The only way to prevent that is to add a listener. If the money isn't server-sided, its money will return to the variable assigned to the player.
Re: How is it possible ? -
YouShootIDodge - 19.04.2020
Set a timer which checks if the value of the server-sided money matches with the GetPlayerMoney ();
Re: How is it possible ? -
Calisthenics - 19.04.2020
You may have a new function that gives server-side money but how do you get the money a player has? If you use `GetPlayerMoney`, it can return money from cheats. Use:
pawn Code:
stock getMoney(playerid)
{
return Player[playerid][playerMoney];
}
Re: How is it possible ? -
David (Sabljak) - 19.04.2020
https://sampforum.blast.hk/showthread.php?tid=71136
Use this tutorial.
And import this to time like for every 5 sec..
Code:
public MoneyTimer()
{
new username[MAX_PLAYER_NAME];
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerCash(i) != GetPlayerMoney(i))
{
ResetMoneyBar(i);//Resets the money in the original moneybar, Do not remove!
UpdateMoneyBar(i,GetPlayerCash(i));//Sets the money in the moneybar to the serverside cash, Do not remove!
new hack = GetPlayerMoney(i) - GetPlayerCash(i);
GetPlayerName(i,username,sizeof(username));
printf("%s has picked up/attempted to spawn $%d.", username,hack);
}
}
}
}
This is theme from 2009, you can improve code with foreach etc etc...
This is most importnant.
Re: How is it possible ? -
Shaheen - 19.04.2020
I had checked every stuffs in the code and i have the things that u guys told.
Its a gamemode from scratch which is available in forums. So if hackers gets the variable i am using for giving money can they hack using that ?
Anyway its server sided money in the script and i am sure about that.
Re: How is it possible ? -
David (Sabljak) - 19.04.2020
Quote:
Originally Posted by Shaheen
I had checked every stuffs in the code and i have the things that u guys told.
Its a gamemode from scratch which is available in forums. So if hackers gets the variable i am using for giving money can they hack using that ?
Anyway its server sided money in the script and i am sure about that.
|
Do you even read my post?
if(GetPlayerCash(i) != GetPlayerMoney(i)) this is for reset
Re: How is it possible ? -
l0gic - 19.04.2020
dont to those stupid checks
just create variable
PHP Code:
new PlayerMoney[MAX_PLAYERS];
PlayerMoney[playerid] += 100; // for adding money to player
PlayerMoney[playerid] -= 100; // for taking money from player
if(PlayerMoney[playerid] < 100){ // for checking if player has enough money
SendClientMessage(playerid, -1, "You don't have enough money for this item!");
}
Player doesn't have any way to change this money amount, its that simple.
And dont use GetPlayerMoney and GivePlayerMoney, because playerside can change those values.
Less timers checking every player on server, the better it is for playerbase.