AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   ExecuteHamB(Ham_CS_RoundRespawn, victim) (https://forums.alliedmods.net/showthread.php?t=127843)

FlyingHorse 05-25-2010 13:41

ExecuteHamB(Ham_CS_RoundRespawn, victim)
 
Why doesn't the respawn on my plugin work? When i die nothing happens..

PHP Code:

#include <amxmodx>
#include <fun>
#include <engine>
#include <hamsandwich>
#include <cstrike>
#include <csx>
#include <colorchat>

new g_szVictimSound[100], g_szKillerSound[100], g_szPlayersSound[100]
new 
g_iMaxPlayers
new const PLUGIN[ ] = "Rambo mod"
new const VERSION[ ] = "1.2"
new const AUTHOR[ ] = "FlyingHorse"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_Spawn"player""Event_Player_Spawn"1)
    
RegisterHam(Ham_Killed"player""Event_Ham_Killed")
    
register_event("DeathMsg""eDeathMsg_HeadShot""a""1>0""3=1")
}

public 
client_putinserver(id)
{
    
set_task(15.0"advertisement"id)
}

public 
advertisement(id)
{
    
ColorChat(idRED"^x04[Rambo Mod]^x01 This server is using^x03 Rambo mod^x04 v%s^x01 by^x04 FlyingHorse^x01."VERSION)
}
public 
plugin_precache()
{
    
precache_sound("fvox/blip.wav")
    new 
szFile[64]
    
get_localinfo("amxx_configsdir"szFile63)
    
format(szFile63"%s/headshots.ini"szFile)

    new 
File fopen(szFile"rt")
    if(!
File)
    {
        
pause("ad")
        return
    }

    new 
Text[128], Witch[8], Sound[100]
    while(!
feof(File))
    {
        
fgets(FileText127)
        
trimText )
        if(!
Text[0] || Text[0] == ';' || (Text[0] == '/' && Text[1] == '/'))
        continue

        
parse(TextWitch7Sound99)
        if(!
g_szVictimSound[0] && equal(Witch"victim"))
        {
            
copy(g_szVictimSound99Sound)
            
precache_sound(g_szVictimSound)
        }
        else if(!
g_szKillerSound[0] && equal(Witch"killer"))
        {
            
copy(g_szKillerSound99Sound)
            
precache_sound(g_szKillerSound)
        }
        else if(!
g_szPlayersSound[0] && equal(Witch"players"))
        {
            
copy(g_szPlayersSound99Sound)
            
precache_sound(g_szPlayersSound)
        }
    }
    
fclose(File)
}


