SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 19/04/2020, 06:10 AM   #1
Shaheen
Huge Clucker
 
Shaheen's Avatar
 
Join Date: Feb 2016
Location: Qatar
Posts: 221
Reputation: 24
Default How is it possible ?

PHP Code:
stock giveMoney(playeridamount)
{
    
Player[playerid][playerMoney] += amount;
    
ResetPlayerMoney(playerid);
    return 
GivePlayerMoney(playeridPlayer[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.
__________________


Add Me On Discord: Nightmare#6799
Shaheen is offline   Reply With Quote
Old 19/04/2020, 07:59 AM   #2
Kent
Big Clucker
 
Kent's Avatar
 
Join Date: Feb 2020
Location: Philippines
Posts: 64
Reputation: 2
Default Re: How is it possible ?

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.
__________________
Lawless Roleplay
Where Lunatics Prosper!
samp.lawlessrp.com
Kent is offline   Reply With Quote
Old 19/04/2020, 08:30 AM   #3
YouShootIDodge
Big Clucker
 
Join Date: May 2019
Posts: 74
Reputation: 15
Default Re: How is it possible ?

Set a timer which checks if the value of the server-sided money matches with the GetPlayerMoney ();
YouShootIDodge is offline   Reply With Quote
Old 19/04/2020, 08:32 AM   #4
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,226
Reputation: 205
Default Re: How is it possible ?

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];
}
__________________
Calisthenics is offline   Reply With Quote
Old 19/04/2020, 08:44 AM   #5
David (Sabljak)
Huge Clucker
 
Join Date: Nov 2011
Posts: 342
Reputation: 18
Default Re: How is it possible ?

https://forum.sa-mp.com/showthread.php?t=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.
David (Sabljak) is offline   Reply With Quote
Old 19/04/2020, 10:19 AM   #6
Shaheen
Huge Clucker
 
Shaheen's Avatar
 
Join Date: Feb 2016
Location: Qatar
Posts: 221
Reputation: 24
Default Re: How is it possible ?

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.
__________________


Add Me On Discord: Nightmare#6799
Shaheen is offline   Reply With Quote
Old 19/04/2020, 10:47 AM   #7
David (Sabljak)
Huge Clucker
 
Join Date: Nov 2011
Posts: 342
Reputation: 18
Default Re: How is it possible ?

Quote:
Originally Posted by Shaheen View Post
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
David (Sabljak) is offline   Reply With Quote
Old 19/04/2020, 10:50 AM   #8
l0gic
Big Clucker
 
Join Date: Aug 2019
Posts: 155
Reputation: 20
Default Re: How is it possible ?

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.
__________________
Coding experience with: PAWN, Java, Python, Javascript, PHP and SQL for about 6 years.
If I helped you, any reputation would be appreciated.
l0gic is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 08:46 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.