Raised This Month: $ Target: $400
 0% 

Remove ammo problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xcalibar
Junior Member
Join Date: Apr 2006
Old 04-09-2006 , 15:19   Remove ammo problem
Reply With Quote #1

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
xcalibar is offline
slurpycof
Senior Member
Join Date: Nov 2004
Old 04-09-2006 , 20:33  
Reply With Quote #2

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
slurpycof is offline
ev0d00b
Member
Join Date: Aug 2005
Location: Middle Earth
Old 04-09-2006 , 23:04   Re: Remove ammo problem
Reply With Quote #3

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.
__________________
ev0d00b is offline
Send a message via MSN to ev0d00b
FatalisDK
Senior Member
Join Date: Mar 2006
Location: bacon
Old 04-10-2006 , 02:29  
Reply With Quote #4

You aren't passing a player id to steal_ammo .
__________________
FatalisDK is offline
xcalibar
Junior Member
Join Date: Apr 2006
Old 04-10-2006 , 07:15  
Reply With Quote #5

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
xcalibar is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 04-10-2006 , 07:42  
Reply With Quote #6

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 }
[ --<-@ ] Black Rose is offline
xcalibar
Junior Member
Join Date: Apr 2006
Old 04-10-2006 , 09:58  
Reply With Quote #7

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
xcalibar is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 04-10-2006 , 12:13  
Reply With Quote #8

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.
VEN is offline
xcalibar
Junior Member
Join Date: Apr 2006
Old 04-11-2006 , 14:06  
Reply With Quote #9

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
xcalibar is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 04-11-2006 , 14:15  
Reply With Quote #10

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



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 16:38.


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