Raised This Month: $ Target: $400
 0% 

Respawn bug


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
#8 SickneSS
BANNED
Join Date: Sep 2008
Location: Here
Old 10-27-2009 , 07:32   Respawn bug
Reply With Quote #1

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.
Attached Files
File Type: zip demo.zip (249.1 KB, 73 views)

Last edited by #8 SickneSS; 10-27-2009 at 09:15.
#8 SickneSS is offline
Send a message via MSN to #8 SickneSS Send a message via Skype™ to #8 SickneSS
lazarev
Veteran Member
Join Date: Sep 2008
Old 10-27-2009 , 13:07   Re: Respawn bug
Reply With Quote #2

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 
 

lazarev is offline
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 10-27-2009 , 13:14   Re: Respawn bug
Reply With Quote #3

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)

__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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