Raised This Month: $ Target: $400
 0% 

Passing A Single ID


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
The Specialist
BANNED
Join Date: Nov 2006
Old 11-05-2006 , 04:54   Passing A Single ID
Reply With Quote #1

I have a problem with my code , it works almost perfectly, except instead of executing the code on only one player's ID it executes on all the ID's. I need a way to set a condition that will work with what i have and only pass the id of the player to go over the cvars set.
Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> // global shot varaible new  g_iShots; public plugin_init() {     register_plugin("Weapon Jam","0.1","The Specialist");     register_cvar("amx_weapon_jam","1");     register_cvar("amx_jam_ratio","100");     register_event("CurWeapon", "weapon_event", "be", "1=1", "3>0", "2!4", "2!6", "2!9", "2!25", "2!29");     register_forward(FM_PlayerPreThink, "weapon_jam");     register_forward(FM_UpdateClientData, "weapon_jam_update", 1); } // current weapon event public weapon_event(id) {     // if plugin is off end function         if(get_cvar_num("amx_weapon_jam")== 0)     {         return PLUGIN_HANDLED;     }else{                          // if shots < ratio cvar increment varaible                 if(g_iShots <= get_cvar_num("amx_jam_ratio"))         {             ++g_iShots;             jam_sounds(id);         }     }     return PLUGIN_CONTINUE; } // pre-think public weapon_jam(id ) {       // if shots == cvar execute functions         if( g_iShots  == get_cvar_num("amx_jam_ratio"))     {         // show messages                 set_hudmessage(255, 255, 255, -1.0, 0.33, 0, 6.0, 12.0)         show_hudmessage(id, "Weapon Jam Press Use To Clear")                 // block attack button                 set_pev( id, pev_button, pev(id,pev_button) & ~IN_ATTACK );                 // execute clear chamber and sounds                 clear_chamber(id);     }     return FMRES_HANDLED; } // client update data public weapon_jam_update(id,sendweapons,cd_handle ) {       // if shots are = cvar execute functions         if(  g_iShots == get_cvar_num("amx_jam_ratio"))     {         // show messages                 set_hudmessage(255, 255, 255, -1.0, 0.33, 0, 6.0, 12.0)         show_hudmessage(id, "Weapon Jam Press Use To Clear")                 // block weapon cd id                 set_cd(cd_handle, CD_ID, 0);                   // clear chamber and play sounds                 clear_chamber(id);         return FMRES_HANDLED;     }     return FMRES_HANDLED; } public jam_sounds(id) {     // if shots is = cvar execute function         if( g_iShots == get_cvar_num("amx_jam_ratio"))     {         // play sounds                 emit_sound(id,CHAN_AUTO, "weapons/dryfire_rifle.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);     } } public clear_chamber(id) {     // if user presses use button execute functions         if(pev(id,pev_button) &  IN_USE )     {               //re-set varaible to 0                 g_iShots = 0;                 // play sounds                 emit_sound(id,CHAN_AUTO,"weapons/m4a1_boltpull.wav",1.0,ATTN_NORM,0,PITCH_NORM);                 // show messages                 set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 12.0);         show_hudmessage(id, "Chamber Clear");                 // and stop functions                 return PLUGIN_HANDLED;     }     return PLUGIN_HANDLED; }
Thank You For Your Time
The Specialist is offline
Send a message via AIM to The Specialist
schnitzelmaker
Senior Member
Join Date: Apr 2006
Location: HERE
Old 11-05-2006 , 07:59   Re: Passing A Single ID
Reply With Quote #2

you need to change
new g_iShots; -> new g_iShots[33];

and all other : g_iShots -> g_iShots[id]
__________________
schnitzelmaker is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 11-05-2006 , 13:53   Re: Passing A Single ID
Reply With Quote #3

hmm , Im getting some errors and i wont be able to declare my varaibles glaobalyif it has [id] at the end . could you show me an example of what you would do with my code that compiles please , thank you
The Specialist is offline
Send a message via AIM to The Specialist
stupok
Veteran Member
Join Date: Feb 2006
Old 11-05-2006 , 13:59   Re: Passing A Single ID
Reply With Quote #4

Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> // global shot varaible new  g_iShots[33]; public plugin_init() {     register_plugin("Weapon Jam","0.1","The Specialist");     register_cvar("amx_weapon_jam","1");     register_cvar("amx_jam_ratio","100");     register_event("CurWeapon", "weapon_event", "be", "1=1", "3>0", "2!4", "2!6", "2!9", "2!25", "2!29");     register_forward(FM_PlayerPreThink, "weapon_jam");     register_forward(FM_UpdateClientData, "weapon_jam_update", 1); } // current weapon event public weapon_event(id) {     // if plugin is off end function         if(get_cvar_num("amx_weapon_jam")== 0)     {         return PLUGIN_HANDLED;     }else{                          // if shots < ratio cvar increment varaible                 if(g_iShots[id] <= get_cvar_num("amx_jam_ratio"))         {             ++g_iShots[id];             jam_sounds(id);         }     }     return PLUGIN_CONTINUE; } // pre-think public weapon_jam(id ) {       // if shots == cvar execute functions         if( g_iShots[id]  == get_cvar_num("amx_jam_ratio"))     {         // show messages                 set_hudmessage(255, 255, 255, -1.0, 0.33, 0, 6.0, 12.0)         show_hudmessage(id, "Weapon Jam Press Use To Clear")                 // block attack button                 set_pev( id, pev_button, pev(id,pev_button) & ~IN_ATTACK );                 // execute clear chamber and sounds                 clear_chamber(id);     }     return FMRES_HANDLED; } // client update data public weapon_jam_update(id,sendweapons,cd_handle ) {       // if shots are = cvar execute functions         if(  g_iShots[id] == get_cvar_num("amx_jam_ratio"))     {         // show messages                 set_hudmessage(255, 255, 255, -1.0, 0.33, 0, 6.0, 12.0)         show_hudmessage(id, "Weapon Jam Press Use To Clear")                 // block weapon cd id                 set_cd(cd_handle, CD_ID, 0);                   // clear chamber and play sounds                 clear_chamber(id);         return FMRES_HANDLED;     }     return FMRES_HANDLED; } public jam_sounds(id) {     // if shots is = cvar execute function         if( g_iShots[id] == get_cvar_num("amx_jam_ratio"))     {         // play sounds                 emit_sound(id,CHAN_AUTO, "weapons/dryfire_rifle.wav", 1.0, ATTN_NORM, 0, PITCH_NORM);     } } public clear_chamber(id) {     // if user presses use button execute functions         if(pev(id,pev_button) &  IN_USE )     {               //re-set varaible to 0                 g_iShots[id] = 0;                 // play sounds                 emit_sound(id,CHAN_AUTO,"weapons/m4a1_boltpull.wav",1.0,ATTN_NORM,0,PITCH_NORM);                 // show messages                 set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 12.0);         show_hudmessage(id, "Chamber Clear");                 // and stop functions                 return PLUGIN_HANDLED;     }     return PLUGIN_HANDLED; }
stupok is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 11-05-2006 , 15:10   Re: Passing A Single ID
Reply With Quote #5

thanks it worked , all i did was forgot to index it ++karma
The Specialist is offline
Send a message via AIM to The Specialist
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 04:56.


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