04.07.2012, 06:57
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.
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.