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

Suggestion / Subplugin Request [SOLVED] make ZP limit command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
arvEL.
Senior Member
Join Date: Dec 2014
Location: Iraq
Old 10-29-2015 , 14:10   [SOLVED] make ZP limit command
Reply With Quote #1

hi guys i want make limit for ZP command
example:
every admin can use zp_human once in each map
if he use this command zp_human again
server will stop him
MESSAGE: this command was already use in this map

Last edited by arvEL.; 10-29-2015 at 23:00.
arvEL. is offline
Send a message via Skype™ to arvEL.
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 10-29-2015 , 22:18   Re: [HELP] make ZP limit command
Reply With Quote #2

Very simple. bool should be the best choice for this case.

PHP Code:
new bool:cmd_used[33
Look for this line and add the red colored line
Code:
// zp_human [target]
public cmd_human(id, level, cid)
{
	// Check for access flag - Make Human
	if (!cmd_access(id, g_access_flag[ACCESS_MAKE_HUMAN], cid, 2))
		return PLUGIN_HANDLED;

	// Limit the use of cmd
	if (cmd_used[id])
	{
		client_print(id, print_chat, "[ZP] You have already used this command!")
		return PLUGIN_HANDLED;
	}
	
	// Retrieve arguments
	static arg[32], player
	read_argv(1, arg, charsmax(arg))
	player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
	
	// Invalid target
	if (!player) return PLUGIN_HANDLED;
	
	// Target not allowed to be human
	if (!allowed_human(player))
	{
		client_print(id, print_console, "[ZP] %L", id, "CMD_NOT")
		return PLUGIN_HANDLED;
	}
	
	command_human(id, player)
	cmd_used[id] = true
	
	return PLUGIN_HANDLED;
}
Note: I purposely made it only restricted using console cmd (which means admins can still use the command using ZP MENU so it would be great if you disable ZP MENU for normal admins)



============================================= ============================================= =

If you want to restrict the command from both MENU and Console CMD: (You dont need to edit the public cmd_human for this)
Code:
// Admin Command. zp_human
command_human(id, player)
{
	// Limit the use of cmd
	if (cmd_used[id])
	{
		client_print(id, print_chat, "[ZP] You have already used this command!")
		return PLUGIN_HANDLED;
	}

	// Show activity?
	switch (get_pcvar_num(cvar_showactivity))
	{
		case 1: client_print(0, print_chat, "ADMIN - %s %L", g_playername[player], LANG_PLAYER, "CMD_DISINFECT")
		case 2: client_print(0, print_chat, "ADMIN %s - %s %L", g_playername[id], g_playername[player], LANG_PLAYER, "CMD_DISINFECT")
	}
	
	// Log to Zombie Plague log file?
	if (get_pcvar_num(cvar_logcommands))
	{
		static logdata[100], authid[32], ip[16]
		get_user_authid(id, authid, charsmax(authid))
		get_user_ip(id, ip, charsmax(ip), 1)
		formatex(logdata, charsmax(logdata), "ADMIN %s <%s><%s> - %s %L (Players: %d/%d)", g_playername[id], authid, ip, g_playername[player], LANG_SERVER,"CMD_DISINFECT", fnGetPlaying(), g_maxplayers)
		log_to_file("zombie_plague_advance.log", logdata)
	}
	
	// Turn to human
	humanme(player, 0, 0, 0)
	cmd_used[id] = true

        return PLUGIN_HANDLED;
}

Last edited by Chihuahuax; 10-29-2015 at 22:48.
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
arvEL.
Senior Member
Join Date: Dec 2014
Location: Iraq
Old 10-29-2015 , 22:35   Re: [HELP] make ZP limit command
Reply With Quote #3

thank you very much my friend, another question
this for all the admins?
or individually for each admin?
arvEL. is offline
Send a message via Skype™ to arvEL.
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 10-29-2015 , 22:38   Re: [HELP] make ZP limit command
Reply With Quote #4

Quote:
Originally Posted by arvEL. View Post
thank you very much my friend, another question
this for all the admins?
or individually for each admin?
Individually

If you want it to be globally, just change all
PHP Code:
cmd_used[id
to
PHP Code:
cmd_used 

And remember to register the right bool
PHP Code:
new bool:cmd_used 
without the [33]

Last edited by Chihuahuax; 10-29-2015 at 22:39.
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
arvEL.
Senior Member
Join Date: Dec 2014
Location: Iraq
Old 10-29-2015 , 23:00   Re: [HELP] make ZP limit command
Reply With Quote #5

SOLVED!
thank you very much @Chihuahuax
T/C
arvEL. is offline
Send a message via Skype™ to arvEL.
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 04:50.


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