AlliedModders

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

vamppa 05-03-2012 13:17

is_user_spectate
 
is there a way to check when the user is spectate?


the purpose:
for example if it where to exist
PHP Code:

if(!is_user_spectate id ) ) 


<VeCo> 05-03-2012 13:18

Re: is_user_spectate
 
PHP Code:

cs_get_user_team(id) != CS_TEAM_SPECTATOR 

?

vamppa 05-03-2012 13:21

Re: is_user_spectate
 
for a Non-counterstrike mod.

claudiuhks 05-03-2012 13:23

Re: is_user_spectate
 
PHP Code:

// EITHER
#define is_user_spectator( %0 ) ( get_user_team( %0 ) == 3 )

// OR
boolis_user_spectatoriPlayer )
  return 
get_user_teamiPlayer ) == 3

Edit:

Or, if you want to know whether user is spectating someone:

PHP Code:

#define INVALID_PLAYER -1

get_user_spectating_targetiPlayer )
{
  static 
i;

  if( !
is_user_aliveiPlayer ) && is_user_connected( ( peviPlayerpev_iuser1 ) ) ) )
    return 
i;

  return 
INVALID_PLAYER;


Then, you can check:

PHP Code:

if( is_user_spectatoriClient ) && get_user_spectating_targetiClient ) != INVALID_PLAYER )
{
  
// His team is spectator and he is spectating a valid target
}

if( 
is_user_spectatoriClient ) )
{
  
// His team is spectator
}

if( 
get_user_spectating_targetiClient ) != INVALID_PLAYER )
{
  
// His team may be Red, Blue or Spectator and he is spectating a valid target



Bilal Pro 05-03-2012 13:48

Re: is_user_spectate
 
Quote:

Originally Posted by claudiuhks (Post 1701289)
PHP Code:

// EITHER
#if !defined is_user_spectator
  #define is_user_spectator( %0 ) ( get_user_team( %0 ) == 3 )
#endif

// OR
boolis_user_spectatoriPlayer )
  return 
get_user_teamiPlayer ) == 3



i think 3 wont work, 0 = spectator?

Napoleon_be 05-03-2012 13:57

Re: is_user_spectate
 
Quote:

Originally Posted by Bilal Pro (Post 1701300)
i think 3 wont work, 0 = spectator?

Think before posting.

Devil259 05-03-2012 14:05

Re: is_user_spectate
 
0 = unassigned
1 = terrorist
2 = counter-terrorist
3 = spectator

mottzi 05-03-2012 14:12

Re: is_user_spectate
 
I think he is asking about how to get wheter a player is spectating someone. If so: Check if player is dead AND if get_user_aiming returns a Player

Exolent[jNr] 05-03-2012 15:12

Re: is_user_spectate
 
Code:
stock GetSpectatedPlayer(id) {     if( !is_user_alive(id)     && ((1 << pev(id, pev_iuser1)) & ((1 << 1)|(1 << 2)|(1 << 4))) )     {         new player = pev(id, pev_iuser2);         if( is_user_alive(player) )         {             return player;         }     }         return id; } stock bool:IsUserSpectatingPlayer(spectater, player) {     return (GetSpectatedPlayer(spectater) == player); } stock bool:IsUserSpectating(id) {     return (GetSpectatedPlayer(id) != id); }

mottzi 05-03-2012 15:55

Re: is_user_spectate
 
die exolent :) explain me that please:
GetSpectatedPlayer()


All times are GMT -4. The time now is 00:31.

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