SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 19/08/2012, 08:05 AM   #1
IceMeteor
Big Clucker
 
Join Date: Nov 2011
Location: Indonesia
Posts: 141
Reputation: 20
Default How to Hook Filterscript Money System with Server-Sided Money System

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] money.inc - Advanced, plug-n-play, server-sided money system fiki574 Includes 7 25/02/2012 10:47 PM
[Help] Server Sided Money Pawn [Please] andrew2695 Scripting Help 1 27/11/2011 11:27 PM
[Include] Server-sided Money - Stop money hackers! NEW RELEASE(v6) x-cutter Includes 107 30/08/2011 07:56 PM
[Include] T-Money: Server sided money Toni Includes 3 04/09/2010 06:09 AM
Server Sided Money Toni Help Archive 9 12/08/2010 01:06 PM


All times are GMT. The time now is 03:03 PM.


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