AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   respawn mod? (https://forums.alliedmods.net/showthread.php?t=126021)

liryck 05-04-2010 15:43

respawn mod?
 
i all im trying to make a simple respawn the thing is that sometimes when the player respawn the crossair gone with the hp, shield and round timer.

you just can't see it?

this is my code maybe u will say that's a ugly code etc etc but well i do my best if you could fix it or post a more simple code that do what im trying be welcome

PHP Code:

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
//RegisterHam( Ham_Killed , "player", "HAM_Killed" )
    
    //gmsgStatusIcon = get_user_msgid("StatusIcon");
    
    
g_pEnabled register_cvar("dm_enabled","0")
    
g_pProtection register_cvar("dm_protection","1")
    
g_pProtectionTime register_cvar("dm_protection_time","3")
    
    
g_msgid_ClCorpse get_user_msgid("ClCorpse")
    
    
register_event"TeamInfo""join_team""a");
    
register_event("DeathMsg""death_mes""a");
    
register_event("StatusIcon","GotBomb","be","1=1","1=2","2=c4");
}

public 
client_connect(id)
{
    
g_connected[id] = false
}

public 
spawnagain(id)
{
    
//Make sure he didn't disconnect in the 0.5 seconds that have passed.
    
if(is_user_connected(id))
    {
        
//Spawn player
    
spawn(id)
    
set_msg_block(g_msgid_ClCorpseBLOCK_ONCE)
    
    if ( 
get_pcvar_numg_pProtection ) == )
     {
        
set_user_godmode(id,1)
        new 
Float:protect get_pcvar_floatg_pProtectionTime )
        
set_task(protect,"stopprotect",id)
        
set_task(1.1,"giveweapon",id)
    }

        
//After 1.0 the player will be spawned fully and you can mess with the ent (give weapons etc)
        //set_task(1.0,"player_fully_spawned",id)
    
}
}

public 
giveweapon(id)
{
    if ( 
get_user_teamid ) == 
    { 
        
give_item(id,"weapon_knife"
        
give_item(id,"weapon_glock18"
        
give_item(id,"ammo_9mm"
        
give_item(id,"ammo_9mm"
        
cs_set_user_money(id,16000)
    } 
    else 
    { 
        
give_item(id,"weapon_knife"
        
give_item(id,"weapon_usp"
        
give_item(id,"ammo_45acp"
        
give_item(id,"ammo_45acp"
        
cs_set_user_money(id,16000)
    } 
}

public 
stopprotect(id)
{
    if(
is_user_alive(id))
    
set_user_godmode(id)
}

public 
check_alive(id)
{
    if(!
get_pcvar_num(g_pEnabled) || !is_user_connected(id) || is_user_alive(id)){
        return;
    }
    else
    {
        if(!
is_user_alive(id))
        {
            
set_task(1.0,"spawnagain",id)
        }
    }
}

public 
death_mes()
{
    new 
victim read_data(2);
    
    if(
get_pcvar_num(g_pEnabled))
    {
        
set_task(1.0,"check_alive",victim)
    }
    return 
PLUGIN_HANDLED;
}

public 
join_team()
{    
    new 
id read_data(1)
    static 
user_team[32]

    
read_data(2user_team31)    
    
    if(!
is_user_connected(id))
        return 
PLUGIN_CONTINUE    
    
    
switch(user_team[0])
    {
        case 
'C':  
        {        
        if(
g_connected[id] == false && get_pcvar_num(g_pEnabled)){
            
            
set_task(6.0,"check_alive",id)
            
g_connected[id] = true
        
}     
        }
            
        case 
'T'
        {
                if(
g_connected[id] == false && get_pcvar_num(g_pEnabled)){
            
            
set_task(6.0,"check_alive",id)
            
g_connected[id] = true
        
}    
        }        
    }
    return 
PLUGIN_CONTINUE
    



wrecked_ 05-04-2010 15:46

Re: respawn mod?
 
Use
Code:
ExecuteHamB( Ham_CS_RoundRespawn, 1 )

The current function you're using (spawn()) is not guarunteed to work, unless you correctly use the "fix".

If you're really bent on using spawn(), you can follow Avalanche's instructions from the AMXX Doc;
Quote:

Originally Posted by Avalanche @ AMXX Doc
People have had trouble getting this to work, the below seems to be the "correct" way to do it without any bugs:
Code:
public soandso(id) {    spawn(id);    set_task(0.5,"spawnagain",id); } public spawnagain(id) {    spawn(id); }
You can play around with the 0.5 time.

In your version, you're setting a task for spawnagain, but you're not calling the actual spawn function beforehand.

grimvh2 05-04-2010 16:22

Re: respawn mod?
 
I suggest to use ham to hook the killed event and to respawn him. much better and easyer

Jelle 05-04-2010 18:54

Re: respawn mod?
 
PHP Code:

register_event("DeathMsg""death_mes""a")

public 
death_mes(id)
{
    
ExecuteHamBHam_CS_RoundRespawn)


Something like that?

drekes 05-04-2010 20:05

Re: respawn mod?
 
Quote:

Originally Posted by Jelle (Post 1170772)
PHP Code:

register_event("DeathMsg""death_mes""a")

public 
death_mes(id)
{
    
ExecuteHamBHam_CS_RoundRespawn)


Something like that?

PHP Code:

register_event("DeathMsg""death_mes""a")

public 
death_mes()
{
    new 
victim read_data(2)

    
ExecuteHamB(Ham_CS_RoundRespawnvictim)


I think it should be something like this

wrecked_ 05-04-2010 20:36

Re: respawn mod?
 
Yep, what drekes said.

drekes 05-04-2010 20:43

Re: respawn mod?
 
Quote:

Originally Posted by wrecked_ (Post 1170907)
Yep, what drekes said.

w00t, i'm getting smarter:mrgreen:

grimvh2 05-05-2010 07:25

Re: respawn mod?
 
Quote:

Originally Posted by drekes (Post 1170866)
PHP Code:

register_event("DeathMsg""death_mes""a")

public 
death_mes()
{
    new 
victim read_data(2)
    
    if(
is_user_connected(victim))
        
ExecuteHamB(Ham_CS_RoundRespawnvictim)


I think it should be something like this



All times are GMT -4. The time now is 03:39.

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