Raised This Month: $ Target: $400
 0% 

Problems with: 'precache_sound' and 'register_menucmd'


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
aljoscha
Junior Member
Join Date: Apr 2006
Old 04-30-2006 , 04:10   Problems with: 'precache_sound' and 'register_menucmd'
Reply With Quote #1

Hello there,

i want to change the mp5(m203)_mod in following ways:
  • - it should use only standard ressources (original mp5 model, hesounds..)
    - it should work for everyone (because some players don't buy automaticly m203 nades, when they buy HEnades. It works only for everyone if they have binded "hegren")

Now i have two Problems
1. the sounds doesn't work
2. i don't now how to fix the nades bug

I hope, you can help me.
(The Problems in the source are marked with '// <<-- BUYPROBLEM' and '// <<-- SOUNDPROBLEM')


Code:
/*/// Mp5+M203 Launcher - by PaintLancer ///////////////////////////// Resources used        - Thantik - HE-conc for knockback        - Asskickr - Grentrail        - EKS - sprite - doing hud sprites Directions     Players buy normal mp5 and buy grenades for it through buying     normal HE grenades 1.9 - Fixed kill given to killed     - Raised start origin of nade fired so it more the actual height of the gun */ #include <amxmodx> #include <fakemeta> #include <engine> #include <cstrike> #include <fun> new g_mp5[33] new g_m203_loaded[33] new g_ammo[33] new g_lastweap[33] new g_buyzone[33] new gmsgDeathMsg new gMsgID //sprites new m_iTrail new xplode #define ICON_HIDE 0 #define ICON_SHOW 1 #define TE_BEAMFOLLOW 22 public plugin_init() {   register_plugin("Mp5 Mod","1.9","PaintLancer")   register_event("DeathMsg","player_die","a")     register_event("CurWeapon","handle_gun","be","1=1")   register_event("StatusIcon","Buy_Icon","be","2=buyzone")   //handle buying nades   register_menucmd(-34,(1<<3),"BuyNade") // <<-- BUYPROBLEM   register_clcmd("hegren", "BuyNade")   //handle when player presses attack2   register_forward(FM_PlayerPreThink, "forward_playerprethink")   // handle world model   register_forward(FM_SetModel, "forward_setmodel")   //cvars   register_cvar("amx_m203cost","300")  //cost for nade   register_cvar("amx_m203ammo","5")  //ammo limit for backpack   register_cvar("amx_crazynade","0") //makes nades bounce off all walls with perfect elasticity until it hits an entity or player...can get crazy   register_cvar("amx_m203conc","10.0")  //force of knockback   register_cvar("amx_m203trail","1")  //nade trails   register_cvar("amx_m203rad","200")  //radius of dmg   register_cvar("amx_m203dmg","100")  //dmg   gmsgDeathMsg = get_user_msgid("DeathMsg")   gMsgID = get_user_msgid("StatusIcon")   return PLUGIN_CONTINUE } public player_die(id) {   if(g_mp5[id])     ammo_hud(id,0)   g_ammo[id] = 0     return PLUGIN_CONTINUE } public BuyNade(id) {   new money = cs_get_user_money(id)   if(g_mp5[id] && g_ammo[id] < get_cvar_num("amx_m203ammo") && money >= get_cvar_num("amx_m203cost") && g_buyzone[id])   {     ammo_hud(id,0)     g_ammo[id]++     ammo_hud(id,1)     client_print(id, print_center, "You bought a grenade for your M203 Launcher %d/%d", g_ammo[id], get_cvar_num("amx_m203ammo"))         cs_set_user_money(id, money - get_cvar_num("amx_m203cost"))     return PLUGIN_HANDLED   }   return PLUGIN_CONTINUE } public forward_setmodel(entity, model[]) {   if (!is_valid_ent(entity))   {     return FMRES_IGNORED   }   if (equal(model, "models/w_mp5.mdl"))   {     new classname[11]     entity_get_string(entity, EV_SZ_classname, classname, 10)       //client_print(0, print_chat, "Model: %s Classname: %s", model, classname)     if (equal(classname, "weaponbox"))     {       //client_print(0, print_chat, "Setting model")       entity_set_model(entity, "models/w_9mmar.mdl")       return FMRES_SUPERCEDE     }   }   return FMRES_IGNORED } public forward_playerprethink(id) {   if(is_user_alive(id))   {     if (entity_get_int(id, EV_INT_button) & IN_ATTACK2)     {       launch_nade(id)       return FMRES_IGNORED     }   }   return FMRES_IGNORED } public handle_gun(id) {   new clip, ammo   new weap = get_user_weapon(id,clip,ammo)   if(weap == CSW_MP5NAVY && g_lastweap[id] != weap)   {     ammo_hud(id,1)     //client_print(id, print_chat, "Setting Model")     entity_set_string(id, EV_SZ_viewmodel, "models/v_mp5.mdl")     entity_set_string(id, EV_SZ_weaponmodel, "models/p_9mmar.mdl")     g_mp5[id] = 1   }   else if(weap != CSW_MP5NAVY)   {     ammo_hud(id,0)     g_mp5[id] = 0   }   g_lastweap[id] = weap   return PLUGIN_HANDLED } public launch_nade(id) {   if(g_mp5[id] == 0 || g_m203_loaded[id] == 0 || !(is_user_alive(id)))     return PLUGIN_CONTINUE   if(g_ammo[id] == 0)   {     client_print(id, print_center, "You are out of m203 grenades!")     return PLUGIN_CONTINUE   }   entity_set_int(id, EV_INT_weaponanim, 3)   new Float: Origin[3], Float: Velocity[3], Float: vAngle[3], Ent   entity_get_vector(id, EV_VEC_origin , Origin)   entity_get_vector(id, EV_VEC_v_angle, vAngle)   //client_print(id, print_center, "Origin: %f-%f-%f", Origin[0], Origin[1], Origin[2])   //client_print(id, print_center, "vAngle: %f-%f-%f", vAngle[0], vAngle[1], vAngle[2])   Origin[2] = Origin[2] + 10   Ent = create_entity("info_target")   if (!Ent) return PLUGIN_HANDLED   entity_set_string(Ent, EV_SZ_classname, "m203_nade")   entity_set_model(Ent, "models/grenade.mdl")   new Float:MinBox[3] = {-1.0, -1.0, -1.0}   new Float:MaxBox[3] = {1.0, 1.0, 1.0}   entity_set_vector(Ent, EV_VEC_mins, MinBox)   entity_set_vector(Ent, EV_VEC_maxs, MaxBox)   entity_set_origin(Ent, Origin)   entity_set_vector(Ent, EV_VEC_angles, vAngle)   entity_set_int(Ent, EV_INT_effects, 2)   entity_set_int(Ent, EV_INT_solid, 1)   entity_set_int(Ent, EV_INT_movetype, 10)   entity_set_edict(Ent, EV_ENT_owner, id)   VelocityByAim(id, 2000 , Velocity)   entity_set_vector(Ent, EV_VEC_velocity ,Velocity)       emit_sound(id,CHAN_VOICE,"he_bounce-1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)   g_m203_loaded[id] = 0   ammo_hud(id,0)   g_ammo[id]--   ammo_hud(id,1)   new parm[1]   parm[0] = Ent   if(get_cvar_num("amx_m203trail"))     set_task(0.2, "grentrail",id,parm,1)     parm[0] = id   set_task(2.0, "m203_reload",id+9910,parm,1)   return PLUGIN_CONTINUE } public m203_reload(parm[]) {     g_m203_loaded[parm[0]] = 1 } public vexd_pfntouch(pToucher, pTouched) {   new szClassName[32]   if ( pToucher > 0)   {     entity_get_string(pToucher, EV_SZ_classname, szClassName, 31)   }   if(equal(szClassName, "m203_nade"))   {     if(!pTouched && get_cvar_num("amx_crazynade"))       return     new damradius = get_cvar_num("amx_m203rad")//200     new maxdamage = get_cvar_num("amx_m203dmg")//70         new tkill = 0     new Float:fl_vExplodeAt[3]     entity_get_vector(pToucher, EV_VEC_origin, fl_vExplodeAt)     new vExplodeAt[3]     vExplodeAt[0] = floatround(fl_vExplodeAt[0])     vExplodeAt[1] = floatround(fl_vExplodeAt[1])     vExplodeAt[2] = floatround(fl_vExplodeAt[2])     new oid = entity_get_edict(pToucher, EV_ENT_owner)     new origin[3],dist,i,Float:dRatio,damage     for ( i = 0; i < 32; i++)     {       if((is_user_alive(i)))       {         get_user_origin(i,origin)     dist = get_distance(origin,vExplodeAt)     if (dist <= damradius)     {               dRatio = floatdiv(float(dist),float(damradius))       damage = maxdamage - floatround(floatmul(float(maxdamage),dRatio))       set_velocity_from_origin(i, fl_vExplodeAt, get_cvar_float("amx_m203conc")*damage) // ThantiK's he-conc function - tried getting it to recognize m203 nades but failed so imported function                     if(cvar_exists("mp_friendlyfire"))       {             if(i == oid)               do_victim(i, oid, damage, 2)         else if( get_cvar_num("mp_friendlyfire"))         {           if(get_user_team(i) == get_user_team(oid)) tkill = 1           do_victim(i,oid,damage,tkill)         }         else         {           if(get_user_team(i) != get_user_team(oid))           {         do_victim(i,oid,damage,0)           }                             }       }           else if(i == oid)             do_victim(i, oid, damage, 2)       else         do_victim(i,oid,damage,0)             }       }     }     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)     write_byte(17)     write_coord(vExplodeAt[0])     write_coord(vExplodeAt[1])     write_coord(vExplodeAt[2] + 60)     write_short(xplode)     write_byte(20)     write_byte(200)     message_end()     emit_sound(pToucher, CHAN_WEAPON, "hegrenade-1.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)         remove_entity(pToucher)   } } do_victim(victim,attacker,damage,tk) {   new namek[32],namev[32],authida[35],authidv[35],teama[32],teamv[32]   get_user_name(victim,namev,31)   get_user_name(attacker,namek,31)   get_user_authid(victim,authidv,34)   get_user_authid(attacker,authida,34)   get_user_team(victim,teamv,31)   get_user_team(attacker,teama,31)   new Float:fl_dmg = float(damage)   if(damage >= get_user_health(victim))   {     set_msg_block(gmsgDeathMsg,BLOCK_SET)     fakedamage(victim, "grenade", fl_dmg, DMG_BLAST)  //user_kill(victim,1)     set_msg_block(gmsgDeathMsg,BLOCK_NOT)     if(is_user_alive(victim)) //some cases where damage is messed with WC3? then return       return     message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0)     write_byte(attacker)     write_byte(victim)     write_byte(0)     write_string("grenade")     message_end()           if(tk == 1)     {       client_print(attacker,print_center,"You killed a teammate")       set_user_frags(attacker,get_user_frags(attacker) - 1 )       set_user_frags(victim, get_user_frags(victim) + 1)       log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"grenade^"",                 namek,get_user_userid(attacker),authida,teama,namev,get_user_userid(victim),authidv,teamv)     }     else if(tk == 2)     {       log_message("^"%s<%d><%s><%s>^" killed self with ^"grenade^"",                 namek,get_user_userid(attacker),authida,teama)     }     else     {       new money = cs_get_user_money(attacker)       cs_set_user_money(attacker, money + 300) // award for kill       set_user_frags(attacker,get_user_frags(attacker) + 1 )       //set_user_frags(attacker,get_user_frags(victim) + 1 )       log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"grenade^"",                 namek,get_user_userid(attacker),authida,teama,namev,get_user_userid(victim),authidv,teamv)     }       }   else   {     fakedamage(victim, "grenade", fl_dmg, DMG_BLAST) //set_user_health(victim,get_user_health(victim) - damage )     if(tk == 1)     {     client_print(0,print_chat,"%s attacked a teammate",namek)     }   } } public client_connect(id) {   g_mp5[id] = 0   g_m203_loaded[id] = 1   g_ammo[id] = 0 } public Buy_Icon(id) {   if (read_data(1))   {     g_buyzone[id] = true   }   else   {     g_buyzone[id] = false   }   return PLUGIN_CONTINUE } ammo_hud(id, sw) {   new s_sprite[33]   format(s_sprite,32,"number_%d",g_ammo[id])     if(sw)   {     message_begin( MSG_ONE, gMsgID, {0,0,0}, id )     write_byte( ICON_SHOW ) // status     write_string( s_sprite ) // sprite name     write_byte( 0 ) // red     write_byte( 160 ) // green     write_byte( 0 ) // blue     message_end()   }   else   {     message_begin( MSG_ONE, gMsgID, {0,0,0}, id )     write_byte( ICON_HIDE ) // status     write_string( s_sprite ) // sprite name     write_byte( 0 ) // red     write_byte( 160 ) // green     write_byte( 0 ) // blue     message_end()   } } ///////////////////// //Thantik's he-conc functions stock get_velocity_from_origin( ent, Float:fOrigin[3], Float:fSpeed, Float:fVelocity[3] ) {     new Float:fEntOrigin[3];     entity_get_vector( ent, EV_VEC_origin, fEntOrigin );     // Velocity = Distance / Time     new Float:fDistance[3];     fDistance[0] = fEntOrigin[0] - fOrigin[0];     fDistance[1] = fEntOrigin[1] - fOrigin[1];     fDistance[2] = fEntOrigin[2] - fOrigin[2];     new Float:fTime = ( vector_distance( fEntOrigin,fOrigin ) / fSpeed );     fVelocity[0] = fDistance[0] / fTime;     fVelocity[1] = fDistance[1] / fTime;     fVelocity[2] = fDistance[2] / fTime;     return ( fVelocity[0] && fVelocity[1] && fVelocity[2] ); } // Sets velocity of an entity (ent) away from origin with speed (speed) stock set_velocity_from_origin( ent, Float:fOrigin[3], Float:fSpeed ) {     new Float:fVelocity[3];     get_velocity_from_origin( ent, fOrigin, fSpeed, fVelocity )     entity_set_vector( ent, EV_VEC_velocity, fVelocity );     return ( 1 ); } public grentrail(parm[]) {   new gid = parm[0]   if (gid)   {     message_begin( MSG_BROADCAST, SVC_TEMPENTITY )     write_byte( TE_BEAMFOLLOW )     write_short(gid) // entity     write_short(m_iTrail)  // model     write_byte( 10 )       // life     write_byte( 5 )        // width     write_byte( 255 )      // r, g, b     write_byte( 255 )    // r, g, b     write_byte( 255 )      // r, g, b     write_byte( 100 ) // brightness             message_end() // move PHS/PVS data sending into here (SEND_ALL, SEND_PVS, SEND_PHS)   } } public plugin_precache() {   precache_model("models/v_mp5.mdl")   precache_model("models/p_9mmar.mdl")   precache_model("models/w_9mmar.mdl")   precache_model("models/grenade.mdl") precache_sound("weapons/he_bounce-1.wav") // <<-- SOUNDPROBLEM precache_sound("weapons/hegrenade-1.wav") // <<-- SOUNDPROBLEM   m_iTrail = precache_model("sprites/smoke.spr")   xplode = precache_model("sprites/fexplo.spr") }

greetz
aljoscha
aljoscha is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 04-30-2006 , 05:15  
Reply With Quote #2

http://forums.alliedmods.net/showthread.php?t=26363
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
aljoscha
Junior Member
Join Date: Apr 2006
Old 04-30-2006 , 05:20  
Reply With Quote #3

Sorry,

my english isn't the best...
Wrong thread?

How can i push it into the right thread ?
aljoscha is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 04-30-2006 , 05:22  
Reply With Quote #4

Use [small] tags instead of [quote] tags. Thanks
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
aljoscha
Junior Member
Join Date: Apr 2006
Old 04-30-2006 , 06:02  
Reply With Quote #5

Ok, thank you...
i have fixed it.

greetz
aljoscha
aljoscha is offline
aljoscha
Junior Member
Join Date: Apr 2006
Old 04-30-2006 , 10:54  
Reply With Quote #6

OH,

that 'i have fixed it' mean, that i have edited my text to use [small] tags.

I didn't fix my problems!
aljoscha is offline
Willmaker
Senior Member
Join Date: Dec 2004
Location: Sydney, Australia
Old 04-30-2006 , 12:07  
Reply With Quote #7

Im not sure, but maybe you can change:
Code:
emit_sound(id,CHAN_VOICE,"he_bounce-1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
to exactly how you wrote it when precaching?
ie,
Code:
emit_sound(id,CHAN_VOICE,"weapons/he_bounce-1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
__________________
GargStudios.net - Australian SvenCoop/Ent Server with Time Based Rewards
Willmaker is offline
Send a message via ICQ to Willmaker Send a message via AIM to Willmaker Send a message via MSN to Willmaker Send a message via Yahoo to Willmaker
aljoscha
Junior Member
Join Date: Apr 2006
Old 05-01-2006 , 05:32  
Reply With Quote #8

Thank you Willmaker,

i didn't see that... it works

but what about problem 2?
i can't understand why it doesn't work for everyone
aljoscha 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 05:10.


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