[Include] GVar (Plugin-Free!)
#1

Introduction:

I've seen Incognito's GVar Plugin a while ago, and I had the idea implementing GVars by using properties (core.inc).

GVars are like PVars, but global.
They are global variables which can be created/deleted/altered dynamically.

I also added some functions to store/load hexadecimal, boolean and binary values.

Note: I couldn't find a good way to implement three functions which are:
GetGVarNameAtIndex,
GetGVarType,
GetGVarsUpperIndex.

Once I find a good way of implementing them, I'll release it for sure.

Version:

• GVar v1.0 - Initial Release.

Known Bugs:

- None, if you do find a bug please make sure you report it to me so I can fix it!

Functions:
pawn Code:
SetGVarString(varname[], value[], id = 0);
SetGVarInt(varname[], value, id = 0);
SetGVarFloat(varname[], Float:value, accuracy = 6, id = 0);
SetGVarBool(varname[], bool:value, id = 0);
SetGVarHex(varname[], value, id = 0);
SetGVarBin(varname[], value, id = 0);
GetGVarString(varname[], id = 0);
GetGVarStringEx(varname[], dest[], size = sizeof dest, bool:pack = false, id = 0);
GetGVarInt(varname[], id = 0);
Float:GetGVarFloat(varname[], id = 0);
bool:GetGVarBool(varname[], id = 0);
GetGVarBin(varname[], id = 0);
GetGVarHex(varname[], id = 0);
DeleteGVar(varname[], id = 0);
Installing:

Like any other include, put it in your includes folder and add it to your script:
pawn Code:
#include <gvar>
Should look like this:
pawn Code:
#include <a_samp>
#include <gvar>
Speed:

Worried about speed?
I have done some benchmarks using Slice's code: https://sampforum.blast.hk/showthread.php?tid=218491
Here are the results for each function:
Code:
Bench for SetGVarInt: executes, by average, 801.36 times/ms.
Bench for SetGVarFloat:: executes, by average, 717.23 times/ms.
Bench for SetGVarString: executes, by average, 906.33 times/ms.
Bench for SetGVarBool: executes, by average, 913.14 times/ms.
Bench for SetGVarHex: executes, by average, 785.13 times/ms.
Bench for SetGVarBin: executes, by average, 741.88 times/ms.
Bench for GetGVarInt: executes, by average, 749.38 times/ms.
Bench for GetGVarFloat:: executes, by average, 487.21 times/ms.
Bench for GetGVarString: executes, by average, 806.46 times/ms.
Bench for GetGVarBool: executes, by average, 708.75 times/ms.
Bench for GetGVarHex: executes, by average, 517.23 times/ms.
Bench for GetGVarBin: executes, by average, 534.33 times/ms.
Bench for DeleteGVar: executes, by average, 1139.07 times/ms.
Downloads:

- GVar v1.0 - http://www.solidfiles.com/d/4ae6e76669/

(Please do not make any mirrors or upload to pastebin, thanks)


So that's about it, using it is very simple, just like PVars.
If you have any suggestions about improving the code, let me know!
Reply
#2

Looks nice, however, like ****** said, maybe do some tests with the GVar plugin?
Reply
#3

Yes, I compared with the Incognito's GVar plugin, and here are the results:

Code:
Bench for SetGVarInt: executes, by average, 4131.94 times/ms.
Bench for SetGVarFloat:: executes, by average, 4068.75 times/ms.
Bench for SetGVarString: executes, by average, 2248.70 times/ms.
Bench for GetGVarInt: executes, by average, 4107.01 times/ms.
Bench for GetGVarFloat:: executes, by average, 3705.45 times/ms.
Bench for GetGVarString: executes, by average, 3157.29 times/ms.
Bench for DeleteGVar: executes, by average, 4481.86 times/ms.
The plugin is about 4 times faster than the include.
I am actually aware that his plugin is faster, he mentioned that his plugin is faster than properties.
He also posted some benchmarks: http://forum.sa-mp.com/showpost.php?...1&postcount=34

He also mentioned some good points regarding to his plugin and properties in that post.
Reply
#4

Quote:
Originally Posted by Maxips2
View Post
Yes, I compared with the Incognito's GVar plugin, and here are the results:

Code:
Bench for SetGVarInt: executes, by average, 4131.94 times/ms.
Bench for SetGVarFloat:: executes, by average, 4068.75 times/ms.
Bench for SetGVarString: executes, by average, 2248.70 times/ms.
Bench for GetGVarInt: executes, by average, 4107.01 times/ms.
Bench for GetGVarFloat:: executes, by average, 3705.45 times/ms.
Bench for GetGVarString: executes, by average, 3157.29 times/ms.
Bench for DeleteGVar: executes, by average, 4481.86 times/ms.
The plugin is about 4 times faster than the include.
I am actually aware that his plugin is faster, he mentioned that his plugin is faster than properties.
He also posted some benchmarks: http://forum.sa-mp.com/showpost.php?...1&postcount=34

He also mentioned some good points regarding to his plugin and properties in that post.
But still, for an include its a very goob job.
Well done!
Reply
#5

Thanks much!
Reply
#6

Well done.
Maybe I'll start using this.
Reply
#7

Can you post a pastebin link?
Reply
#8

Quote:
Originally Posted by [xB]Lordz
View Post
Well done.
Maybe I'll start using this.
Thanks.

Quote:
Originally Posted by Arca
View Post
Can you post a pastebin link?
Nothing personal but no, I don't like uploading my releases to pastebin.
Reply
#9

Quote:
Originally Posted by Maxips2
View Post
Yes, I compared with the Incognito's GVar plugin, and here are the results:

Code:
Bench for SetGVarInt: executes, by average, 4131.94 times/ms.
Bench for SetGVarFloat:: executes, by average, 4068.75 times/ms.
Bench for SetGVarString: executes, by average, 2248.70 times/ms.
Bench for GetGVarInt: executes, by average, 4107.01 times/ms.
Bench for GetGVarFloat:: executes, by average, 3705.45 times/ms.
Bench for GetGVarString: executes, by average, 3157.29 times/ms.
Bench for DeleteGVar: executes, by average, 4481.86 times/ms.
The plugin is about 4 times faster than the include.
I am actually aware that his plugin is faster, he mentioned that his plugin is faster than properties.
He also posted some benchmarks: http://forum.sa-mp.com/showpost.php?...1&postcount=34

He also mentioned some good points regarding to his plugin and properties in that post.
Hmm.I think that, you should test plugin in your computer.
Reply
#10

Very nice
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)