plugins/basefuncommands.sp
changeset 1536 fe2146e4975d
parent 1418 7404bb003948
child 1591 3f28cc06e235
     1.1 --- a/plugins/basefuncommands.sp	Mon Oct 08 22:13:49 2007 +0000
     1.2 +++ b/plugins/basefuncommands.sp	Sat Oct 13 04:43:42 2007 +0000
     1.3 @@ -35,6 +35,8 @@
     1.4  
     1.5  #include <sourcemod>
     1.6  #include <sdktools>
     1.7 +#undef REQUIRE_PLUGIN
     1.8 +#include <adminmenu>
     1.9  
    1.10  public Plugin:myinfo =
    1.11  {
    1.12 @@ -45,6 +47,14 @@
    1.13  	url = "http://www.sourcemod.net/"
    1.14  };
    1.15  
    1.16 +new Handle:hTopMenu = INVALID_HANDLE;
    1.17 +
    1.18 +new g_SlapDamage[MAXPLAYERS+1];
    1.19 +
    1.20 +#include "basefuncommands/slay.sp"
    1.21 +#include "basefuncommands/burn.sp"
    1.22 +#include "basefuncommands/slap.sp"
    1.23 +
    1.24  public OnPluginStart()
    1.25  {
    1.26  	LoadTranslations("common.phrases");
    1.27 @@ -53,6 +63,55 @@
    1.28  	RegAdminCmd("sm_slap", Command_Slap, ADMFLAG_SLAY, "sm_slap <#userid|name> [damage]");
    1.29  	RegAdminCmd("sm_slay", Command_Slay, ADMFLAG_SLAY, "sm_slay <#userid|name>");
    1.30  	RegAdminCmd("sm_play", Command_Play, ADMFLAG_GENERIC, "sm_play <#userid|name> <filename>");
    1.31 +	
    1.32 +	/* Account for late loading */
    1.33 +	new Handle:topmenu;
    1.34 +	if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
    1.35 +	{
    1.36 +		OnAdminMenuReady(topmenu);
    1.37 +	}
    1.38 +}
    1.39 +
    1.40 +public OnAdminMenuReady(Handle:topmenu)
    1.41 +{
    1.42 +	/* Block us from being called twice */
    1.43 +	if (topmenu == hTopMenu)
    1.44 +	{
    1.45 +		return;
    1.46 +	}
    1.47 +	
    1.48 +	/* Save the Handle */
    1.49 +	hTopMenu = topmenu;
    1.50 +	
    1.51 +	/* Find the "Player Commands" category */
    1.52 +	new TopMenuObject:player_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_PLAYERCOMMANDS);
    1.53 +
    1.54 +	if (player_commands != INVALID_TOPMENUOBJECT)
    1.55 +	{
    1.56 +		AddToTopMenu(hTopMenu,
    1.57 +			"Slay Player",
    1.58 +			TopMenuObject_Item,
    1.59 +			AdminMenu_Slay,
    1.60 +			player_commands,
    1.61 +			"sm_slay",
    1.62 +			ADMFLAG_SLAY);
    1.63 +			
    1.64 +		AddToTopMenu(hTopMenu,
    1.65 +			"Burn Player",
    1.66 +			TopMenuObject_Item,
    1.67 +			AdminMenu_Burn,
    1.68 +			player_commands,
    1.69 +			"sm_burn",
    1.70 +			ADMFLAG_SLAY);
    1.71 +			
    1.72 +		AddToTopMenu(hTopMenu,
    1.73 +			"Slap Player",
    1.74 +			TopMenuObject_Item,
    1.75 +			AdminMenu_Slap,
    1.76 +			player_commands,
    1.77 +			"sm_slap",
    1.78 +			ADMFLAG_SLAY);	
    1.79 +	}
    1.80  }
    1.81  
    1.82  public Action:Command_Play(client, args)
    1.83 @@ -102,122 +161,3 @@
    1.84  	return Plugin_Handled;
    1.85  }
    1.86  
    1.87 -public Action:Command_Burn(client, args)
    1.88 -{
    1.89 -	if (args < 1)
    1.90 -	{
    1.91 -		ReplyToCommand(client, "[SM] Usage: sm_burn <#userid|name> [time]");
    1.92 -		return Plugin_Handled;
    1.93 -	}
    1.94 -
    1.95 -	decl String:arg[65];
    1.96 -	GetCmdArg(1, arg, sizeof(arg));
    1.97 -
    1.98 -	new target = FindTarget(client, arg);
    1.99 -	if (target == -1)
   1.100 -	{
   1.101 -		return Plugin_Handled;
   1.102 -	}
   1.103 -
   1.104 -	GetClientName(target, arg, sizeof(arg));
   1.105 -	
   1.106 -	if (!IsPlayerAlive(target))
   1.107 -	{
   1.108 -		ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", arg);
   1.109 -		return Plugin_Handled;
   1.110 -	}
   1.111 -	
   1.112 -	new Float:seconds = 20.0;
   1.113 -	if (args > 1)
   1.114 -	{
   1.115 -		decl String:time[20];
   1.116 -		GetCmdArg(2, time, sizeof(time));
   1.117 -		if (StringToFloatEx(time, seconds) == 0)
   1.118 -		{
   1.119 -			ReplyToCommand(client, "[SM] %t", "Invalid Amount");
   1.120 -			return Plugin_Handled;
   1.121 -		}
   1.122 -	}
   1.123 -
   1.124 -	ShowActivity(client, "%t", "Ignited player", arg);
   1.125 -	LogAction(client, target, "\"%L\" ignited \"%L\" (seconds \"%f\")", client, target, seconds);
   1.126 -	IgniteEntity(target, seconds);
   1.127 -
   1.128 -	return Plugin_Handled;
   1.129 -}
   1.130 -
   1.131 -public Action:Command_Slap(client, args)
   1.132 -{
   1.133 -	if (args < 1)
   1.134 -	{
   1.135 -		ReplyToCommand(client, "[SM] Usage: sm_slap <#userid|name> [damage]");
   1.136 -		return Plugin_Handled;
   1.137 -	}
   1.138 -
   1.139 -	decl String:arg[65];
   1.140 -	GetCmdArg(1, arg, sizeof(arg));
   1.141 -
   1.142 -	new target = FindTarget(client, arg);
   1.143 -	if (target == -1)
   1.144 -	{
   1.145 -		return Plugin_Handled;
   1.146 -	}
   1.147 -
   1.148 -	GetClientName(target, arg, sizeof(arg));
   1.149 -
   1.150 -	if (!IsPlayerAlive(target))
   1.151 -	{
   1.152 -		ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", arg);
   1.153 -		return Plugin_Handled;
   1.154 -	}	
   1.155 -	
   1.156 -	new damage = 0;
   1.157 -	if (args > 1)
   1.158 -	{
   1.159 -		decl String:arg2[20];
   1.160 -		GetCmdArg(2, arg2, sizeof(arg2));
   1.161 -		if (StringToIntEx(arg2, damage) == 0)
   1.162 -		{
   1.163 -			ReplyToCommand(client, "[SM] %t", "Invalid Amount");
   1.164 -			return Plugin_Handled;
   1.165 -		}
   1.166 -	}
   1.167 -
   1.168 -	ShowActivity(client, "%t", "Slapped player", arg);
   1.169 -	LogAction(client, target, "\"%L\" slapped \"%L\" (damage \"%d\")", client, target, damage);
   1.170 -	SlapPlayer(target, damage, true);
   1.171 -
   1.172 -	return Plugin_Handled;
   1.173 -}
   1.174 -
   1.175 -public Action:Command_Slay(client, args)
   1.176 -{
   1.177 -	if (args < 1)
   1.178 -	{
   1.179 -		ReplyToCommand(client, "[SM] Usage: sm_slay <#userid|name>");
   1.180 -		return Plugin_Handled;
   1.181 -	}
   1.182 -
   1.183 -	decl String:arg[65];
   1.184 -	GetCmdArg(1, arg, sizeof(arg));
   1.185 -
   1.186 -	new target = FindTarget(client, arg);
   1.187 -	if (target == -1)
   1.188 -	{
   1.189 -		return Plugin_Handled;
   1.190 -	}
   1.191 -
   1.192 -	GetClientName(target, arg, sizeof(arg));
   1.193 -
   1.194 -	if (!IsPlayerAlive(target))
   1.195 -	{
   1.196 -		ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", arg);
   1.197 -		return Plugin_Handled;
   1.198 -	}	
   1.199 -
   1.200 -	ShowActivity(client, "%t", "Slayed player", arg);
   1.201 -	LogAction(client, target, "\"%L\" slayed \"%L\"", client, target);
   1.202 -	ForcePlayerSuicide(target);
   1.203 -
   1.204 -	return Plugin_Handled;
   1.205 -}