AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Remove ammo problem (https://forums.alliedmods.net/showthread.php?t=26811)

xcalibar 04-09-2006 15:19

Remove ammo problem
 
hi,
i'm kind of new to all of this and id really like to learn from the experts,

heres my problem, i'm trying to write a simple plugin that will remove the ammo of a user but for some reason it doesn't remove the ammo and gives a run time error,

i know you can just drop the weapon but i dont want them to drop the weapon just have no ammo

heres my code (appologies if the code is badly done :? ),


Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <cstrike> #define PLUGIN "Test rip ammo" #define VERSION "1.0" #define AUTHOR "TEST" #define free 10 public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     set_task(float(free),"steal_ammo",_,_,_,"b") } public steal_ammo(id){ if(id == 0) return cs_set_weapon_ammo(id,0) new clip, ammo, wid = get_user_weapon(id, clip,ammo) cs_set_user_bpammo(id,cs_get_weapon_id (wid),0) set_hudmessage(255, 255, 255, 0.11, 0.31, 0, 6.0, 12.0) show_hudmessage(id, "Oh no! The grim reaper has killed all your ammo ;P") }

amx returns the error


Code:
[AMXX] Run time error 10 (plugin "test.amxx") - debug not enabled!
if i add the word debug after the plugin in the plugins.ini file i recieve the same message debug not enabled?


can anyone tell me what i'm doing wrong


thanks in advance

Xcalibar

slurpycof 04-09-2006 20:33

check your amxx.cfg to see if your debug settings are set right. I have very little experience with weapons and ammo, so I am not going to waste your time guessing what is right.

// Plugin Debug mode
// 0 - No debugging (garbage line numbers)
// 1 - Plugins with "debug" option in plugins.ini are put into debug mode
// 2 - All plugins are put in debug mode
// Note - debug mode will affect JIT performance
amx_debug 1

ev0d00b 04-09-2006 23:04

Re: Remove ammo problem
 
i'm newb at this as well but i think you got the return part wrong and you need to check if user is alive try this

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <cstrike> #define PLUGIN "Test rip ammo" #define VERSION "1.0" #define AUTHOR "TEST" #define free 10 public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     set_task(float(free),"steal_ammo",_,_,_,"b") } public steal_ammo(id){ if (!is_user_alive(id)) return PLUGIN_HANDLED else{ cs_set_weapon_ammo(id,0) new clip, ammo, wid = get_user_weapon(id, clip,ammo) cs_set_user_bpammo(id,cs_get_weapon_id (wid),0) set_hudmessage(255, 255, 255, 0.11, 0.31, 0, 6.0, 12.0) show_hudmessage(id, "Oh no! The grim reaper has killed all your ammo ;P") } return PLUGIN_HANDLED }

amx returns the error


Code:
[AMXX] Run time error 10 (plugin "test.amxx") - debug not enabled!

and i apoligise if im completley wrong as like i said im newb too. but i hope that works or helps.

also may want to look up the user alive funtion.

FatalisDK 04-10-2006 02:29

You aren't passing a player id to steal_ammo .

xcalibar 04-10-2006 07:15

thanks for all the replys,

i changed the code to this
Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <cstrike> #define PLUGIN "Test rip ammo" #define VERSION "1.1 rc1" #define AUTHOR "TEST" #define free 10 public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     set_task(float(free),"steal_ammo",_,_,_,"b") } public steal_ammo(){ for (new i = 0; i <= get_maxplayers(); i++) { if (is_user_alive(i) && is_user_connected(i) && !is_user_bot(i) && !is_user_hltv(i)) { cs_set_weapon_ammo(i,0) new clip, ammo, wid = get_user_weapon(i, clip,ammo) cs_set_user_bpammo(i,cs_get_weapon_id (wid),0) set_hudmessage(255, 255, 255, 0.11, 0.31, 0, 6.0, 12.0) show_hudmessage(i, "Oh no! The grim reaper has killed all your ammo ;P") } } return PLUGIN_HANDLED }
i borrowed the user id code from Cheesy Peteza's AFk Kicker


however i now get the following error

Code:
[CSTRIKE] Non-player entity 1 out of range [AMXX] Run time error 10 (plugin "test.amxx") - debug not enabled! [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).

i have also set amx_debug to "2"


thanks in advance


Xcalibar

[ --<-@ ] Black Rose 04-10-2006 07:42

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <cstrike> #define PLUGIN "Test rip ammo" #define VERSION "1.1 rc1" #define AUTHOR "TEST" #define free 10 public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     set_task(float(free),"steal_ammo",_,_,_,"b") } public steal_ammo() {     new Player[32], PlayerCount     get_players(Player, PlayerCount, "ach")     /*     "a" - Don't return dead players     "c" - Skip bots     "h" - Skip HLTV     */     for (new i = 0; i <= PlayerCount; i++) {         if ( is_user_connected(Player[i]) ) {             cs_set_weapon_ammo(Player[i],0)             new clip, ammo, wid = get_user_weapon(Player[i], clip, ammo)             cs_set_user_bpammo(Player[i],cs_get_weapon_id(wid),0)             set_hudmessage(255, 255, 255, 0.11, 0.31, 0, 6.0, 12.0)             show_hudmessage(Player[i], "Oh no! The grim reaper has killed all your ammo ;P")         }     }     return PLUGIN_HANDLED }

xcalibar 04-10-2006 09:58

thanks Black Rose for the reply

however it still returns the same error as before

Code:
[CSTRIKE] Non-player entity 1 out of range [AMXX] Run time error 10 (plugin "test.amxx") - debug not enabled! [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).


thanks in advanced

Xcalibar

VEN 04-10-2006 12:13

Do not confuse cs_*_weapon_* natives with cs_*_user_* natives.

For example:
native cs_get_user_deaths(index) uses player's index.
native cs_get_weapon_id(index) uses weapon's entity index.

If you dont know what is weapon's entity index you shouldn't use such natives.

xcalibar 04-11-2006 14:06

Thanks for all the replys so far,

i'm still having trouble with this i did manage to get past the runtime error but run into another problem, it doesn't seem to remove the ammo?


heres what i've got,
Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <cstrike> #define PLUGIN "Test rip ammo" #define VERSION "1.1 rc5" #define AUTHOR "TEST" #define free 10 public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     set_task(float(free),"list_users",_,_,_,"b") } public list_users(id){ new Player[32], PlayerCount get_players(Player, PlayerCount, "ach") for (new i = 0; i <= PlayerCount; i++) { if ( is_user_connected(Player[i]) ) { new weapons[32],wep[32],inum get_user_weapons(Player[i],weapons,inum) get_weaponname(weapons[i],wep,32) cs_set_weapon_ammo(wep[i], 0) set_hudmessage(255, 255, 255, 0.11, 0.31, 0, 6.0, 5.0) show_hudmessage(Player[i], "This should have stolen your ammo for the %s",wep[i]) } } }



thanks in advance

xcalibar

VEN 04-11-2006 14:15

I think you didn't listen, reread what i said in the previous post.


All times are GMT -4. The time now is 16:38.

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