AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Correct or Not? I have do my best (https://forums.alliedmods.net/showthread.php?t=86053)

ilham92-cc-sakura 02-20-2009 02:12

Correct or Not? I have do my best
 
I have try... seems can't compile after i add function "public spwn_cmd (victim);"

PHP Code:

/*
        I'm hurt! HE make me can't listen for while!

        Extra stuff for Grenade Enhancer by anakin_cstrike
        
        This plugins will play sound when HE throw and player get
        damage from HE. Hurt Sound will be played.
        
        More real style HE damage like Half-Life 2 and Call of Duty 4
        Download: http://forums.alliedmods.net/showthread.php?p=651536
        
        © Copyright 2008 ANiME clan.
        Visit: http://ilham92-cc-sakura.webs/
    Under License GNU
    
    English help by: [ANiME|ADMiN][5hp-Evolution]
    Created by: [ANiME|ADMiN][Ilham Sakura] aka ilham92-cc-sakura
    Scripting Help: SnoW (Damage Event)
    Scripting Help: Tuty (Stock)

*/

#include <amxmodx>
#include <fakemeta>
#include <csx>

#define SND1 "player/player_listen.wav"
#define SND2 "player/breathe1noloop.wav"
#define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))

new amx_pcvar_0;
new const 
g_soundName[2][16];
new const 
g_soundDir[2][32];
new 
g_num;

public 
plugin_init()
{
    
register_plugin("HE Player Damage Snd""1.0","ilham92-cc-sakura");
    
amx_pcvar_0 register_cvar("he_hit_respawn","1");
    
register_clcmd("say /spwn","spwn_cmd");
    
register_clcmd("say_team /spwn""spwn_cmd");
}
public 
plugin_precache()
{
    new 
szFile[64];
    
    
add(szFilecharsmax(szFile), "/hesnd.ini");
    if(!
file_exists(szFile))
    {
        
write_file(szFile"; HE Damage Sound Configuration File", -1);
        
write_file(szFile"; ----------------------------------", -1);
        
write_file(szFile"; Do not start path with ^"sound/^"", -1);
        
write_file(szFile"; SND1 for Sound Event 1", -1);
        
write_file(szFile"; SND2 for Sound Event 2", -1);
        
write_file(szFile"; Be sure sound file with [*.wav] file extension!", -1);
        
write_file(szFile"; ----------------------------------", -1);
    }
    new 
szBuffer[128], iLeniLine;
    while(
read_file(szFileiLine++, szBuffersizeof szBuffer 1iLen))
    {
        if(!
iLen || szBuffer[0] == ';')
            continue;
        
        
parse(szBufferg_soundName[g_num], sizeof g_soundName[] - 1g_soundDir[g_num], sizeof g_soundDir[] - 1);
        
engfunc(EngFunc_PrecacheSoundg_soundDir[g_num]);
        
        if(
g_num >= 2)
            break;
    }
}
public 
client_damage(attacker,victim,damage,wpnindex,hitplace,TA)
{
    if(
get_pcvar_num(amx_pcvar_0) != && wpnindex != CSW_HEGRENADE)
        return 
PLUGIN_HANDLED;
    
    new 
sound1[129];
    
copy(sound1,128,SND1);

    if(
contain(sound1,".wav"))
    {
        
replace(sound1,128,".wav","");
        
client_cmd(victim"spk %s",sound1);
    }

    new 
sound2[131];
    
copy(sound2,130,SND2);

    if(
contain(sound2,".wav"))
    {
        
replace(sound1,130,".wav","");
        
client_cmd(victim"spk %s",sound2);
    }

    new 
pl_name[32];
    
get_user_name(victim,pl_name31);
    
    
client_print(0print_chat"[Grenade]: %s get hit by HE Grenade",pl_name);
    
    if(
get_user_team(victim) == 1)
    {
        
fm_give_item(victim"weapon_knife");
        
fm_give_item(victim"weapon_mp5navy");
        
fm_give_item(victim"item_kevlar");
        
fm_give_item(victim"ammo_9mm");
        
fm_give_item(victim"ammo_9mm");
        
fm_give_item(victim"ammo_9mm");
        
fm_give_item(victim"ammo_9mm");
    }
    if 
is_user_alive(victim)
    {
        
set_task(0.6,"respawnagain",victim);
        
client_print(0print_chat"[Grenade]: HE kill %s and respwan.",pl_name);
    }
    return 
PLUGIN_CONTINUE;
}
public 
spwn_cmd (victim)
{
    if(
get_pcvar_num(respawnagain) != 1)
    
client_print(victimprint_chat"[Grenade]: Re-Spwan Enable")
    
    else(
get_pcvar_num(respawnagain) != 0)
    
client_print(victimprint_chat"[Grenade]: Re-Spwan Disable")
}
public 
respawnagain(victim)
{
    
fm_cs_user_spawn(victim);
}
stock fm_cs_user_spawn(index)
{
    
set_pev(indexpev_deadflagDEAD_RESPAWNABLE);
    
dllfunc(DLLFunc_Spawnindex);
    
set_pev(indexpev_iuser10);

    return 
1;
}
stock fm_give_item(index, const item[])
{
    if (!
equal(item"weapon_"7) && !equal(item"ammo_"5) && !equal(item"item_"5) && !equal(item"tf_weapon_"10))
        return 
0;

    new 
ent fm_create_entity(item);

    if (!
pev_valid(ent))
        return 
0;

    new 
Float:origin[3];
    
pev(indexpev_originorigin);
    
set_pev(entpev_originorigin);
    
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN);
    
dllfunc(DLLFunc_Spawnent);

    new 
save pev(entpev_solid);
    
dllfunc(DLLFunc_Touchentindex);

    if (
pev(entpev_solid) != save)
        return 
ent;

    
engfunc(EngFunc_RemoveEntityent);
    return -
1;


i wanna make say /spwn (enable/disable spwan after HE Hit) and *.ini file.
seems not work.

Error:
Code:

Error: Expected token: "(", but found "-identifier-" on line 109
Error: Start of function body without function header on line 117
Error: Invalid function or declaration on line 118
Error: Invalid function or declaration on line 121

4 Errors.

can help me..

anakin_cstrike 02-20-2009 03:54

Re: Correct or Not? I have do my best
 
Here
PHP Code:

/*
        I'm hurt! HE make me can't listen for while!

        Extra stuff for Grenade Enhancer by anakin_cstrike
        
        This plugins will play sound when HE throw and player get
        damage from HE. Hurt Sound will be played.
        
        More real style HE damage like Half-Life 2 and Call of Duty 4
        Download: http://forums.alliedmods.net/showthread.php?p=651536
        
        © Copyright 2008 ANiME clan.
        Visit: http://ilham92-cc-sakura.webs/
    Under License GNU
    
    English help by: [ANiME|ADMiN][5hp-Evolution]
    Created by: [ANiME|ADMiN][Ilham Sakura] aka ilham92-cc-sakura
    Scripting Help: SnoW (Damage Event)
    Scripting Help: Tuty (Stock)

*/

#include <amxmodx>
#include <fakemeta>
#include <csx>

#define SND1 "player/player_listen.wav"
#define SND2 "player/breathe1noloop.wav"
#define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))

new amx_pcvar_0;
new const 
g_soundName[2][16];
new const 
g_soundDir[2][32];
new 
g_num;

public 
plugin_init()
{
    
register_plugin("HE Player Damage Snd""1.0","ilham92-cc-sakura");
    
amx_pcvar_0 register_cvar("he_hit_respawn","1");
    
register_clcmd("say /spwn","spwn_cmd");
    
register_clcmd("say_team /spwn""spwn_cmd");
}
public 
plugin_precache()
{
    new 
szFile[64];
    
    
add(szFilecharsmax(szFile), "/hesnd.ini");
    if(!
file_exists(szFile))
    {
        
write_file(szFile"; HE Damage Sound Configuration File", -1);
        
write_file(szFile"; ----------------------------------", -1);
        
write_file(szFile"; Do not start path with ^"sound/^"", -1);
        
write_file(szFile"; SND1 for Sound Event 1", -1);
        
write_file(szFile"; SND2 for Sound Event 2", -1);
        
write_file(szFile"; Be sure sound file with [*.wav] file extension!", -1);
        
write_file(szFile"; ----------------------------------", -1);
    }
    new 
szBuffer[128], iLeniLine;
    while(
read_file(szFileiLine++, szBuffersizeof szBuffer 1iLen))
    {
        if(!
iLen || szBuffer[0] == ';')
            continue;
        
        
parse(szBufferg_soundName[g_num], sizeof g_soundName[] - 1g_soundDir[g_num], sizeof g_soundDir[] - 1);
        
engfunc(EngFunc_PrecacheSoundg_soundDir[g_num]);
        
        if(
g_num >= 2)
            break;
    }
}
public 
client_damage(attacker,victim,damage,wpnindex,hitplace,TA)
{
    if(
get_pcvar_num(amx_pcvar_0) != && wpnindex != CSW_HEGRENADE)
        return 
PLUGIN_HANDLED;
    
    new 
sound1[129];
    
copy(sound1,128,SND1);

    if(
contain(sound1,".wav"))
    {
        
replace(sound1,128,".wav","");
        
client_cmd(victim"spk %s",sound1);
    }

    new 
sound2[131];
    
copy(sound2,130,SND2);

    if(
contain(sound2,".wav"))
    {
        
replace(sound1,130,".wav","");
        
client_cmd(victim"spk %s",sound2);
    }

    new 
pl_name[32];
    
get_user_name(victim,pl_name31);
    
    
client_print(0print_chat"[Grenade]: %s get hit by HE Grenade",pl_name);
    
    if(
get_user_team(victim) == 1)
    {
        
fm_give_item(victim"weapon_knife");
        
fm_give_item(victim"weapon_mp5navy");
        
fm_give_item(victim"item_kevlar");
        
fm_give_item(victim"ammo_9mm");
        
fm_give_item(victim"ammo_9mm");
        
fm_give_item(victim"ammo_9mm");
        
fm_give_item(victim"ammo_9mm");
    }
    if ( 
is_user_alive(victim) )
    {
        
set_task(0.6,"respawnagain",victim);
        
client_print(0print_chat"[Grenade]: HE kill %s and respwan.",pl_name);
    }
    return 
PLUGIN_CONTINUE;
}
public 
spwn_cmd (victim)
{
    switch(
get_pcvar_num(amx_pcvar_0))
    {
        case 
1:
            
client_print(victimprint_chat"[Grenade]: Re-Spwan Enable")
    
        case 
0:
            
client_print(victimprint_chat"[Grenade]: Re-Spwan Disable")
    }
}
public 
respawnagain(victim)
{
    
fm_cs_user_spawn(victim);
}
stock fm_cs_user_spawn(index)
{
    
set_pev(indexpev_deadflagDEAD_RESPAWNABLE);
    
dllfunc(DLLFunc_Spawnindex);
    
set_pev(indexpev_iuser10);

    return 
1;
}
stock fm_give_item(index, const item[])
{
    if (!
equal(item"weapon_"7) && !equal(item"ammo_"5) && !equal(item"item_"5) && !equal(item"tf_weapon_"10))
        return 
0;

    new 
ent fm_create_entity(item);

    if (!
pev_valid(ent))
        return 
0;

    new 
Float:origin[3];
    
pev(indexpev_originorigin);
    
set_pev(entpev_originorigin);
    
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN);
    
dllfunc(DLLFunc_Spawnent);

    new 
save pev(entpev_solid);
    
dllfunc(DLLFunc_Touchentindex);

    if (
pev(entpev_solid) != save)
        return 
ent;

    
engfunc(EngFunc_RemoveEntityent);
    return -
1;


I didn't looked at the rest of the code.
The major problem that caused the errors was:
PHP Code:

if is_user_alive(victim


You forgot 2 braces.
</span></span>
And then, you can't use a pointer for get_pcvar_num wich is used as public for a task.

ilham92-cc-sakura 02-20-2009 04:24

Re: Correct or Not? I have do my best
 
Woring Fine. but. when i type: /spwn only show:
"[Grenade]: Re-Spwan Enable"

it can't disable.

function miss to disable for player
PHP Code:

public spwn_cmd (victim)
{
    switch(
get_pcvar_num(amx_pcvar_0))
    {
        case 
1:
            
client_print(victimprint_chat"[Grenade]: Re-Spwan Enable")
        case 
0:
            
client_print(victimprint_chat"[Grenade]: Re-Spwan Disable")
    }


when i move that to:
PHP Code:

    if(is_user_alive(victim))    
    {
        
set_task(0.6,"respawnagain",victim);
        
client_print(0print_chat"[Grenade]: HE kill %s and respwan.",pl_name);
    }
    return 
PLUGIN_CONTINUE

can't compile and unable to on/off for player

anakin_cstrike 02-20-2009 06:04

Re: Correct or Not? I have do my best
 
he_hit_respawn 0/1

xPaw 02-20-2009 08:53

Re: Correct or Not? I have do my best
 
PHP Code:

public spwn_cmdid ) {
    switch( 
get_pcvar_num(amx_pcvar_0) ) {
        case 
1client_print(idprint_chat"[Grenade]: Re-Spwan Enabled");
        default: 
client_print(idprint_chat"[Grenade]: Re-Spwan Disabled");
    }
}

// i think this is better because you will have only 1/0

public spwn_cmdid ) {
    if( 
get_pcvar_num(amx_pcvar_0) == ) {
        
client_print(idprint_chat"[Grenade]: Re-Spwan Enabled");
    } else {
        
client_print(idprint_chat"[Grenade]: Re-Spwan Disabled");
    }



anakin_cstrike 02-20-2009 11:42

Re: Correct or Not? I have do my best
 
PHP Code:

// i think this is better because you will have only 1/0 

public spwn_cmdid ) { 
    if( 
get_pcvar_num(amx_pcvar_0) == ) { 
        
client_print(idprint_chat"[Grenade]: Re-Spwan Enabled"); 
    } else { 
        
client_print(idprint_chat"[Grenade]: Re-Spwan Disabled"); 
    } 


->
PHP Code:

get_pcvar_num(amx_pcvar_0)
?
     
client_print(idprint_chat"[Grenade]: Re-Spwan Enabled")
:    
client_print(idprint_chat"[Grenade]: Re-Spwan Disabled"); 


SnoW 02-20-2009 12:52

Re: Correct or Not? I have do my best
 
Quote:

Originally Posted by anakin_cstrike (Post 765376)
PHP Code:

get_pcvar_num(amx_pcvar_0)
?
     
client_print(idprint_chat"[Grenade]: Re-Spwan Enabled")
:    
client_print(idprint_chat"[Grenade]: Re-Spwan Disabled"); 


->
PHP Code:

client_print(idprint_chat"[Grenade]: Re-Spwan %s"get_pcvar_num(amx_pcvar_0) ? "Disabled." "Enabled."); 

Just how u like it.

ilham92-cc-sakura 02-22-2009 05:04

Re: Correct or Not? I have do my best
 
Both of them.. can't... disable or enable. also spwan...

why not return..
PHP Code:

    if (is_user_alive(victim))
    {
        
set_task(0.6,"respawnagain",victim);
        
client_print(0print_chat"[Grenade]: HE kill %s and respwan.",pl_name);
    }
    return 
PLUGIN_CONTINUE

PHP Code:

public spwn_cmd(id
{
    if( 
get_pcvar_num(amx_pcvar_0) == 
    {
    
client_print(idprint_chat"[Grenade]: Re-Spwan %s"get_pcvar_num(amx_pcvar_0) ? "Disabled." "Enabled.");
    }


replace "respawnagain" to "spwn_cmd"

i have try... not work

second... pcvar giving weapon...
PHP Code:

public plugin_init()
{
amx_pcvar_1 register_cvar("he_give_wpn""1");


PHP Code:

    if(get_pcvar_num(amx_pcvar_1) != && (get_user_team(victim) == 1)
        return 
PLUGIN_HANDLED;
    {
        
fm_give_item(victim"weapon_knife");
        
fm_give_item(victim"weapon_mp5navy");
        
fm_give_item(victim"item_kevlar");
        
fm_give_item(victim"ammo_9mm");
        
fm_give_item(victim"ammo_9mm");
        
fm_give_item(victim"ammo_9mm");
        
fm_give_item(victim"ammo_9mm");
    } 

Error:
Code:

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Error: Expected token: ")", but found "return" on line 102

1 Error.



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

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