Raised This Month: $ Target: $400
 0% 

Error Respawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bello2
Senior Member
Join Date: Jun 2010
Location: Venezuela
Old 07-08-2010 , 10:08   Error Respawn
Reply With Quote #1

The error that this cause is that: When respawning a player there are times when it was as a spectator, Instead of reviving
The method that i'm using is this:

PHP Code:
ExecuteHamBHam_CS_RoundRespawnid ); 
To try to solve the problem i have done this small code:

PHP Code:
if (!can_spawn(id)) return;
{
     
//revive
}

stock can_spawn(id)
{
   if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED || is_user_alive(id))
      return 
false
    
   
return true

The problem is that it is not working and moreover i strip this error:

Code:
L 07/07/2010 - 23:53:17: Start of error session.
L 07/07/2010 - 23:53:17: Info (map "de_train") (file "addons/amxmodx/logs/error_20100707.log")
L 07/07/2010 - 23:53:17: [CSTRIKE] Invalid player 9
L 07/07/2010 - 23:53:17: [AMXX] Displaying debug trace (plugin "respawn.amxx")
L 07/07/2010 - 23:53:17: [AMXX] Run time error 10: native error (native "cs_get_user_team")
L 07/07/2010 - 23:53:17: [AMXX]    [0] deathmatch.sma::can_spawn (line 51)
L 07/07/2010 - 23:53:17: [AMXX]    [1] deathmatch.sma::revive (line 35)

Last edited by Bello2; 07-08-2010 at 12:25.
Bello2 is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 07-08-2010 , 12:04   Re: Error Respawn
Reply With Quote #2

try checking if he is connected

PHP Code:
stock can_spawn(id)
{
   if( !
is_user_connected(id) || cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED ||  is_user_alive(id))
      return 
false
    
   
return true

__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 07-08-2010 at 12:06.
drekes is offline
Send a message via MSN to drekes
Bello2
Senior Member
Join Date: Jun 2010
Location: Venezuela
Old 07-08-2010 , 12:12   Re: Error Respawn
Reply With Quote #3

Quote:
Originally Posted by drekes View Post
try checking if he is connected

PHP Code:
stock can_spawn(id)
{
   if( !
is_user_connected(id) || cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED ||  is_user_alive(id))
      return 
false
    
   
return true

Ok perfect.

a question:

That stock worked better?

1.
PHP Code:
stock can_spawn(id)
{
   if( !
is_user_connected(id) || cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED ||  is_user_alive(id))
      return 
false
    
   
return true

2.
PHP Code:
stock can_spawn(id) return ( !is_user_connected(id) && (cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED || is_user_alive(id))) ? false true 
Bello2 is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 07-08-2010 , 12:35   Re: Error Respawn
Reply With Quote #4

i think it's the second one is a little bit better. Not sure though and it won't matter much.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 07-08-2010 , 12:36   Re: Error Respawn
Reply With Quote #5

Even better a macro:
PHP Code:
#define can_spawn(%0) !(( !is_user_connected((%0) && (cs_get_user_team((%0) == CS_TEAM_SPECTATOR || cs_get_user_team((%0) == CS_TEAM_UNASSIGNED || is_user_alive((%0)))) 
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 07-08-2010 , 12:45   Re: Error Respawn
Reply With Quote #6

Quote:
Originally Posted by ot_207 View Post
Even better a macro:
PHP Code:
#define can_spawn(%0) !(( !is_user_connected((%0) && (cs_get_user_team((%0) == CS_TEAM_SPECTATOR || cs_get_user_team((%0) == CS_TEAM_UNASSIGNED || is_user_alive((%0)))) 
So macro's are better then stocks?
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-08-2010 , 13:05   Re: Error Respawn
Reply With Quote #7

Bello2, show the code where you call can_spawn, i guess you call it at a wrong place.
You shouldn't need to check if player is connected.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Bello2
Senior Member
Join Date: Jun 2010
Location: Venezuela
Old 07-08-2010 , 13:25   Re: Error Respawn
Reply With Quote #8

Quote:
Originally Posted by ot_207 View Post
Even better a macro:
PHP Code:
#define can_spawn(%0) !(( !is_user_connected((%0) && (cs_get_user_team((%0) == CS_TEAM_SPECTATOR || cs_get_user_team((%0) == CS_TEAM_UNASSIGNED || is_user_alive((%0)))) 
This is the code:

PHP Code:
public plugin_init() 

    
register_plugin("respawn","1.0","Bello2")
    
register_event("DeathMsg","death","a"
    
register_cvar("dm_enabled","0")
    
register_cvar("dm_protection","1")
    
register_cvar("dm_protection_time","3")
}

public 
death() 

    if (
get_cvar_num("dm_enabled"))
    {
        new 
id read_data(2)
        
set_task(0.5,"revive",id)
    }
}

public 
revive(id)
{
    if (!
can_spawn(id)) return;
    
    
ExecuteHamBHam_CS_RoundRespawnid );
    
    if (
get_cvar_num("dm_protection"))
    {
        new 
Float:ProtectTime get_cvar_float("dm_protection_time")
        
        
set_user_godmodeid);
        
set_taskProtectTime "stopprotect"id );
    }
}

