[Tutorial] How to Hook Filterscript Money System with Server-Sided Money System
#1

Yeah, sometime it will be suck if we can't use a filterscript we have a Server-Sided Money Gamemode. And i want to share my way to fix this. I will use SetPVarInt here.

First, We just open our Gamemode, and we have to find the timer to check the money, like this
pawn Code:
public OnGameModeInit()
{
    SetTimer("MoneyCheck", 1000, 1);
    return 1;
}
Next, We go to the public 'MoneyCheck'
pawn Code:
forward MoneyCheck();
public MoneyCheck();
{
    foreach(Player, i)
    {
        ResetPlayerMoney(i);
        GivePlayerMoney(i, GetPlayerCash(i));
    }
}
Next, Let the GM Opened, and open the Filterscript. Find the GivePlayerMoney. We will use the PVar here, every GivePlayerMoney should be replaced with SetPVarInt. Example, change this:
pawn Code:
GivePlayerMoney(playerid, -House[i][Price]);
To this:
pawn Code:
SetPVarInt(playerid, "HouseMoney", -House[i][Price]);
The name of variable can be changed, the integer of the PVarInt should same with the value in GivePlayerMoney.

Now, we just have to add GivePlayerSafeMoney (or anything like this) on your GM, We take the value through the PVar. Dont forget to add this on the timer public, like this
pawn Code:
forward MoneyCheck();
public MoneyCheck();
{
    foreach(Player, i)
    {
        ResetPlayerMoney(i);
        GivePlayerMoney(i, GetPlayerCash(i));
        GivePlayerSafeCash(i, GetPVarInt(playerid, "HouseMoney"));
    }
}
And Last, dont forget to reset the PVarInt, so the money won't be added again and again. Just use SetPVarInt(playerid, "HouseMoney", 0)
pawn Code:
forward MoneyCheck();
public MoneyCheck();
{
    foreach(Player, i)
    {
        ResetPlayerMoney(i);
        GivePlayerMoney(i, GetPlayerCash(i));
        GivePlayerSafeCash(i, GetPVarInt(playerid, "HouseMoney"));
        SetPVarInt(playerid, "HouseMoney", 0);
    }
}
And that's it, I have test this and it worked. Sorry for my bad english, for question or suggestion please reply here.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)