SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 03/06/2011, 03:59 PM   #1
clavador
Huge Clucker
 
clavador's Avatar
 
Join Date: Jun 2007
Location: Argentina
Posts: 245
Reputation: 71
Question [QUESTION] includes Vs filterscripts

Hello.

Maybe this is a stupid question, I don't know.

Is there a difference between using an include and a filterscript for passing data, for example?

In this case I need an array to be available among all my scripts...

Do the includes store data the same way a FS does??
clavador is offline  
Old 03/06/2011, 04:32 PM   #2
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 15,100
Reputation: 3166
Default Re: [QUESTION] includes Vs filterscripts

They're not the same thing in any way, or even comparable.

An include is a set of source code which can be included in any script at compile time.

A filterscript is a pre-compiled script, which may have used includes in the first place to be written.

Filterscripts store data in their own private data area. Includes don't store data because they're just code, they aren't run until they are compiled, at which point any variables they declare are again stored in that script's (gm or fs) private memory.

To answer your higher-level question, there are a number of ways to share data between scripts. First is properties, which are global, but reset on gmx. Second is PVars which are again global, but are per-player (may or may not be what you want). Third is persistent storage, which includes files and databases, though neither of those are particularly well designed for this. There are also custom plugins such as the GVar plugin, but they don't do anything that properties don't.

As for calling between scripts, there is "CallRemoteFunction" and wrappers around that (y_master).

For completeness you can communicate with bot scripts using these techniques as well as "SendText" and "SendClientMessage" for two-way communication over the SA:MP text system.
Y_Less is online now  
Old 03/06/2011, 04:50 PM   #3
clavador
Huge Clucker
 
clavador's Avatar
 
Join Date: Jun 2007
Location: Argentina
Posts: 245
Reputation: 71
Default Respuesta: Re: [QUESTION] includes Vs filterscripts

Quote:
Originally Posted by Y_Less View Post
They're not the same thing in any way, or even comparable.

An include is a set of source code which can be included in any script at compile time.

A filterscript is a pre-compiled script, which may have used includes in the first place to be written.

Filterscripts store data in their own private data area. Includes don't store data because they're just code, they aren't run until they are compiled, at which point any variables they declare are again stored in that script's (gm or fs) private memory.

To answer your higher-level question, there are a number of ways to share data between scripts. First is properties, which are global, but reset on gmx. Second is PVars which are again global, but are per-player (may or may not be what you want). Third is persistent storage, which includes files and databases, though neither of those are particularly well designed for this. There are also custom plugins such as the GVar plugin, but they don't do anything that properties don't.

As for calling between scripts, there is "CallRemoteFunction" and wrappers around that (y_master).

For completeness you can communicate with bot scripts using these techniques as well as "SendText" and "SendClientMessage" for two-way communication over the SA:MP text system.
Thanx for your quick and precise response.

That's why my variable wasn't working well between scripts.

I try not to read all the time from a file because I believe it's slower than other methods.

I wasn't using Pvar's because i needed an enum to keep things in order, but I guess I have to do something with that. Maybe setting the array's variable to the same number as the Pvar in order to syncronize values.
clavador is offline  
Old 03/06/2011, 06:21 PM   #4
Ash.
High-roller
 
Ash.'s Avatar
 
Join Date: Jan 2010
Location: England
Posts: 2,094
Reputation: 163
Default Re: Respuesta: Re: [QUESTION] includes Vs filterscripts

Quote:
Originally Posted by clavador View Post
Thanx for your quick and precise response.

That's why my variable wasn't working well between scripts.

I try not to read all the time from a file because I believe it's slower than other methods.

I wasn't using Pvar's because i needed an enum to keep things in order, but I guess I have to do something with that. Maybe setting the array's variable to the same number as the Pvar in order to syncronize values.
I don't know if this would help in anyway, but if you are to be passing data accross scripts with PVar's - create a function to return the data you need. Or create a macro to do such task.

For example, if you were to store the players money in a PVar, and called the variable "money" - you could create a macro to return the data, rather than writing out GetPVarInt(...);
Like so:

pawn Code:
#define GetPMoney(%0) GetPVarInt(%0, "money")

Obviously GetPMoney could be changed to the name you wished to use. (You could use it as a replacement as GetPlayerMoney to combat agaist money hacking i guess)
__________________
TruckingWorld
Work, Play, Make Friends
Written from scratch, and originally released in 2011, play today!
Visit the forum | Play the game
Ash. is offline  
 

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
Filterscripts & Includes List |- Made For Vbulletin! -| Toni Filterscripts 37 25/10/2012 03:11 PM
Filterscripts sherlock Server Support 5 06/03/2011 12:47 PM
Question About Filterscripts. Apply Help Archive 2 16/05/2010 11:01 PM
Filterscripts in a 24/7 Rickyboy30 Server Support 8 05/10/2009 07:11 PM


All times are GMT. The time now is 12:25 PM.


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