core.inc properties
#1

Lately I had an interesting conversation at SA-MP mIRC. We've talked about the four old functions that defined in PAWN as default in core.inc; the property() functions (getproperty, setproperty, existproperty, deleteproperty).

I'm opening this thread so we can all share information about these functions because currently they're unknown to most of scripters in SA-MP but looks like they can be really useful just as most of the rest of functions in core.inc. Not a lot is known about these functions.

Anyway, I know that these functions used to create server-side variables that saved in the entire server. By using these functions instead of normal variables we can define a formatted variable name. It means we can decide the name of a variable just by a string. Also, by SA-MP wiki there are new documention added to these functions and from them it looks like there are two ways to create such a variable. The first is to define integer property and the other is to define a string, and both uses different codes in the setproperty() parameters. I've also found that when loading or unloading a filterscript, or changing gamemode, all of the defined variables gets reseted.

I've found a lot of uses for these functions. For example, I got a dynamic logs (server history) system, which is controlled by a function that requires the name of the log (Connections, Stats, Commands, etc). I wanted to write to the log file a message when the log first edited (so in case of server crashing, the message will seperate the log file from the text before the crash and the text after the crash). To do that, i've used properties to set a property that his name is the name of the log and the value is doesn't matter here. When writing to log I just check if the property exist, if so i'll write to the log, if not i'll add the line i've mentioned before and then the text to write.

There are a lot of other ways to use these functions, and after so much time that passed from creating SA-MP, I think it's time that people will know this option.
Reply
#2

I was very interested in these functions as-well. I have a pretty large gamemode to modify so if I'd go through all that work I would prefer PVar (& GVar when necessary). Do you know if the property functions have any speed differences between PVar & normal variables? Thanks for the information though, I'm glad to see there's still some curious minded people like me, on this forum
Reply
#3

I, in fact, edited that article with the example of saving integers using the information provided on page 130 of the manual. These functions basically serve the same purpose as the GVar plugin in that they can be shared throughout all scripts. Float values cannot be saved, though (I think).
Reply
#4

Quote:
Originally Posted by Vince
View Post
I, in fact, edited that article with the example of saving integers using the information provided on page 130 of the manual. These functions basically serve the same purpose as the GVar plugin in that they can be shared throughout all scripts. Float values cannot be saved, though (I think).
Sure they can, just by saving a string and using floatstr().
Reply
#5

Quote:
Originally Posted by Amit_B
View Post
Sure they can, just by saving a string and using floatstr().
Or saved as int and Float: them.

---

Well, properties are a pretty old group of functions and I believe GVars were created to replace those functions because of the speed.
Reply
#6

Someone should actually test the speed of both. I think Pawn natives are still faster than plugin natives.
Reply
#7

I guess that the creators of GVar (both plugin and include) just didn't knew these functions...
Reply
#8

Where have you find all of these replies?
It's so good to know that there are more scripters using it.

It will not be that bad if you'll try a little to understand people and be more nice to them.
Reply
#9

I don't use properties very often, but I do use them sometimes. So I guess Y_less isn't the only one who uses them.
Reply
#10

Quote:
Originally Posted by Vince
View Post
Someone should actually test the speed of both. I think Pawn natives are still faster than plugin natives.
The GVar plugin thread has plenty of test results posted, along with one comparing properties to GVars by Incognito. This should say enough.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)