AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Respawn bug (https://forums.alliedmods.net/showthread.php?t=107483)

#8 SickneSS 10-27-2009 07:32

Respawn bug
 
1 Attachment(s)
It happens when u switch to spectator.Spec player its respawned,i want to know how to fix that.
So i asked for ur help.

Here is the code

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <colorchat>
#include <hamsandwich>

#define PLUGIN    "Respawn"
#define VERSION    "1.0"
#define AUTHOR    "#8 SickneSS"

/* pCvars */
new enable
new delay
new prefix

/* String */
new szPrefix[32]

/* Boolean */
new bool:respawn[33]

//====================[*REGISTRATIONS*]===========================//
public plugin_init() 
{
    
    
/* Plugin Registration */
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
/* Ham Registrations */
    
RegisterHam(Ham_Spawn"player""Ham_Spawn_player"1)
    
RegisterHam(Ham_Killed"player""Ham_Killed_player"1)
    
    
/* pCvar */
    
enable register_cvar("amx_respawn","1")
    
delay register_cvar("amx_respawn_delay","3")
    
prefix register_cvar("amx_prefix","[AMXX]")
    
    
/* String */
    
get_pcvar_string(prefix,szPrefix,31)
    
    
/* Commands */
    
register_clcmd("say /respawn","cmdRespawn")
    
register_clcmd("say_team /respawn","cmdRespawn")    

}

//====================[*RESPAWN*]===========================//
public client_putinserver(id
{
    
respawn[id] = false
}
//----------------------------------------------------------//
public cleint_disconnect(id
{    
    
respawn[id] = false
}
//----------------------------------------------------------//
public cmdRespawn(id
{
        
    if(
get_pcvar_num(enable) == 1)
    {
        if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR
        {
            
ColorChat(id,GREEN,"%s^x01 This command is disabled for spectators.",szPrefix)
        }
            
        if(
cs_get_user_team(id) == CS_TEAM_T || cs_get_user_team(id) == CS_TEAM_CT
        {
            
respawn[id] = !respawn[id]
            
ColorChat(idGREEN,"%s^x01 You have been %sable your respawn.",szPrefix,respawn[id] ? "en" "dis")
            
            if(!
is_user_alive(id) || respawn[id]) 
            {
                
set_task(get_pcvar_float(delay),"cmdRespawns",id)
            }
        }
    }    
    return 
PLUGIN_HANDLED
}
//----------------------------------------------------------//
public Ham_Killed_player(id
{
        
    if(
get_pcvar_num(enable) == 1)
    {
        if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR
        {
            
respawn[id] = false
        
}
        
        if(
respawn[id])
        {
            
ColorChat(idGREEN,"%s^x01 You have respawn in^x03 %d^x01 seconds.",szPrefix,get_pcvar_num(delay))
            
ColorChat(idGREEN,"%s^x01 To disable your respawn,type^x03 /respawn^x01.",szPrefix)
            
set_task(get_pcvar_float(delay),"cmdRespawns",id)
        }
        else
        {
            
ColorChat(idGREEN,"%s^x01 To enable your respawn,type^x03 /respawn^x01.",szPrefix)
            return 
HAM_IGNORED
        
}
    }
    return 
HAM_IGNORED
}
//----------------------------------------------------------//
public Ham_Spawn_player(id
{
    if(
is_user_alive(id))    
    
remove_task(id)
}
//----------------------------------------------------------//
public cmdRespawns(id
{
    if(!
is_user_alive(id)) 
    
ExecuteHamB(Ham_CS_RoundRespawn,id)


I leave u a demo with ilustration of the bug.

Sorry for my bad english,im from Argentina.

lazarev 10-27-2009 13:07

Re: Respawn bug
 
part from my code:
PHP Code:

public plugin_init() { 
 
RegisterHam(Ham_Spawn"player" "HamPlayerSpawn"1
 
RegisterHam(Ham_Killed"player""HamPlayerKilled",  1
 } 

 public 
HamPlayerSpawn(id
 {    
    
GiveItems(id
    
g_bGodmode[id] = true 
    gPlayerAlive
[id] = is_user_alive(id
    
set_user_godmode(id1
 } 

 public 
HamPlayerKilled(id
 { 
    if(
ExecuteHamB(Ham_IsPlayerid)) 
    
CmdRespawn(id

 } 

 public 
CmdRespawn(id
 { 
    new 
CsTeams:team cs_get_user_team(id
    if (
team == CS_TEAM_SPECTATOR
    { 
    return 
PLUGIN_HANDLED 
    

    else 
    { 
    
ExecuteHamB(Ham_CS_RoundRespawn,id
    return 
PLUGIN_HANDLED 
 



Alucard^ 10-27-2009 13:14

Re: Respawn bug
 
Emm, I don't know but maybe this work:

PHP Code:

public cmdRespawns(id
{
    if(
is_user_alive(id) || cs_get_user_team(id) == CS_TEAM_SPECTATOR)
        return 
PLUGIN_HANDLED
    
    ExecuteHamB
(Ham_CS_RoundRespawn,id)




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

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