Raised This Month: $32 Target: $400
 8% 

prevent using admin command after x seconds passed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gehinnom
Junior Member
Join Date: Jul 2008
Old 10-24-2021 , 10:38   prevent using admin command after x seconds passed
Reply With Quote #1

Hey there,

As you know there is a command named amx_weapon in AMX Super. I want to prevent admins to use this command after 15 seconds passed on EACH round start. So I need to check the round time passed in seconds.

How can I do that?
Gehinnom is offline
Send a message via ICQ to Gehinnom
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 10-24-2021 , 11:35   Re: prevent using admin command after x seconds passed
Reply With Quote #2

store get_systime() in a global variable at Round Start hook and check if 15 seconds is passed in the command handler

Last edited by jimaway; 10-24-2021 at 11:36.
jimaway is offline
Gehinnom
Junior Member
Join Date: Jul 2008
Old 10-24-2021 , 11:38   Re: prevent using admin command after x seconds passed
Reply With Quote #3

Code:
register_logevent("logevent_round_start", 2, "1=Round_Start")
Code:
public logevent_round_start() {
	new id[32], num
	get_players(id, num, "ae", "TERRORIST")
	
	roundStartTime = get_systime()
..
Code:
public admin_weapon(id,level,cid)
{
	if ( !cmd_access(id,level,cid,3) )
		return PLUGIN_HANDLED
		
		
	if (get_systime() - roundStartTime > 15)
		return PLUGIN_HANDLED
how does this one look? compiled but didn't work, don't know why.

Last edited by Gehinnom; 10-24-2021 at 11:39.
Gehinnom is offline
Send a message via ICQ to Gehinnom
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 10-24-2021 , 11:58   Re: prevent using admin command after x seconds passed
Reply With Quote #4

try this
Code:
if (get_systime() - roundStartTime > 15 && roundStartTime)
jimaway is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 10-24-2021 , 12:25   Re: prevent using admin command after x seconds passed
Reply With Quote #5

Could base it off the mp_freezetime CVAR to help future-proof it.
Code:
new bool:roundfreeze public round_end()    roundfreeze = true public round_start()    roundfreeze = false public admin_weapon(id,level,cid)    if (!cmd_access(id,level,cid,3) || roundfreeze) return PLUGIN_HANDLED;
__________________
DJEarthQuake is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 10-24-2021 , 15:33   Re: prevent using admin command after x seconds passed
Reply With Quote #6

Quote:
Originally Posted by DJEarthQuake View Post
Could base it off the mp_freezetime CVAR to help future-proof it.
Code:
new bool:roundfreeze public round_end()    roundfreeze = true public round_start()    roundfreeze = false public admin_weapon(id,level,cid)    if (!cmd_access(id,level,cid,3) || roundfreeze) return PLUGIN_HANDLED;
What if mp_freezetime is set to 0?
__________________
edon1337 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-24-2021 , 16:20   Re: prevent using admin command after x seconds passed
Reply With Quote #7

Quote:
Originally Posted by Gehinnom View Post
how does this one look? compiled but didn't work, don't know why.
The code you have showed seems reasonable to me. When you post that something "didn't work" it is often unhelpful because you have not explained how it didn't work, what actually happened?
__________________
fysiks is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 10-24-2021 , 18:38   Re: prevent using admin command after x seconds passed
Reply With Quote #8

Quote:
Originally Posted by edon1337 View Post
What if mp_freezetime is set to 0?
Crossed my mind. Hardly something mission-critical enough to hard code. Hard-coding is not the best way. An off switch is nice. Anytime he wanted to change it 10 sec or whatever have to edit the SMA and recompile upload, change map, etc.
__________________

Last edited by DJEarthQuake; 10-24-2021 at 20:42.
DJEarthQuake is offline
Reply



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 16:08.


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