[QUESTION] includes Vs filterscripts
#1

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??
Reply
#2

Quote:
Originally Posted by ******
Посмотреть сообщение
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.
Reply
#3

Quote:
Originally Posted by clavador
Посмотреть сообщение
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 Код:
#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)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)