plugins/testsuite/tf2-test.sp
author Nicholas Hastings <skamonkey@gmail.com>
Fri Oct 28 20:27:44 2011 -0400 (2011-10-28)
changeset 3428 2200d218c91c
parent 2939 3d62874b9071
permissions -rw-r--r--
Updated Dino D-Day gamedata for today's update.
     1 #include <sourcemod>
     2 #include <sdktools>
     3 #include <tf2>
     4 #include <tf2_stocks>
     5 
     6 public Plugin:myinfo = 
     7 {
     8 	name = "TF2 Test",
     9 	author = "pRED*",
    10 	description = "Test of Tf2 functions",
    11 	version = "1.0",
    12 	url = "www.sourcemod.net"
    13 }
    14 
    15 public OnPluginStart()
    16 {
    17 	RegConsoleCmd("sm_burnme", Command_Burn);
    18 	RegConsoleCmd("sm_respawn", Command_Respawn);
    19 	RegConsoleCmd("sm_disguise", Command_Disguise);
    20 	RegConsoleCmd("sm_remdisguise", Command_RemDisguise);
    21 	RegConsoleCmd("sm_class", Command_Class);
    22 	RegConsoleCmd("sm_remove", Command_Remove);
    23 	RegConsoleCmd("sm_changeclass", Command_ChangeClass);
    24 	RegConsoleCmd("sm_regenerate", Command_Regenerate);
    25 	RegConsoleCmd("sm_uberme", Command_UberMe);
    26 	RegConsoleCmd("sm_unuberme", Command_UnUberMe);
    27 	RegConsoleCmd("sm_setpowerplay", Command_SetPowerPlay);
    28 	RegConsoleCmd("sm_panic", Command_Panic);
    29 	RegConsoleCmd("sm_bighit", Command_BigHit);
    30 	RegConsoleCmd("sm_frighten", Command_Frighten);
    31 }
    32 
    33 public Action:Command_Class(client, args)
    34 {
    35 	TF2_RemoveAllWeapons(client);
    36 	
    37 	PrintToChat(client, "Test: sniper's classnum is %i (should be %i)", TF2_GetClass("sniper"), TFClass_Sniper);
    38 		
    39 	return Plugin_Handled;
    40 }
    41 
    42 public Action:Command_Remove(client, args)
    43 {
    44 	decl String:text[10];
    45 	GetCmdArg(1, text, sizeof(text));
    46 	
    47 	new one = StringToInt(text);
    48 	
    49 	TF2_RemoveWeaponSlot(client, one);
    50 	
    51 	PrintToChat(client, "Test: heavy's classnum is %i (should be %i)", TF2_GetClass("heavy"), TFClass_Heavy);
    52 	
    53 	new doms = TF2_GetPlayerResourceData(client, TFResource_Dominations);
    54 	PrintToChat(client, "Dominations read test: %i", doms);
    55 	
    56 	TF2_SetPlayerResourceData(client, TFResource_Dominations, doms + 10);
    57 	doms = TF2_GetPlayerResourceData(client, TFResource_Dominations);
    58 	PrintToChat(client, "Dominations write test: %i", doms);
    59 	
    60 	/* Note: This didn't appear to change my dominations value when I pressed tab. */
    61 	
    62 	return Plugin_Handled;
    63 }
    64 
    65 public Action:Command_ChangeClass(client, args)
    66 {
    67 	decl String:text[10];
    68 	GetCmdArg(1, text, sizeof(text));
    69 	
    70 	new one = StringToInt(text);
    71 	
    72 	PrintToChat(client, "Current class is :%i", TF2_GetPlayerClass(client));
    73 	
    74 	TF2_SetPlayerClass(client, TFClassType:one);
    75 	
    76 	PrintToChat(client, "New class is :%i", TF2_GetPlayerClass(client));
    77 		
    78 	return Plugin_Handled;
    79 }
    80 
    81 
    82 
    83 public Action:Command_Burn(client, args)
    84 {
    85 	if (client == 0)
    86 	{
    87 		return Plugin_Handled;
    88 	}
    89 	
    90 	TF2_IgnitePlayer(client, client);
    91 	
    92 	return Plugin_Handled;
    93 }
    94 
    95 public Action:Command_Disguise(client, args)
    96 {
    97 	if (client == 0)
    98 	{
    99 		return Plugin_Handled;
   100 	}
   101 	
   102 	if (args < 2)
   103 	{
   104 		return Plugin_Handled;	
   105 	}
   106 	
   107 	decl String:text[10];
   108 	decl String:text2[10];
   109 	GetCmdArg(1, text, sizeof(text));
   110 	GetCmdArg(2, text2, sizeof(text2));
   111 	
   112 	new one = StringToInt(text);
   113 	new two = StringToInt(text2);
   114 
   115 	TF2_DisguisePlayer(client, TFTeam:one, TFClassType:two);
   116 	
   117 	return Plugin_Handled;
   118 }
   119 
   120 public Action:Command_RemDisguise(client, args)
   121 {
   122 	if (client == 0)
   123 	{
   124 		return Plugin_Handled;
   125 	}
   126 	
   127 	TF2_RemovePlayerDisguise(client);
   128 	
   129 	return Plugin_Handled;
   130 }
   131 
   132 
   133 public Action:Command_Respawn(client, args)
   134 {
   135 	if (client == 0)
   136 	{
   137 		return Plugin_Handled;
   138 	}
   139 	
   140 
   141 	TF2_RespawnPlayer(client);
   142 	
   143 	return Plugin_Handled;
   144 }
   145 
   146 public Action:Command_Regenerate(client, args)
   147 {
   148 	if (client == 0)
   149 	{
   150 		return Plugin_Handled;
   151 	}
   152 	
   153 	TF2_RegeneratePlayer(client);
   154 	
   155 	return Plugin_Handled;
   156 }
   157 
   158 public Action:Command_UberMe(client, args)
   159 {
   160 	if (client == 0)
   161 	{
   162 		return Plugin_Handled;
   163 	}
   164 	
   165 	if (args < 1)
   166 	{
   167 		return Plugin_Handled;
   168 	}
   169 	
   170 	decl String:text[10];
   171 	GetCmdArg(1, text, sizeof(text));
   172 	
   173 	new Float:one = StringToFloat(text);
   174 	
   175 	TF2_AddCondition(client, TFCond_Ubercharged, one);
   176 	
   177 	return Plugin_Handled;
   178 }
   179 
   180 public Action:Command_UnUberMe(client, args)
   181 {
   182 	if (client == 0)
   183 	{
   184 		return Plugin_Handled;
   185 	}
   186 	
   187 	TF2_RemoveCondition(client, TFCond_Ubercharged);
   188 	
   189 	return Plugin_Handled;
   190 }
   191 
   192 public Action:Command_SetPowerPlay(client, args)
   193 {
   194 	if (client == 0)
   195 	{
   196 		return Plugin_Handled;
   197 	}
   198 	
   199 	if (args < 1)
   200 	{
   201 		return Plugin_Handled;
   202 	}
   203 	
   204 	decl String:text[10];
   205 	GetCmdArg(1, text, sizeof(text));
   206 	
   207 	new bool:one = bool:StringToInt(text);
   208 	
   209 	TF2_SetPlayerPowerPlay(client, one);
   210 	
   211 	return Plugin_Handled;
   212 }
   213 
   214 public Action:Command_Panic(client, args)
   215 {
   216 	if (client == 0)
   217 	{
   218 		return Plugin_Handled;
   219 	}
   220 	
   221 	TF2_StunPlayer(client, 15.0, 0.25, TF_STUNFLAGS_LOSERSTATE);
   222 	
   223 	return Plugin_Handled;
   224 }
   225 
   226 public Action:Command_BigHit(client, args)
   227 {
   228 	if (client == 0)
   229 	{
   230 		return Plugin_Handled;
   231 	}
   232 	
   233 	TF2_StunPlayer(client, 5.0, _, TF_STUNFLAGS_BIGBONK, client);
   234 	
   235 	return Plugin_Handled;
   236 }
   237 
   238 public Action:Command_Frighten(client, args)
   239 {
   240 	if (client == 0)
   241 	{
   242 		return Plugin_Handled;
   243 	}
   244 	
   245 	TF2_StunPlayer(client, 5.0, _, TF_STUNFLAGS_GHOSTSCARE);
   246 	
   247 	return Plugin_Handled;
   248 }