Money bar and the variable
#1

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);
Reply
#2

You want anti-cheat?? If so, read this thread https://sampforum.blast.hk/showthread.php?tid=220089
Reply
#3

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.
Reply
#4

Код:
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
Reply
#5

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);

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)