AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   cant compile simple code .. (https://forums.alliedmods.net/showthread.php?t=195118)

avril-lavigne 09-03-2012 18:15

cant compile simple code ..
 
PHP Code:

 #include <amxmodx> 
#include <hamsandwich>
#include <cstrike>
#include <fakemeta> 
#include <engine>


new const oldknife_sounds[][] =
{
"weapons/knife_deploy1.wav",    // Deploy Sound
"weapons/knife_hit1.wav",    // Hit 1
"weapons/knife_hit2.wav",    // Hit 2
"weapons/knife_hit3.wav",    // Hit 3
"weapons/knife_hit4.wav",    // Hit 4
"weapons/knife_hitwall1.wav",    // Hit Wall
"weapons/knife_slash1.wav",    // Slash 1
"weapons/knife_slash2.wav",    // Slash 2
"weapons/knife_stab.wav",
"common/wpn_select.wav" 
}


const 
m_pPlayer 41

public plugin_init()
{
register_plugin("Defibrilator""1.0""skype lemishev")
register_event("CurWeapon","switchweapon","be ","1=1","2!29"
register_forward(FM_EmitSound"fw_EmitSound"
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_knife""fw_Knife_PrimaryAttack_Post"1)
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_knife""fw_Knife_SecondaryAttack_Post"1)
}

public 
plugin_precache()
{
precache_model("models/knf_new2.mdl"
precache_sound("defibrilator/knife_hit1.wav"
precache_sound("defibrilator/knife_slash1.wav" )
precache_sound("defibrilator/knife_deploy1.wav" 
}

public 
switchweapon(id)

if( 
read_data(2) == CSW_KNIFE) {
set_pev(id,pev_viewmodel2,"models/knf_new2.mdl"
client_cmd(id,"speak defibrilator/knife_deploy1.wav"
}



public 
fw_EmitSound(idchannel, const sound[])
{

if(!
is_user_alive(id))
return 
FMRES_IGNORED 



// Check sound
for(new 0sizeof oldknife_soundsi++)
{
if(
equal(soundoldknife_sounds[i]))


return 
FMRES_SUPERCEDE
}
}

return 
FMRES_IGNORED
}



public 
fw_Knife_PrimaryAttack_Post(knife)
{    

static 
id
id 
get_pdata_cbase(knifem_pPlayer4)    

if(
is_user_connected(id))
emit_sound(idCHAN_WEAPON"defibrilator/knife_hit1"VOL_NORMATTN_NORM0PITCH_NORM



}

public 
fw_Knife_SecondaryAttack_Post(knife)
{    

static 
id
id 
get_pdata_cbase(knifem_pPlayer4)


if(
is_user_connected(id))
emit_sound(idCHAN_WEAPON"defibrilator/knife_slash1"VOL_NORMATTN_NORM0PITCH_NORM





amxx studio shows me problem in FW emit sound.
i took this part from my another plugin. and it works there fine. but after removing some code I cant compile plugin

OvidiuS 09-03-2012 18:51

Re: cant compile simple code ..
 
I changed it a bit
Code:
#include < amxmodx >    #include < hamsandwich > #include < fakemeta >   new const oldknife_sounds[][] = {     "weapons/knife_deploy1.wav",    // Deploy Sound     "weapons/knife_hit1.wav",   // Hit 1     "weapons/knife_hit2.wav",   // Hit 2     "weapons/knife_hit3.wav",   // Hit 3     "weapons/knife_hit4.wav",   // Hit 4     "weapons/knife_hitwall1.wav",   // Hit Wall     "weapons/knife_slash1.wav", // Slash 1     "weapons/knife_slash2.wav", // Slash 2     "weapons/knife_stab.wav",     "common/wpn_select.wav"   } const m_pPlayer =    41 new Trie:g_tSounds     public plugin_init( ) {     register_plugin( "Defibrilator", "1.0", "skype lemishev" )         register_event( "CurWeapon", "switchweapon", "be", "1=1", "2!29" )      register_forward( FM_EmitSound, "forward_EmitSound" )         RegisterHam( Ham_Weapon_PrimaryAttack, "weapon_knife", "fw_Knife_PrimaryAttack_Post", true )     RegisterHam( Ham_Weapon_SecondaryAttack, "weapon_knife", "fw_Knife_SecondaryAttack_Post", true )         for( new i = 0; i < sizeof oldknife_sounds; i++ )         TrieSetCell( g_tSounds, oldknife_sounds[ i ], 1 ); } public plugin_precache( ) {     precache_model( "models/knf_new2.mdl" )           precache_sound( "defibrilator/knife_hit1.wav" )             precache_sound( "defibrilator/knife_slash1.wav" )     precache_sound( "defibrilator/knife_deploy1.wav" )   } public switchweapon( id ) {       if( read_data( 2 ) == CSW_KNIFE )     {         set_pev( id, pev_viewmodel2, "models/knf_new2.mdl" )           client_cmd( id, "speak defibrilator/knife_deploy1.wav" )        } } public forward_EmitSound( id, iChannel, const szSound[ ], Float:flVol, Float:flAttn, iFlags, iPitch ) {     if( TrieKeyExists( g_tSounds, szSound ) )     {         if( is_user_alive( id ) )             return FMRES_SUPERCEDE     }     return FMRES_IGNORED; } public fw_Knife_PrimaryAttack_Post( iKnife ) {         static id     id = get_pdata_cbase( iKnife, m_pPlayer, 4 )                if( is_user_connected( id ) )         emit_sound( id, CHAN_WEAPON, "defibrilator/knife_hit1", VOL_NORM, ATTN_NORM, 0, PITCH_NORM )            } public fw_Knife_SecondaryAttack_Post( iKnife ) {     static id     id = get_pdata_cbase( iKnife, m_pPlayer, 4 )     if( is_user_connected( id ) )         emit_sound( id, CHAN_WEAPON, "defibrilator/knife_slash1", VOL_NORM, ATTN_NORM, 0, PITCH_NORM )      }

Anyway your mistake was in
switchweapon(id)
You are missing some }

avril-lavigne 09-03-2012 18:57

Re: cant compile simple code ..
 
thanks

avril-lavigne 09-03-2012 22:39

Re: cant compile simple code ..
 
your code didnt work dont know why. I replaced it with old one.
so the result is here

defibrillator
http://www.youtube.com/watch?v=qHoC0IvEfI8

fysiks 09-03-2012 23:41

Re: cant compile simple code ..
 
Your first post says the thread has been solved . . .

avril-lavigne 09-04-2012 13:38

Re: cant compile simple code ..
 
Ive changed 1st post after ovidius reply

YamiKaitou 09-04-2012 13:41

Re: cant compile simple code ..
 
Post restored, do not delete your posts when your issue has been resolved.


All times are GMT -4. The time now is 08:17.

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