AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Is this the right way? (https://forums.alliedmods.net/showthread.php?t=188421)

bLacK-bLooD 06-26-2012 06:27

Is this the right way?
 
PHP Code:

#include <amxmodx>
#include <hamsandwich>

public plugin_init(){
   
register_plugin("RESPAWN""1.0""Kinnekt")
   
register_event("DeathMsg""hook_death""a")
   
register_clcmd("say /respawn""res")
}

public 
hook_death(){
   new 
victim read_data(2)
   
   if(
get_user_team(victim) == 2)
      
set_task(0.5"res"victim)
}

public 
client_putinserver(id)
{
   if( !
is_user_alive(id) || !(CS_TEAM_T <= cs_get_user_team(id) <= CS_TEAM_CT) )
      
set_task(0.5"res"id)
   
   return 
PLUGIN_CONTINUE
}

public 
res(id){
   if(!
is_user_connected(id))
      return 
PLUGIN_HANDLED
   
   ExecuteHamB
(Ham_CS_RoundRespawnid)
   
   return 
PLUGIN_CONTINUE



jimaway 06-26-2012 07:06

Re: Is this the right way?
 
you should add check if player is in a team (you dont want alive spectators running around dont you?)
also instead of client_putinserver hook jointeam command or something like that

bLacK-bLooD 06-26-2012 07:37

Re: Is this the right way?
 
Better?

jimaway 06-26-2012 07:51

Re: Is this the right way?
 
not rly, you still dont check the team in death event, and player will never be in a team in client_putinserver.
put the check just before respawning player and replace client_putinserver with jointeam command hook

<VeCo> 06-26-2012 08:48

Re: Is this the right way?
 
It's better to hook the joinclass command.

bLacK-bLooD 06-26-2012 08:57

Re: Is this the right way?
 
Problem solved.

It should have looked like this :

PHP Code:

#include <amxmodx>
#include <hamsandwich>

public plugin_init(){
   
register_plugin("RESPAWN""1.0""Kinnekt")
   
register_event("DeathMsg""hook_death""a")
   
register_clcmd("say /respawn""cl_cmd")
}

public 
cl_cmd(id) {
   if(
is_user_alive(id)) {
      
client_print(idprint_chat"You must be dead to use this command !")
      return 
PLUGIN_HANDLED
   
}

   
set_task(1.0"res"id)

   return 
PLUGIN_CONTINUE
}

public 
hook_death(){
   new 
victim read_data(2)
   
   
set_task(1.0"res"victim)
}

public 
client_putinserver(id) {
   if(
is_user_alive(id))
      return 
PLUGIN_HANDLED

   set_task
(2.5"res"id)

   return 
PLUGIN_CONTINUE
}

public 
res(id){   
   
ExecuteHamB(Ham_CS_RoundRespawnid)
   
   return 
PLUGIN_CONTINUE



jimaway 06-26-2012 10:35

Re: Is this the right way?
 
and ur still not checking players team... try to connect and join spectator, or just type this in console while in game: kill;jointeam 6

claudiuhks 06-26-2012 10:48

Re: Is this the right way?
 
Code:
#include < amxmodx > #include < fakemeta > public plugin_init( )   set_task( 2.0, "TaskCheckForDeadPlayers", .flags = "b" ); public TaskCheckForDeadPlayers( ) {   static iPlayers[ 32 ], iNum, i, cModel[ 32 ], iTeam;   get_players( iPlayers, iNum, "b" );   if( iNum )   {     for( i = 0; i < iNum; i++ )     {       if( pev_valid( iPlayers[ i ] ) == 2 /* Supposed to prevent any crashes */ )       {           iTeam = get_pdata_int( iPlayers[ i ], 114 );           pev( iPlayers[ i ], pev_model, cModel, 31 );           if( iTeam > 0 && iTeam < 3 && ( -1 == containi( cModel, "player.mdl" ) ) /* Makes sure he chosed a model */ )             dllfunc( DLLFunc_Spawn, iPlayers[ i ] );       }     }   } }

bLacK-bLooD 06-26-2012 11:43

Re: Is this the right way?
 
Quote:

Originally Posted by jimaway (Post 1736493)
and ur still not checking players team... try to connect and join spectator, or just type this in console while in game: kill;jointeam 6

I have team manager by exolent. It's no need to check player's team since that plugin is active.

@claudiuhks Again, it's no need to check if a player has chosen a model, because when he connects to the server, he is automatically transfered to CT.

Anyway, thanks for help guys.


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

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