AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Simple respawning, bodies does not disappear (https://forums.alliedmods.net/showthread.php?t=95817)

naven 06-27-2009 14:31

Simple respawning, bodies does not disappear
 
Hi,
I am using this code for respawning(works fine):
Code:

public DeathMsg()
{
    new victim;
    victim = read_data(2)
    if (get_cvar_num("amx_respawn") > 0)
    set_task(1.0, "respawn_player", victim + 483)
}
public respawn_player(id)
{
    id -= 483;
    if (!is_user_connected(id) || is_user_alive(id) || cs_get_user_team(id) == CS_TEAM_SPECTATOR)        return;
    set_pev(id, pev_deadflag, DEAD_RESPAWNABLE)
    dllfunc(DLLFunc_Think, id)
    if (is_user_bot(id) && pev(id, pev_deadflag) == DEAD_RESPAWNABLE)
    {
    dllfunc(DLLFunc_Spawn, id)
    }
   
}
public sayrespawn(gracz)
{
    if (!is_user_connected(gracz) || cs_get_user_team(gracz) == CS_TEAM_SPECTATOR)        return PLUGIN_HANDLED;
    set_pev(gracz, pev_deadflag, DEAD_RESPAWNABLE)
    dllfunc(DLLFunc_Think, gracz)
    dllfunc(DLLFunc_Spawn, gracz)
    return PLUGIN_HANDLED;
}

("gracz" is id)
But I want bodies to disappear just right after death, at the moment some maps looks like this: http://iv.pl/images/f8kvcr040qy9ha48y.jpg
Check out fps- not really good fps for surf
Note: I need this for my surf mod, and I want to keep as many fps as I can

vato loco [GE-S] 06-27-2009 16:53

Re: Simple respawning, bodies does not disappear
 
you can test this respawn plugin
should be ok for surf maps
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <cstrike>
#include <fakemeta>

#define PLUGIN "Respawn"
#define VERSION "1.0"
#define AUTHOR "Author"

new g_sf_respawn

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /respawn","cmd_respawn")
    
g_sf_respawn register_cvar("sf_respawn","1")
    
register_event("DeathMsg","death_event","a")
}

public 
cmd_respawn(id)
{    
    if(
get_pcvar_num(g_sf_respawn))
    {
        new 
CsTeams:Team cs_get_user_team(id)
        
        if(
Team == CS_TEAM_T || Team == CS_TEAM_CT)
        {
            
set_task(0.5,"spawn",id)
        }
    }
    return 
PLUGIN_CONTINUE
}

public 
death_event()    
{
    new 
victim read_data(2)
    
set_task(0.5,"spawn",victim)
}

public 
spawn(id)
{
    if(
get_pcvar_num(g_sf_respawn))
    {    
        new 
CsTeams:Team cs_get_user_team(id)
        
        if(
is_user_connected(id) && (Team == CS_TEAM_T || Team == CS_TEAM_CT))
        {
            
dllfunc(DLLFunc_Spawn,id)
        }
    }
    return 
PLUGIN_CONTINUE



hleV 06-28-2009 05:48

Re: Simple respawning, bodies does not disappear
 
I remember that when spawning dead player with Ham, his body sometimes disappears and sometimes not. Does it really never disappear with the way N A V E N provided?

naven 06-28-2009 07:43

Re: Simple respawning, bodies does not disappear
 
When I play alone, bodies disappear after maybe 10 seconds(I look when my body falls down... i do not want that too), but when it's on a server with more people some bodies never disappear, makes crash and low fps, not really wanted on surf.
P.S. I prefer saying just naven to me

naven 06-29-2009 09:51

Re: Simple respawning, bodies does not disappear
 
Could anyone fix my code?


All times are GMT -4. The time now is 15:37.

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