SA-MP Forums Archive
Explain me please - 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: Explain me please (/showthread.php?tid=299430)



Explain me please - Dripac - 25.11.2011

I need a good server-side-money script and explain how to use it, will give+rep


Re: Explain me please - Rob_Maate - 25.11.2011

What sort of gamemode?
What is your current player information variable? (where you store data to be saved to a db/file)


AW: Explain me please - Dripac - 25.11.2011

i use this

https://sampforum.blast.hk/showthread.php?tid=273088

And i plan to create a rp/dm gamemode based in los santos


Re: AW: Explain me please - Jakku - 25.11.2011

EDIT: Oh yeah, never mind. Didn't read the topic carefully enough, sorry


Re: Explain me please - Rob_Maate - 25.11.2011

Ahhh E'z

There's a very simple legacy way of controlling cash:
That is
GivePlayerMoney(playerid, amount);
For negative amounts:
GivePlayerMoney(playerid, -amount);

However with this system, people are gonna hack the shit out of your server.
What you want to do is use that [pCash] variable you are currently employing.

That is achieved by making a stock:

pawn Код:
stock GivePlayerMoneyEx(playerid, value)
{
  PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash] + value;
  ResetPlayerMoney(playerid);
  GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
}
This basically means that your cash is actually based on [pCash] instead of the legacy moneybar, and the moneybar @ the HUD is just a display for your [pCash] variable.

So wherever you would use GivePlayerMoney() in your script, write it as GivePlayerMoneyEx().

Also, undertaking this system of money-control allows you to easily check for hacks.

under OnPlayerUpdate, run this block of code:

pawn Код:
if(GetPlayerMoney(playerid) > PlayerInfo[playerid][pCash])
        {
            new HackedAmount;
            HackedAmount = GetPlayerMoney(playerid) - PlayerInfo[playerid][pCash];
            OnPlayerHaveHackedMoney(playerid, HackedAmount);
        }
This will check if the value displayed on the moneybar is actually larger than the amount of cash the player has received via server functions. If it is? It will run OnPlayerHaveHackedMoney.

OnPlayerHaveHackedMoney is not a native function, so you will need to forward it:

pawn Код:
forward OnPlayerHaveHackedMoney(playerid, HackedAmount);
And then give it functionality.

pawn Код:
public OnPlayerHaveHackedMoney(playerid, value)
{
    new hacker[64];
    new string[128];
    GetPlayerName(playerid, hacker);
    if(value > 49) //what bonehead would try and hack less lmao
    {
        format(string, 256, "<A> HackWarning: [%d]%s attempted to spawn $%d.",playerid, hacker, value);
//you now have 'string' which contains ^^. Insert here your admin broadcast code
//here you also insert your disciplinary code, whether it be warn, Ban(playerid), Kick(playerid) or w/e
    }
}
If you don't feel the need to ban a player for attempting to moneyhack, you can run the following code in OnPlayerHaveHackedMoney:

pawn Код:
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
That will simply just reset their moneybar constantly to their [pCash] value and hopefully their frustration will encourage them to give up : D


Re: Explain me please - Dripac - 25.11.2011

Thank you so much! +rep from me


Re: Explain me please - Steven82 - 25.11.2011

An RP/DM script as one? You've got to be kidding me..


Re: Explain me please - Dripac - 25.11.2011

Quote:
Originally Posted by Steven82
Посмотреть сообщение
An RP/DM script as one? You've got to be kidding me..
CnR style... i just dont wannt to call it cnr


Re: Explain me please - Kingunit - 25.11.2011

Quote:
Originally Posted by Steven82
Посмотреть сообщение
An RP/DM script as one? You've got to be kidding me..
What is your problem? Your comment isn't even related this subject.

Dripac; The questions has been answered?


Re: Explain me please - Steven82 - 26.11.2011

Quote:
Originally Posted by Kingunit
Посмотреть сообщение
What is your problem? Your comment isn't even related this subject.

Dripac; The questions has been answered?
My problem?

My problem: x + 12x - 17 ( 4 * 8 ) + 88 ( 8 * 9 )