Raised This Month: $12 Target: $400
 3% 

Prevent player from spawning (just ignore him)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MihailoZ
Member
Join Date: Aug 2013
Old 09-18-2019 , 05:56   Prevent player from spawning (just ignore him)
Reply With Quote #1

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.
__________________
mhvtnns

Last edited by MihailoZ; 09-18-2019 at 14:05.
MihailoZ is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 09-18-2019 , 06:05   Re: Prevent player from spawning (just ignore him)
Reply With Quote #2

Return HAM_SUPERCEDE on Ham_Spawn (pre).
__________________
edon1337 is offline
MihailoZ
Member
Join Date: Aug 2013
Old 09-18-2019 , 06:07   Re: Prevent player from spawning (just ignore him)
Reply With Quote #3

Quote:
Originally Posted by edon1337 View Post
Return HAM_SUPERCEDE on Ham_Spawn (pre).
Thank you. One more question:

How to count 40 seconds?
__________________
mhvtnns
MihailoZ is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 09-18-2019 , 06:13   Re: Prevent player from spawning (just ignore him)
Reply With Quote #4

Register new round. Add there global variable (float): g_fRoundTime = get_gametime()

On spawn check if g_fRoundTime >= 40.0
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
MihailoZ
Member
Join Date: Aug 2013
Old 09-18-2019 , 06:14   Re: Prevent player from spawning (just ignore him)
Reply With Quote #5

Quote:
Originally Posted by JocAnis View Post
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.
__________________
mhvtnns
MihailoZ is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 09-18-2019 , 07:35   Re: Prevent player from spawning (just ignore him)
Reply With Quote #6

Quote:
Originally Posted by JocAnis View Post
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.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
MihailoZ
Member
Join Date: Aug 2013
Old 09-18-2019 , 07:44   Re: Prevent player from spawning (just ignore him)
Reply With Quote #7

Quote:
Originally Posted by OciXCrom View Post
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?
__________________
mhvtnns
MihailoZ is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 09-18-2019 , 08:02   Re: Prevent player from spawning (just ignore him)
Reply With Quote #8

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.
__________________

Last edited by OciXCrom; 09-18-2019 at 08:02.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
MihailoZ
Member
Join Date: Aug 2013
Old 09-18-2019 , 10:06   Re: Prevent player from spawning (just ignore him)
Reply With Quote #9

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.
__________________
mhvtnns

Last edited by MihailoZ; 09-18-2019 at 10:06.
MihailoZ is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 09-18-2019 , 10:07   Re: Prevent player from spawning (just ignore him)
Reply With Quote #10

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
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)

Last edited by JocAnis; 09-18-2019 at 10:09.
JocAnis is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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