AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   client_putinserver - respawn problem/explanation (https://forums.alliedmods.net/showthread.php?t=294027)

xTr3m3r 02-18-2017 07:22

client_putinserver - respawn problem/explanation
 
Its me again! (apparently)

So Im trying to add a task when a player joins my server to be automatically spawned after a few seconds but it seems that it bugs the whole hidenseek plugin and the plugins on the server doesnt work as supposed as well.

PHP Code:

public client_putinserver(plr)
{
    
g_bConnected[plr] = true;
    
g_bAlive[plr] = false;
    
g_bFirstSpawn[plr] = false;
    
        
set_task(5.0"TaskRespawn"plr); //this is what i added

    
return PLUGIN_CONTINUE;


Can somebody explain why I can't use set_task in client_putinserver and how can I make something similar to this? Thanks!

edon1337 02-18-2017 07:27

Re: client_putinserver - respawn problem/explanation
 
We can't help if you don't explain what's wrong.

xTr3m3r 02-18-2017 07:35

Re: client_putinserver - respawn problem/explanation
 
It doesnt respawn the player at all and the blocks from the blockmaker im using are just solid and they do nothing. When I remove the set_task everything works just fine. :) The TaskRespawn is working as supposed because Im using it when a player dies or gets killed so its not from it as you can see below:

PHP Code:

public TaskRespawn(plr)
{
    
// thanks GHW_Chronic & MeRcyLeZZ
    
set_pev(plrpev_deadflagDEAD_RESPAWNABLE);
    
dllfunc(DLLFunc_Thinkplr);


I was just wondering why wouldn't the task spawn the player when he gets put in to my server and how should I do that?

Natsheh 02-18-2017 07:50

Re: client_putinserver - respawn problem/explanation
 
PHP Code:

 #include <amxmodx>
#include <hamsandwich>

#define TASK_RESPAWN 124253
#define TEAM_T      1
#define TEAM_CT    2

#define fm_get_user_team(%1)      ((get_user_team(%1)<0) ? 3:get_user_team(%1))

public client_putinserver(id)
{
       
remove_task(TASK_RESPAWN+id)
       
set_task(5.0"task_respawn"TASK_RESPAWN+id__"b")
}

public 
task_respawn(const taskid)
{
       new 
id taskid TASK_RESPAWN;
       if(!
is_user_connected(id)) remove_task(taskid)
       else if((
1<<fm_get_user_team(id)) & ((1<<TEAM_CT)|(1<<TEAM_T)))
       {
                 
client_cmd(id"joinclass 5");
                 
ExecuteHamB(Ham_CS_RoundRespawnid)
                 
remove_task(taskid)
       }



edon1337 02-18-2017 08:18

Re: client_putinserver - respawn problem/explanation
 
Quote:

Originally Posted by Natsheh (Post 2496326)
PHP Code:

#include <hamsandwich>

#define TASK_RESPAWN 124253
#define TEAM_T      1
#define TEAM_CT    2

public client_putinserver(id)
{
       
remove_task(TASK_RESPAWN+id)
       
set_task(5.0"task_respawn"TASK_RESPAWN+id__"b")
}

public 
task_respawn(taskid)
{
       new 
id taskid TASK_RESPAWN;
       if((
1<<get_user_team(id)) & ((1<<TEAM_CT)|(1<<TEAM_T))
       {
                 
client_cmd(id"joinclass 5");
                 
ExecuteHamB(Ham_CS_RoundRespawnid)
                 
remove_task(taskid)
       }



I'd love to see you compiling that. Also you can just use 'id' for the task id.

Natsheh 02-18-2017 08:46

Re: client_putinserver - respawn problem/explanation
 
Quote:

Originally Posted by edon1337 (Post 2496333)
I'd love to see you compiling that. Also you can just use 'id' for the task id.

btw it compiles fine ... it was a sample..

if it dosent compile for you its you problem that youre too stupid to add #include <amxmodx> in the script...

edon1337 02-18-2017 09:20

Re: client_putinserver - respawn problem/explanation
 
Quote:

Originally Posted by Natsheh (Post 2496337)
youre too stupid to add #include <amxmodx> in the script...

Sherlock, you're so smart you forgot to include the main module. I was pointing that out.

PRoSToTeM@ 02-18-2017 09:22

Re: client_putinserver - respawn problem/explanation
 
Quote:

Originally Posted by Natsheh (Post 2496326)
PHP Code:

#include <amxmodx>
#include <hamsandwich>

#define TASK_RESPAWN 124253
#define TEAM_T      1
#define TEAM_CT    2

public client_putinserver(id)
{
       
remove_task(TASK_RESPAWN+id)
       
set_task(5.0"task_respawn"TASK_RESPAWN+id__"b")
}

public 
task_respawn(const taskid)
{
       new 
id taskid TASK_RESPAWN;
       if((
1<<get_user_team(id)) & ((1<<TEAM_CT)|(1<<TEAM_T))
       {
                 
client_cmd(id"joinclass 5");
                 
ExecuteHamB(Ham_CS_RoundRespawnid)
                 
remove_task(taskid)
       }



Where is remove_task in client_disconnect?

jimaway 02-18-2017 09:23

Re: client_putinserver - respawn problem/explanation
 
Quote:

Originally Posted by Natsheh (Post 2496326)
PHP Code:


       
if((1<<get_user_team(id)) & ((1<<TEAM_CT)|(1<<TEAM_T)) 


why are you overly complicating this? when get_user_team() will return -1 this will have unforeseen consequences whereas a simple (1 <= get_user_team(id) <= 2) will have no problems

Natsheh 02-18-2017 10:24

Re: client_putinserver - respawn problem/explanation
 
Quote:

Originally Posted by PRoSToTeM@ (Post 2496344)
Where is remove_task in client_disconnect?

no need ... i just edited the code and checked if user isnt connected...

Quote:

Originally Posted by jimaway (Post 2496345)
why are you overly complicating this? when get_user_team() will return -1 this will have unforeseen consequences whereas a simple (1 <= get_user_team(id) <= 2) will have no problems


youre right, i fixed it by adding fm_get_user_team..


All times are GMT -4. The time now is 21:01.

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