AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Instagib plugin showing lots of errors (https://forums.alliedmods.net/showthread.php?t=19509)

DarlD 10-18-2005 12:54

Instagib plugin showing lots of errors
 
Ok so here is what i've got right now
Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <fun> #define PLUGIN "Meta-Addons" #define VERSION "0.1" #define AUTHOR "Meta" // Setting all the cvars and others here. public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("ResetHUD","event_resethud","b")     register_cvar("ma_details", "1")     register_cvar("ma_instagib", "0")     register_cvar("ma_weed", "1"); } /* Starting the plugins functions */ public event_resethud(id) {     if(is_user_connected(id)) {         set_task(0.1,"ma_instagib",id)     } } // ma_details is set here public ma_details(id) {             } // ma_instagib is set here public ma_instagib(id) {     if ( ma_instagib == 1 )     show_hudmessage(id,"Meta-Addons: Instagib Mode has been activated!")     if(is_user_alive(id))          set_user_health(id,20)     cs_set_user_money(id,1,0)          strip_user_weapons(id)          give_item(id,"weapon_scout")          cs_set_weapon_ammo(id,60); }

why is it not compiling i keep getting shitloads of errors!

XxAvalanchexX 10-18-2005 14:50

1.
Code:
if ( ma_instagib == 1 )
I'm assuming you want to check the cvar's value, in which case you have to use get_cvar_num. So it would look like this instead:
Code:
if ( get_cvar_num("ma_instagib") == 1 )
.

2. You use some cs_* commands without including cstrike, so just add
Code:
#include <cstrike>
to your includes list.

3. It looks like maybe some of your if statements should have more than one condition, which means you have to use curly braces to define what happens inside of them. As of now it will only execute the first line after the if statement if the conidition is true, which looks like it will cause a lot of weird things if the statements aren't true.

DarlD 10-18-2005 15:42

Ok it compiles now, but weidly, when i type amx_help 1, 11, 21, 31, 41, 51, 61, i dont see my cvars (ex.: ma_instagib)

Code:
public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("ResetHUD","event_resethud","b")     register_cvar("ma_details", "1")     register_cvar("ma_instagib", "0")     register_cvar("ma_weed", "1");^

did i forget anything?

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #define PLUGIN "Meta-Addons" #define VERSION "0.1" #define AUTHOR "Meta" // Setting all the cvars and others here. public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("ResetHUD","event_resethud","b")     register_cvar("ma_details", "1")     register_cvar("ma_instagib", "0")     register_cvar("ma_weed", "1"); } /* Starting the plugins functions */ public event_resethud(id) {     if(is_user_connected(id)) {         set_task(0.1,"ma_instagib",id)     } } // ma_details is set here public ma_details(id) {             } // ma_instagib is set here public ma_instagib(id) {     if ( get_cvar_num("ma_instagib") == 1 )     show_hudmessage(id,"Meta-Addons: Instagib Mode has been activated!")     if(is_user_alive(id))         set_user_health(id,20)     cs_set_user_money(id,1,0)         strip_user_weapons(id)         give_item(id,"weapon_scout")         cs_set_weapon_ammo(id,60); }

MistaGee 10-18-2005 16:13

checked "amxx cvars"? it's a lot easier than using the help thingy and shows your cvars for sure if they are correctly registered...

BTW: there should be an empty statement error when you compile cuz you didn't do anything in this ma_details function. Maybe (maybe...) this screwz up the compiler so that your plugin isn't correctly compiled (I've had this once). Do something there to prevent this...

Greetz MGee

XxAvalanchexX 10-18-2005 17:19

Quote:

Originally Posted by DarlD
Ok it compiles now, but weidly, when i type amx_help 1, 11, 21, 31, 41, 51, 61, i dont see my cvars (ex.: ma_instagib)

cvars are data stored by the server, not commands. amx_help only shows commands registered by amxx.

DarlD 10-18-2005 17:58

ok but what is wrong??

how come my cvars arent registered???

XxAvalanchexX 10-18-2005 18:04

They are, but they don't show up in amx_help because they are cvars, not commands.

DarlD 10-18-2005 18:06

ok so how to i creat commands?

register_concmd?

Code:
/* Plugin Created by DarlD on amxmodx forums, Real nick = Meta */ #include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #define PLUGIN "Meta-Addons" #define VERSION "0.1" #define AUTHOR "Meta" // Setting all the cvars and others here. public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("ResetHUD","event_resethud","b")     register_cvar("ma_details", "1")     register_cvar("ma_instagib", "0")     register_concmd("ma_instagib","instagib",ADMIN_KICK,"Instagib command")     register_cvar("ma_weed", "1"); } /* Starting the plugins functions */ public event_resethud(id) {     if(is_user_connected(id)) {         set_task(0.1,"ma_instagib",id)     } } // ma_details is set here public ma_details(id) {     return PLUGIN_CONTINUE } // ma_instagib is set here public ma_instagib(id) {     if ( get_cvar_num("ma_instagib") == 1 )     show_hudmessage(id,"Meta-Addons: Instagib Mode has been activated!")     if(is_user_alive(id))     set_user_health(id,1)     cs_set_user_money(id,1,0)     strip_user_weapons(id)     give_item(id,"weapon_scout")     cs_set_weapon_ammo(id,60);         return PLUGIN_CONTINUE }

it still aint working even with the register_concmd

Zenith77 10-18-2005 18:42

register_clcmd() only allow clients to run this command


register_concmd() allows the server and clients to run commands

DarlD 10-18-2005 19:08

yeah i know that, but the register_concmd in my plugin doesnt seam to work. any ideas


All times are GMT -4. The time now is 23:48.

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