AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Prevent player from spawning (just ignore him) (https://forums.alliedmods.net/showthread.php?t=318744)

MihailoZ 09-18-2019 05:56

Prevent player from spawning (just ignore him)
 
Hello,

if a player joins the round after 40 seconds have passed, can he just be ignored and his spawning prevented? No messages, no 3rd person camera showing his death?


Thank you.

edon1337 09-18-2019 06:05

Re: Prevent player from spawning (just ignore him)
 
Return HAM_SUPERCEDE on Ham_Spawn (pre).

MihailoZ 09-18-2019 06:07

Re: Prevent player from spawning (just ignore him)
 
Quote:

Originally Posted by edon1337 (Post 2667393)
Return HAM_SUPERCEDE on Ham_Spawn (pre).

Thank you. One more question:

How to count 40 seconds?

JocAnis 09-18-2019 06:13

Re: Prevent player from spawning (just ignore him)
 
Register new round. Add there global variable (float): g_fRoundTime = get_gametime()

On spawn check if g_fRoundTime >= 40.0

MihailoZ 09-18-2019 06:14

Re: Prevent player from spawning (just ignore him)
 
Quote:

Originally Posted by JocAnis (Post 2667395)
Register new round. Add there global variable (float): g_fRoundTime = get_gametime()

On spawn check if g_fRoundTime >= 40.0


Thank you Sir. I will try to make something out of this code. I will post an update soon. :)

OciXCrom 09-18-2019 07:35

Re: Prevent player from spawning (just ignore him)
 
Quote:

Originally Posted by JocAnis (Post 2667395)
Register new round. Add there global variable (float): g_fRoundTime = get_gametime()

On spawn check if g_fRoundTime >= 40.0

That time is counted from the start of the map, not round. He can use get_gametime(), but he will need to compare the stored value with a new get_gametime() when the player joins and check if the difference between them is >= 40.

MihailoZ 09-18-2019 07:44

Re: Prevent player from spawning (just ignore him)
 
Quote:

Originally Posted by OciXCrom (Post 2667407)
That time is counted from the start of the map, not round. He can use get_gametime(), but he will need to compare the stored value with a new get_gametime() when the player joins and check if the difference between them is >= 40.

Okay... Any code that can lead me to the solution?

OciXCrom 09-18-2019 08:02

Re: Prevent player from spawning (just ignore him)
 
Store get_gametime()'s value in a global variable on round start.
When the player joins, compare the variable with a new get_gametime() output and see if it's greater than 40:

PHP Code:

if(get_gametime() - STORED_VARIABLE >= 40

You can use get_systime() too if you prefer.

MihailoZ 09-18-2019 10:06

Re: Prevent player from spawning (just ignore him)
 
Code:

#include <amxmodx>
#include <hamsandwich>

new Float:g_fRoundTime;

public plugin_init() {
        register_plugin("LateJoin", "1.0.0", "de");
       
        register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
       
        RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
}

public event_new_round() {
        g_fRoundTime = get_gametime();
}

public fwHamPlayerSpawnPost(id) {
        if(is_user_connected(id))
        if(get_gametime() - g_fRoundTime >= 40) {
       
                return HAM_SUPERCEDE;
               
        }
       
        return PLUGIN_CONTINUE;
}

Tried this, not working.

JocAnis 09-18-2019 10:07

Re: Prevent player from spawning (just ignore him)
 
Ops my bad, dunno why i wrote that, thanks @OciXCrom for catching it

@MihailoZ, get_gametime() at the beggining was too hard for me to undestand what it does, but its fun thing, maybe this example can help you:

Like OciX said, get_gametime() is getting the decimal time from the map start, so when you go with g_fRoundTime = get_gametime(), if round started like on the 10.0 sec of the map starting, g_fRoundTime will be that time. So if player connects (and spawn automatically) a little later, lets say on 30.0 sec of the map start, you must get his late-time from roundstarting to be 20.0 sec (easy logic)....so by putting it on player spawn:
( get_gametime() (<-its his 30.0sec on first spawn) - g_fRoundTime (<- already stored, first round on 10.0sec of map start) ) >= 40.0

i hope its easier for you
@OciXCrom, i would aprecciate if you can make any example with get_systime (how i undestood, systime must be used for like gag/ban/similar plugins)

EDIT: i think you cant go with return HAM_SUPERCEDE on POST of player spawn idk


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

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