Money bar and the variable - 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: Money bar and the variable (
/showthread.php?tid=591472)
Money bar and the variable -
Bondage - 12.10.2015
Hey there!
Here i got a doubt, the money bar value changes only when we use the function GivePlayerMoney. My question is whether it will change if we use a custom variable for that?
For example
pawn Код:
PlayerInfo[giveplayerid][Money] += 1000; //money bar value changes to 1000 $ instead of using GivePlayerMoney(playerid,1000);
Re: Money bar and the variable -
bgedition - 12.10.2015
You want anti-cheat?? If so, read this thread
https://sampforum.blast.hk/showthread.php?tid=220089
Re: Money bar and the variable -
Vince - 12.10.2015
I believe you can overload operators to do that, but I haven't used it myself and don't know exactly how that works. I guess you will need to create a new tag for the money (e.g. Money:) to separate it from regular integer addition operations. Check float.inc to see how it's done there.
Re: Money bar and the variable -
SecretBoss - 12.10.2015
Код:
forward GivePlayerMoneyEx(playerid, amount);
public GivePlayerMoneyEx(playerid, amount)
{
if(IsPlayerConnected(playerid))
{
PlayerInfo[playerid][Money] = PlayerInfo[playerid][Money] + amount;
}
return 1;
}
CMD:10cash(playerid, params[])
{
GivePlayerMoneyEx(playerid, 10);
SendClientMessage(playerid, -1, "You just received $10 from custom function");
return 1;
}
Just replace all GivePlayerMoney with GivePlayerMoneyEx function and you are done
Now you can put on GivePlayerMoneyEx the update bar function so it will update the bar when you use it
Re: Money bar and the variable -
AbyssMorgan - 12.10.2015
PHP код:
GetPlayerMoneyEx(playerid){
    return PlayerInfo[playerid][Money];
}
SetPlayerMoneyEx(playerid,money){
    PlayerInfo[playerid][Money] = money;
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid,money);
}
GivePlayerMoneyEx(playerid,money){
    PlayerInfo[playerid][Money] += money;
    GivePlayerMoney(playerid,money);
}Â