SA-MP Forums Archive
Filterscript read stock in main gm? - 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: Filterscript read stock in main gm? (/showthread.php?tid=359890)



Filterscript read stock in main gm? - oblexive - 15.07.2012

Hey guys pretty self explanitory in the title.
How can i get a filterscript to read a stock in the main gamemode?

Iv downloaded a vehicle filterscript, but I need it to read the way money is handled otherwise cars are free..
Thanks heaps.


Re: Filterscript read stock in main gm? - Matz - 15.07.2012

I guess you can't do it.


Re: Filterscript read stock in main gm? - GSRP - 15.07.2012

You can use "CallRemoteFunction". Although I have never really messed with this, I am not to handy with how to actually use it. :P

This forum requires that you wait 120 seconds between posts. Please try again in 4 seconds. <-- Every time..


Re: Filterscript read stock in main gm? - oblexive - 15.07.2012

i found this but im not understanding it a great deal..
https://sampforum.blast.hk/showthread.php?tid=261584

Can anyone help? Ill add that im using zgaming roleplay GM script and What is setup in the main GM for cash is:
enum pInfo
{
pMoney,//Money

the stock for giving or taking money is:
stock GiveZaiatMoney(playerid, amount)
{
new string[128];
if(amount < 0) format(string, sizeof(string), "~r~-$%d", amount*-1);
else if(amount > 0) format(string, sizeof(string), "~g~+$%d", amount);
GameTextForPlayer(playerid, string, 3000, 1);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
PlayerInfo[playerid][pMoney] += amount;
return 1;
}

How can I make it so the money handling can be accessed through the vehicle filterscript. Thanks guys.


Re: Filterscript read stock in main gm? - oblexive - 15.07.2012

Okay what I did was created:
Код:
forward playermoney(playerid, amount);
public playermoney(playerid, amount)
{
    GiveZaiatMoney(playerid, amount);
	return 1;
}
Then in the filterscript created
CallRemoteFunction("playermoney", "ii", playerid, money);

which takes me to the script above which takes me to the stock givezaiatmoney But iv run into a problem.
How do I turn these two into the above callremotefunction? Its for when selling your car to another player..? and how would I edit the above script? Thanks!

GivePlayerMoney(playerid, -price);
GivePlayerMoney(targetid, price);

GivePlayerMoney(i, -cost); .. ?


Re: Filterscript read stock in main gm? - Calgon - 15.07.2012

stocks can only be called from the script they're in (unless they're included via an include).

Change the keyword of your stock function to public and forward it and you'll be able to call it from filterscripts and other remote scripts, using CallRemoteFunction.


Re: Filterscript read stock in main gm? - oblexive - 15.07.2012

Thanks for the tip, iv got that all working What I need to understand is this:
GivePlayerMoney(i, -cost);

Whats this mean and how can I make it work with CallRemoteFunction("playermoney", "ii", playerid, money);
its park of the fueling part of the vehicle script.