New to AMX plugins, quick question
Hello, i just started reading about AMX plugins and how they work, and after reading several guides (im aiming to write a program eventually) I have come up with a question i was wondering if anyone could answer
It seems to me, that every mapchange, amx plugin's are "reset" or "re loaded" or something similar, is there any way to circumvent this? Im not looking to transfer pages of information and keep a running tab, simply looking if there was a way to set a variable during one game that could be checked the next game, regardless of whether a map change occured or not, and an action could be performed based on the True/False 1/0 nature of this variable... Thank you in advance ~Jason |
I don't think there is any straightforward way to do as you ask. However, you could easily write whatever values you want to track across maps to a file when the map ends and then read it in when the next map starts.
|
Thank you for the quick reply.. taht is what i was thinking id have to do, now i know for sure....
But since its just a simple Yes/No thingie... writing it to a tiny ass file shouldnt be too hard.... :) ~Jason |
lol...he doesnt know what he is getting himself into......
|
There is a straightforward and simple way which is registering and storing a cvar value, which is good for small amounts of small data, but not good for tracking large amounts of data. If you just want to remember if the user had this plugin on or off, for example, would be a fair use of it. If you wanted to remember every single person's name then storing the information in a file or MySQL is the best choice.
Code:
There are different commands for getting and setting different types of cvars (floats and strings). |
Plugins are reloaded on mapchange. I don't know why this is but since every plugin ever written implicitly "relies" on its state being refreshed, I will not change it for the lifetime of AMX Mod X. I believe there is no reason for plugins to be refreshed like this by default however.
You can use vault to store persistent things. |
Thank you again for all the replies, i have several methods of doing it now if i read correctly... ill get to work on it soon, im still teaching myself C++ so i dont even know if ill ever finish it...
Basically im taking a votekick script, and rewriting it as a amx_voterandom script The end result of this script will be to write to this file a value (say 1) or to a CVAR 1 so it is stored during map switches Then at the start of every map The randomall script will detect this variable, run normally, then reset the variable, file, or CVAR to 0 so that it has to be re-voted to happen again .... As i said, this seems pretty straightforward to me, i have the votekick source, the randomall source, piecing this together shouldnt be too hard (stick the randomall source in an if loop and check for this variable) if not, terminate it somehow, or go into an infinite empty loop if true, run the randomall and reset the variable or cvar or file to 0) and modifying the votekick by removing kicking, editing some say_text's, and adding the editing of the file or Cvar..... This SEEMS pretty straightforward to me.... anyone see any pitfalls i might run into?? like i said, I know Java pretty well, but learning C++... everything is very familiar, but im not familar enuff with C++ to know if something like that is possible.... it seems like an easy thing to do to me tho.... and im gonna try to get it working eventually :) maybe learn some more C++ in the process ~jason |
One pitfall is plugins are written in Pawn, not C++.
|
Quote:
|
Code:
plugin_cvar 1if you have amxmodx/configs/maps/de_aztec.cfg with the following contents: Code:
plugin_cvar 0it executes like this: changelevel de_aztec server.cfg (is loaded, plugin_cvar=1) de_aztec.cfg (is loaded, plugin_cvar=0) and the process repeats for the next map change. |
| All times are GMT -4. The time now is 14:29. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.