Variables across scripts
#1

Hey yall.. I was wondering what the best way to access/change variables that are in different scripts is.

My current method is by using remote function calls, but im sure there is a much better method that makes me feel retarded. Please halp me out.
Reply
#2

You can use PVars for player variables, or you can use get/set property.

https://sampwiki.blast.hk/wiki/Setproperty
https://sampwiki.blast.hk/wiki/Getproperty
https://sampwiki.blast.hk/wiki/Per-player_variable_system
Reply
#3

hmmmm... that get/set property looks pretty messy... lol. However the PVar system look pretty appealing.. is this what alot of the good scripts use?
Reply
#4

Get/Setproperty are a lot older. They have been there since 0.1 and they may be a bit harder to use.
PVars are limited in a way that you can only use them for players, an example would be like having an array called PlayerVehicle[MAX_PLAYERS];
Reply
#5

Also, you can use Incognito's GVars (global variables) plugin.

https://sampforum.blast.hk/showthread.php?tid=151076
Reply
#6

Most of the stuff I need across the scripts are just player variables.. like money, level, etc..
i can just use CallRemoteFunction when I need a global variable

Thank you guys.


Oh wow.. that Gvar looks nice... ill use that alongside Pvar... thanks for solving all my probs for now DD
Reply
#7

If you've ever programmed in C# or Java, you can also use that GVar plugin like a makeshift ArrayList.
Reply
#8

Also, is it normal to have many filterscripts for your server? I like to have a separate one for handling different things... like one that manages the Moneysystem, the database, chatting, claymores (fun little scripted claymore for unsuspecting people ).. Im just wondering if too many filterscripts is a problem. Adding all of these FS names to the server.cfg kinda worries me.

- Thanx Guise - littleG

[I have changed all of my CallRemoteFunctions into just Set/Get PVars and seems to be working greatly.. thanks you all!]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)