stock can_spawn(id)
{
   if( !
is_user_connected(id) && ( cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED || is_user_alive(id) ) )
      return 
false
    
   
return true
}

public 
stopprotect(id)
{
    if( 
is_user_aliveid ) )
        
set_user_godmodeid);

@Ot, as be the code applying your macro?

@Connor that is the code
Bello2 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-08-2010 , 13:54   Re: Error Respawn
Reply With Quote #9

Ok, then you have to check if player is connected du to the delayed respawn.
Little optimization on code, so you use only 1 time the team :
PHP Code:
stock can_spawn(id)
{
    if(    
is_user_connected(id)
    &&    !
is_user_alive(id)
    &&    (
CS_TEAM_T <= cs_get_user_team(id) <= CS_TEAM_CT)    )
    {
        return 
true
    
}
    return 
false

or

PHP Code:
stock can_spawn(id)
{
    return ( 
is_user_connected(id) && !is_user_alive(id) && (CS_TEAM_T <= cs_get_user_team(id) <= CS_TEAM_CT) )

or

PHP Code:
#define can_respawn(%1)    ( is_user_connected(%0) && !is_user_alive(%0) && (CS_TEAM_T <= cs_get_user_team(%0) <= CS_TEAM_CT) ) 
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Bello2
Senior Member
Join Date: Jun 2010
Location: Venezuela
Old 07-08-2010 , 14:03   Re: Error Respawn
Reply With Quote #10

Ok then with the macro be in this way:

PHP Code:
#define can_respawn(%1)    ( is_user_connected(%0) && !is_user_alive(%0) && (CS_TEAM_T <= cs_get_user_team(%0) <= CS_TEAM_CT) )  

public plugin_init() 

    
register_plugin("respawn","1.0","Bello2")
    
register_event("DeathMsg","death","a"
    
register_cvar("dm_enabled","0")
    
register_cvar("dm_protection","1")
    
register_cvar("dm_protection_time","3")
}

public 
death() 

    if (
get_cvar_num("dm_enabled"))
    {
        new 
id read_data(2)
        
set_task(0.5,"revive",id)
    }
}

public 
revive(id)
{
    if (!
can_respawn(id)) return;
    
    
ExecuteHamBHam_CS_RoundRespawnid );
    
    if (
get_cvar_num("dm_protection"))
    {
        new 
Float:ProtectTime get_cvar_float("dm_protection_time")
        
        
set_user_godmodeid);
        
set_taskProtectTime "stopprotect"id );
    }
}

public 
stopprotect(id)
{
    if( 
is_user_aliveid ) )
        
set_user_godmodeid);

Or this evil? What i want to know is how I can call the macro, because i do not have much experience with the macros...

Last edited by Bello2; 07-08-2010 at 17:33.
Bello2 is offline
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 07:15.


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