public 
Event_Player_Spawn(id)
{    
    if(
is_user_alive(id))
    {
        
set_user_maxspeed(id350.0)
        
set_task(0.1"player_glowteam"id)
        
client_cmd(id,"spk ^"fvox/blip^"")
        
ColorChat(idGREEN"^x04[Rambo Mod]^x01 You Respawned!")
        
strip_user_weapons(id)
        
give_item(id"weapon_knife")
        
cs_set_weapon_ammo(give_item(id"weapon_deagle"), 20)
        
cs_set_weapon_ammo(give_item(id"weapon_m249"), 200)
        
cs_set_weapon_ammo(give_item(id"weapon_hegrenade"), 10)
        
cs_set_user_bpammo(idCSW_DEAGLE100)
        
cs_set_user_bpammo(idCSW_M2491000)
    }
}
public 
Event_Ham_Killed(victimattackershouldgib)
{
    new 
attackername[33]
    
get_user_name(attackerattackername32)
    if(
is_user_connected(victim))
    
ColorChat(victimGREEN"^x04[Rambo Mod]^x01 You got owned by^x04 %s"attackername)
    
ExecuteHamB(Ham_CS_RoundRespawnvictim)


public 
player_glowteam(id)
{
    if(
cs_get_user_team(id) == CS_TEAM_CT)
    {
        
set_user_rendering(idkRenderFxGlowShell00255kRenderNormal16)
    }
    else if(
cs_get_user_team(id) == CS_TEAM_T)
    
set_user_rendering(idkRenderFxGlowShell25500kRenderNormal16)
}

public 
plugin_cfg()
{
    
g_iMaxPlayers get_maxplayers()
}

public 
eDeathMsg_HeadShot()
{
    new 
iKiller read_data(1)

    if(
iKiller g_iMaxPlayers)
        return

    new 
iVictim read_data(2)
    if(
iKiller == iVictim)
        return

    if(
g_szKillerSound[0])
        
emit_sound(iKillerCHAN_VOICEg_szKillerSoundVOL_NORMATTN_STATIC0PITCH_NORM)

    if(
g_szVictimSound[0])
        
client_cmd(iVictim"speak %s"g_szVictimSound)

    if(
g_szPlayersSound[0])
    {
        for(new 
id 1id <= g_iMaxPlayersid++)
        {
            if(!
is_user_connected(id))
                continue
            if((
g_szKillerSound[0] && id == iKiller) || (g_szVictimSound[0] && id == iVictim))
                continue
            
client_cmd(id"speak %s"g_szPlayersSound)
        }
    }



grimvh2 05-25-2010 14:02

Re: ExecuteHamB(Ham_CS_RoundRespawn, victim)
 
Add a delay.

FlyingHorse 05-25-2010 14:42

Re: ExecuteHamB(Ham_CS_RoundRespawn, victim)
 
How? im new at coding ..just been doing it for like a week

KadiR 05-25-2010 14:44

Re: ExecuteHamB(Ham_CS_RoundRespawn, victim)
 
How to make a delay? Search? Anyways:

http://www.amxmodx.org/funcwiki.php?...task&go=search

Sylwester 05-25-2010 14:51

Re: ExecuteHamB(Ham_CS_RoundRespawn, victim)
 
Instead of adding delay you can do this:
PHP Code:

RegisterHam(Ham_Killed"player""Event_Ham_Killed"

-->
PHP Code:

RegisterHam(Ham_Killed"player""Event_Ham_Killed"1


wrecked_ 05-25-2010 15:48

Re: ExecuteHamB(Ham_CS_RoundRespawn, victim)
 
Adding on to Sylwester's fix, the fourth parameter for RegisterHam is the post or pre call. If you have it as 0 (default), it will be called on pre (before the actual event happens). If you make it 1, it will be called on post (after the actual event).

You'd use pre for things like superceding on TakeDamage to prevent damage from happening. If you'd tried to supercede in TakeDamage post, nothing would happen, since the damage was already dealt.

There are different uses for each, but for your method, as Sylwester showed you, you need to use post.

ConnorMcLeod 05-25-2010 15:53

Re: ExecuteHamB(Ham_CS_RoundRespawn, victim)
 
Register as post (as already said), or supercede in pre, if you don't want DeathMsg being sent for example.

FlyingHorse 05-26-2010 08:29

Re: ExecuteHamB(Ham_CS_RoundRespawn, victim)
 
Sorry connor.. But could you explain better? .. I'm not a good coder.. im a beginner.. This is the biggest thing ive ever made

drekes 05-26-2010 13:42

Re: ExecuteHamB(Ham_CS_RoundRespawn, victim)
 
@ Connor:
Will supercede in pre block the victim from dying to?

Example:

PHP Code:

#include <amxmodx>
#include <hamsandwich>

public plugin_init()
{
    
RegisterHam(Ham_Killed"player""Ham_Killed_Pre"0)        // Player isn't death yet
    
RegisterHam(Ham_Killed"player""Ham_Killed_Post"1)        // Player is death
    // Other stuff
}

public 
Ham_Killed_Pre(victimattackershouldgib)    // Player isn't death, block it
    
return HAM_SUPERCEDE    // Blocks stuff from happening

public Ham_Killed_Post(victimattackershouldgib)    // Player is death, respawn him    
    
ExecuteHamb(Ham_CS_RoundRespawnvictim)    // Respawns the victim 

if you want a bigger delay use set_task like this:
PHP Code:

#include <amxmodx>
#include <hamsandwich>

public plugin_init()
{
    
RegisterHam(Ham_Killed"player""Ham_Killed_Pre"0)        // Player isn't death yet
    
RegisterHam(Ham_Killed"player""Ham_Killed_Post"1)        // Player is death
    // Other stuff
}

public 
Ham_Killed_Pre(victimattackershouldgib)    // Player isn't death, block it
    
return HAM_SUPERCEDE

public Ham_Killed_Post(victimattackershouldgib)    // Player is death, respawn him    
    
set_task(5.0"respawn"victim)
    
public 
respawn(id)
    
ExecuteHamB(Ham_CS_RoundRespawnid


FlyingHorse 05-26-2010 13:55

Re: ExecuteHamB(Ham_CS_RoundRespawn, victim)
 
solved already .. i made this:
PHP Code:

public Event_Ham_Killed(victimattackershouldgib)
{
    new 
attackername[33]
    
get_user_name(attackerattackername32)
    if(
is_user_connected(victim))
    
set_hudmessage(00255, -1.0, -1.0)
    
show_hudmessage(victim"You got owned by %s"attackername)
    
set_task(1.0"respawn"victim)
}

public 
respawn(victimattackershouldgib)
{
    new 
attackername[33]
    
get_user_name(attackerattackername32)
    
ExecuteHamB(Ham_CS_RoundRespawnvictim)


I added a task to delay with 1 second so u dont respawn instantly when u die.. kinda confusing


All times are GMT -4. The time now is 05:22.

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