AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [HLDM] Send player to Spectator on join (https://forums.alliedmods.net/showthread.php?t=315559)

gabuch2 04-13-2019 11:06

[HLDM] Send player to Spectator on join
 
Hello, I try to send a player to spectator when he joins, however when I do so they get sent into a "limbo" state, unable to do anything. (origin 0,0,0 - camera tilted as if they were dead)

Code:
public player_spawn_pre(id) {     if(g_bRoundStarted || get_playersnum() < 2)     {         hl_set_user_spectator(id, true);         return HAM_SUPERCEDE;     }     return HAM_IGNORED; }

If I send them to spectator again when they are killed (assuming they spawned normally), they go to spectator without problems.
Code:
public player_killed_post(id) {     [...]     if (g_bRoundStarted)         set_task(5.0, "send_player_to_spec", id + TASK_SENDVICTIMTOSPEC); }

Code:
public send_player_to_spec(taskid) {     new id = taskid - TASK_SENDVICTIMTOSPEC;     if (is_user_connected(id))     {         if (!is_user_alive(id) || is_user_bot(id))             hl_set_user_spectator(id, true);     } }

What's the cause of this?

EDIT: Fixed it myself by moving this operation to a task set on post


All times are GMT -4. The time now is 07:24.

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