Raised This Month: $ Target: $400
 0% 

New to AMX plugins, quick question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SDJASON
New Member
Join Date: Aug 2005
Old 08-30-2005 , 14:35   New to AMX plugins, quick question
Reply With Quote #1

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
SDJASON is offline
Send a message via AIM to SDJASON
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 08-30-2005 , 14:40  
Reply With Quote #2

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.
Brad is offline
SDJASON
New Member
Join Date: Aug 2005
Old 08-30-2005 , 14:42  
Reply With Quote #3

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
SDJASON is offline
Send a message via AIM to SDJASON
Zenith77
Veteran Member
Join Date: Aug 2005
Old 08-30-2005 , 16:43  
Reply With Quote #4

lol...he doesnt know what he is getting himself into......
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 08-30-2005 , 16:55  
Reply With Quote #5

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:
public plugin_init() {    register_cvar("cvarname","defaultvalue"); } public set() {    set_cvar_num("cvarname",1); } public get() {    if(get_cvar_num("cvarnam") == 1) {    }    else {    } }

There are different commands for getting and setting different types of cvars (floats and strings).
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
BAILOPAN
Join Date: Jan 2004
Old 08-30-2005 , 17:03  
Reply With Quote #6

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.
__________________
egg
BAILOPAN is offline
SDJASON
New Member
Join Date: Aug 2005
Old 08-31-2005 , 13:30  
Reply With Quote #7

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
SDJASON is offline
Send a message via AIM to SDJASON
Johnny got his gun
Veteran Member
Join Date: Jan 2004
Location: Tokyo
Old 08-31-2005 , 13:40  
Reply With Quote #8

One pitfall is plugins are written in Pawn, not C++.
Johnny got his gun is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 08-31-2005 , 15:18  
Reply With Quote #9

Quote:
Originally Posted by Johnny got his gun
One pitfall is plugins are written in Pawn, not C++.
You win at life.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Riddick51
BANNED
Join Date: Jul 2005
Location: Lincoln, Nebr US
Old 09-03-2005 , 05:04  
Reply With Quote #10

Code:
plugin_cvar 1

//use server.cfg each mapchange
mapchangecfgfile server.cfg
with that bit, your cvar plugin_cvar is set = 1 on each map change.

if you have amxmodx/configs/maps/de_aztec.cfg with the following contents:
Code:
plugin_cvar 0
de_aztec.cfg is "read-in" when the map changes to de_aztec and the plugin_cvar is set = 0

it 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.
Riddick51 is offline
Send a message via AIM to Riddick51 Send a message via MSN to Riddick51 Send a message via Yahoo to Riddick51
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:29.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode