| closedsniper and mg limits |
| Started by Dr.G on 11-29-2008, 03:47 PM |
Threads: 75
Joined: Nov 2007
This is the first plugin ive made on my own with outanything else then some other scripts to steal from :D And ofcource i have a problem lol it doesnt diable the plugin as it should. the dod_sniper_mg cvar doesnt work like it should but i cant see why?rnrn***CODE IS UPDATED 11/30 08***rnrn
//////////////////////////////////////////////////////////////////////////////////rn//rn// Information:rn// Makes it possible to control when sniper/mg classes are open compared to the amountrn// players in the server. Bots are ignoredrn//rn//////////////////////////////////////////////////////////////////////////////////rn//rn// Thanks to: diamond-optic I grapped some code from avamods hill sniper limitrn// http://www.avamods.com/download.php?view.11 + some more cant remember :)rn//rn//////////////////////////////////////////////////////////////////////////////////rn//rn// Changelog:rn// Join messages now ref. to (p_limits) and (p_limitmg) valuern// public plugin_precache changed to public plugin_cfg -> native error problemrn//rn//////////////////////////////////////////////////////////////////////////////////rn//rn#include <amxmodx>rn#include <amxmisc>rnrn#define PLUGIN "DoD Sniper/MG classes"rn#define VERSION "v1.0 - by Dr.G"rn#define AUTHOR "Dr.G"rnrn// Cvar pointerrnnew p_enablernnew p_enablesrnnew p_enablemgrnnew p_limitsrnnew p_limitmgrnnew p_joinmsgrnnew p_joinmsgmgrnnew p_timeacmsgslrnnew p_timeacmsgmgrnrnpublic plugin_init() rn{rn register_plugin(PLUGIN, VERSION, AUTHOR)rn //Public tracking cvarrn register_cvar("dod_sniper_mg_classes_stats", VERSION, FCVAR_SERVER|FCVAR_SPONLY)rn // Register cvarsrn p_enable = register_cvar("dod_sniper_mg","1") // Turns plugin on/off | 1=on 0=offrn p_limits = register_cvar("dod_sl_minplayers","10") // Sets the amount of people that have to be in server before sniper classes are openrn p_limitmg = register_cvar("dod_mgl_minplayers","8") // Sets the amount of people that have to be in server before sniper classes are openrn p_enables = register_cvar("dod_sl","1") // Turns sniper limits on/off | 1=on 0=offrn p_enablemg = register_cvar("dod_mgl","1") // Turns mg limits on/off | 1=on 0=offrn p_joinmsg = register_cvar("dod_sl_joinmsg","1") // turns sniper info message on/off | 1=on 0=offrn p_joinmsgmg = register_cvar("dod_mgl_joinmsg","1") // turns mg info message on/off | 1=on 0=offrn p_timeacmsgsl = register_cvar("dod_sl_joinmsgs_delay","30") //Amount of time in sec. before sniper limit info msg are shownrn p_timeacmsgmg = register_cvar("dod_sl_joinmsgmg_delay","25") //Amount of time in sec before MG info msg are shownrn}rnpublic plugin_cfg() //precache limits to 0 if dod_sniper_mg is 1rn{ rn if (get_pcvar_num (p_enable) && get_pcvar_num (p_enables)) server_cmd("mp_limitaxisscopedkar 0; mp_limitalliesspring 0; mp_limitbritsniper 0")rn if (get_pcvar_num (p_enable) && get_pcvar_num (p_enablemg)) server_cmd("mp_limitbritmg 0; mp_limitaxismg42 0; mp_limitaxismg34 0; mp_limitallies30cal 0")rn}rnpublic client_putinserver(id)rn{ rn if(!is_user_bot(id) && get_pcvar_num(p_enable) && get_pcvar_num(p_enables) && is_user_connected(id) && get_pcvar_num(p_joinmsg))rn check_count()rn set_task(get_pcvar_float(p_timeacmsgsl),"ShowMsg",id)rn if(!is_user_bot(id) && get_pcvar_num(p_enable) && get_pcvar_num(p_enablemg) && is_user_connected(id) && get_pcvar_num(p_joinmsgmg))rn check_count()rn set_task(get_pcvar_float(p_timeacmsgmg),"ShowMsgMG",id)rn}rnpublic client_disconnect(id)rn check_count()rnrnpublic ShowMsg(id)rn rnif(!is_user_bot(id) && is_user_connected(id) && get_pcvar_num(p_joinmsg)) rn client_print(id, print_chat, "*** Sniper classes wont be avalible until %d players have joined the game***",get_pcvar_num(p_limits))rnrnpublic ShowMsgMG(id)rn rnif(!is_user_bot(id) && is_user_connected(id) && get_pcvar_num(p_joinmsgmg)) rn client_print(id, print_chat, "*** Heavy weapon classes wont be avalible until %d players have joined the game***",get_pcvar_num(p_limitmg))rnrnpublic check_count()rn{rn new players_on = get_playersnum()rn rn if(players_on < get_pcvar_float(p_limits))rn server_cmd("mp_limitaxisscopedkar 0; mp_limitalliesspring 0; mp_limitbritsniper 0")rn else if(players_on > get_pcvar_float(p_limits))rn server_cmd("mp_limitaxisscopedkar 1; mp_limitalliesspring 1; mp_limitbritsniper 1")rn if(players_on < get_pcvar_float(p_limitmg))rn server_cmd("mp_limitbritmg 0; mp_limitaxismg42 0; mp_limitaxismg34 0; mp_limitallies30cal 0")rn else if(players_on > get_pcvar_float(p_limitmg))rn server_cmd("mp_limitbritmg 1; mp_limitaxismg42 1; mp_limitaxismg34 1; mp_limitallies30cal 1")rn}rnrnrnAnd another quistion.. how do it get the print the value of p_limitmg and p_limits. I tryed like this but without luckrnrnif(!is_user_bot(id) && is_user_connected(id) && get_pcvar_num(p_joinmsg)) rnclient_print(id, print_chat, "*** Sniper classes wont be avalible until %s players have joined the game***", p_limits)rnrnrnHelp and comments is very welcome! ;)rnrnThanks in advanceThreads: 103
Joined: May 2005
im a bit drunk at the moment which is rare for me so bare with me haha.. but for the 2nd part.. you have to get the pcvar value and not just call the variable.. and since youre just using an integer value you dont need to use %s for a stringnn
if(!is_user_bot(id) && is_user_connected(id) && get_pcvar_num(p_joinmsg))n client_print(id, print_chat, "*** Sniper classes wont be avalible until %d players have joined the game***",get_pcvar_num(p_limits))nni'll look into the other problem for u a bit later on when i sober up enough to feel like looking at lines and lines of code lolThreads: 75
Joined: Nov 2007
Thx alot! I updated the code. Iam pretty sure i had some misunderstanding with some !'s.. Ill test it again and get back if its still not working.. For now dont waste time on looking at it, unless u are really bored lol... Thanks again!rnrn**EDIT**rnIts not work 100%.. SURPRICE! lolrnrnI get an error as the code is nowrnrn
01:47:32 L 11/30/2008 - 00:47:41: Invalid CVAR pointerrn01:47:32 L 11/30/2008 - 00:47:41: [AMXX] Displaying debug trace (plugin "dod_sniper_mg_classes.amxx")rn01:47:32 L 11/30/2008 - 00:47:41: [AMXX] Run time error 10: native error (native "get_pcvar_num")rn01:47:32 L 11/30/2008 - 00:47:41: [AMXX] [0] dod_sniper_mg_classes.sma::plugin_precache (line 55)rnrnThanks in advance...Threads: 103
Joined: May 2005
ohh try removing the spaces in the native..nn
get_pcvar_num (p_enable)nnshould bennget_pcvar_num(p_enable)Threads: 75
Joined: Nov 2007
Narhh didnt help.. no clue with the space was there... might have gotten kinda snow blind i guess :-)
Threads: 103
Joined: May 2005
ohh you know what it is.. i think plugin_precache might be called before the cvars are registerednntry changing it to plugin_cfg()
Threads: 75
Joined: Nov 2007
Yea! that did the trick.. thanks again...

