1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520
| #include <sourcemod> #include <sdktools> #include <sdktools_functions> #undef REQUIRE_PLUGIN #include <adminmenu>
new Handle:hAdminMenu = INVALID_HANDLE
new Handle:Cvar_RocketMe = INVALID_HANDLE
new gametype = 0 new g_Explosion
new g_Ent[MAXPLAYERS+1] new String:GameName[64]
new bool:IsBonusRound = false
#define PLUGIN_VERSION "1.0.110"
// Functions public Plugin:myinfo = { name = "Evil Admin - Rocket", author = "<eVa>Dog", description = "Make a rocket with a player", version = PLUGIN_VERSION, url = "http://www.theville.org" }
public OnPluginStart() { CreateConVar("sm_evilrocket_version", PLUGIN_VERSION, "Evil Rocket插件版本", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY) Cvar_RocketMe = CreateConVar("sm_rocketme_enabled", "0", "允許玩家把自己變成火箭", FCVAR_PLUGIN) RegAdminCmd("sm_zisha", Command_EvilRocket, ADMFLAG_SLAY, "sm_evilrocket <#userid|name>") RegConsoleCmd("sm_kill", Command_RocketMe, "一個有趣的自殺方法") LoadTranslations("common.phrases") GetGameFolderName(GameName, sizeof(GameName)) if (StrEqual(GameName, "tf")) { HookEvent("teamplay_round_win", RoundWinEvent) HookEvent("teamplay_round_active", RoundStartEvent) } else if (StrEqual(GameName, "dod")) { HookEvent("dod_round_win", RoundWinEvent) HookEvent("dod_round_active", RoundStartEvent) } new Handle:topmenu if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE)) { OnAdminMenuReady(topmenu) } }
public Action:RoundWinEvent(Handle:event, const String:name[], bool:dontBroadcast) { IsBonusRound = true }
public Action:RoundStartEvent(Handle:event, const String:name[], bool:dontBroadcast) { IsBonusRound = false }
public OnEventShutdown() { if (StrEqual(GameName, "tf")) { UnhookEvent("teamplay_round_win", RoundWinEvent) UnhookEvent("teamplay_round_active", RoundStartEvent) } else if (StrEqual(GameName, "dod")) { UnhookEvent("dod_round_win", RoundWinEvent) UnhookEvent("dod_round_active", RoundStartEvent) } }
public OnMapStart() { if (StrEqual(GameName, "tf")) { gametype = 1 } else if (StrEqual(GameName, "dod")) { gametype = 2 } else { gametype = 0 } g_Explosion = PrecacheModel("sprites/sprite_fire01.vmt") PrecacheSound("ambient/explosions/exp2.wav", true) PrecacheSound("npc/env_headcrabcanister/launch.wav", true) PrecacheSound("weapons/rpg/rocketfire1.wav", true) }
public Action:Command_EvilRocket(client, args) { decl String:target[65] decl String:target_name[MAX_TARGET_LENGTH] decl target_list[MAXPLAYERS] decl target_count decl bool:tn_is_ml if (args < 1) { ReplyToCommand(client, "[提示] 用法: sm_evilrocket <#userid|name>"); return Plugin_Handled } GetCmdArg(1, target, sizeof(target)) if ((target_count = ProcessTargetString( target, client, target_list, MAXPLAYERS, 0, target_name, sizeof(target_name), tn_is_ml)) <= 0) { ReplyToTargetError(client, target_count) return Plugin_Handled } for (new i = 0; i < target_count; i++) { if (IsClientInGame(target_list[i]) && IsPlayerAlive(target_list[i])) { PerformEvilRocket(client, target_list[i]) } } return Plugin_Handled }
PerformEvilRocket(client, target) { if (g_Ent[target] == 0) { if (client != -1) { LogAction(client, target, "\"%L\"把\"%L\"送到太空了", client, target) ShowActivity(client, "已发射 \%N 到太空", target) if (gametype == 1) { AttachParticle(target, "rockettrail_!") } else if (gametype == 2) { AttachParticle(target, "rockettrail") } else { AttachFlame(target) } EmitSoundToAll("weapons/rpg/rocketfire1.wav", target, _, _, _, 0.8) CreateTimer(2.0, Launch, target) CreateTimer(3.5, Detonate, target) } else { if (gametype == 1) { AttachParticle(target, "rockettrail_!") } else if (gametype == 2) { AttachParticle(target, "rockettrail") } else { AttachFlame(target) } EmitSoundToAll("weapons/rpg/rocketfire1.wav", target, _, _, _, 0.8) CreateTimer(2.0, Launch, target) CreateTimer(3.5, Detonate, target) } } }
public Action:Launch(Handle:timer, any:client) { if (IsClientInGame(client)) { new Float:vVel[3] vVel[0] = 0.0 vVel[1] = 0.0 vVel[2] = 800.0 EmitSoundToAll("ambient/explosions/exp2.wav", client, _, _, _, 1.0) EmitSoundToAll("npc/env_headcrabcanister/launch.wav", client, _, _, _, 1.0) TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vVel) SetEntityGravity(client, 0.1) } return Plugin_Handled }
public Action:Detonate(Handle:timer, any:client) { if (IsClientInGame(client)) { new Float:vPlayer[3] GetClientAbsOrigin(client, vPlayer) if (gametype == 1) { DeleteParticle(g_Ent[client]) g_Ent[client] = 0 if (IsBonusRound) { new Float:ClientOrigin[3] GetClientAbsOrigin(client, ClientOrigin)
new g_ent = CreateEntityByName("env_explosion") DispatchKeyValue(g_ent, "iMagnitude", "2000") DispatchKeyValue(g_ent, "iRadiusOverride", "15") DispatchSpawn(g_ent) TeleportEntity(g_ent, ClientOrigin, NULL_VECTOR, NULL_VECTOR) AcceptEntityInput(g_ent, "Explode") CreateTimer(3.0, KillExplosion, g_ent) } else { FakeClientCommand(client, "Explode") } } else if (gametype == 2) { DeleteParticle(g_Ent[client]) g_Ent[client] = 0 FakeClientCommand(client, "Explode") } else { TE_SetupExplosion(vPlayer, g_Explosion, 10.0, 1, 0, 600, 5000) TE_SendToAll() g_Ent[client] = 0 ForcePlayerSuicide(client) } SetEntityGravity(client, 1.0) } return Plugin_Handled }
public Action:KillExplosion(Handle:timer, any:ent) { if (IsValidEntity(ent)) { new String:classname[256] GetEdictClassname(ent, classname, sizeof(classname)) if (StrEqual(classname, "env_explosion", false)) { RemoveEdict(ent) } } }
public OnLibraryRemoved(const String:name[]) { if (StrEqual(name, "adminmenu")) { hAdminMenu = INVALID_HANDLE; } }
public OnAdminMenuReady(Handle:topmenu) { if (topmenu == hAdminMenu) { return; } hAdminMenu = topmenu
new TopMenuObject:player_commands = FindTopMenuCategory(hAdminMenu, ADMINMENU_PLAYERCOMMANDS)
if (player_commands != INVALID_TOPMENUOBJECT) { AddToTopMenu(hAdminMenu, "sm_evilrocket", TopMenuObject_Item, AdminMenu_rocket, player_commands, "sm_evilrocket", ADMFLAG_SLAY) } } public AdminMenu_rocket( Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength ) { if (action == TopMenuAction_DisplayOption) { Format(buffer, maxlength, "恶魔火箭") } else if( action == TopMenuAction_SelectOption) { DisplayPlayerMenu(param) } }
DisplayPlayerMenu(client) { new Handle:menu = CreateMenu(MenuHandler_Players) decl String:title[100] Format(title, sizeof(title), "选择玩家:") SetMenuTitle(menu, title) SetMenuExitBackButton(menu, true) AddTargetsToMenu(menu, client, true, true) DisplayMenu(menu, client, MENU_TIME_FOREVER) }
public MenuHandler_Players(Handle:menu, MenuAction:action, param1, param2) { if (action == MenuAction_End) { CloseHandle(menu) } else if (action == MenuAction_Cancel) { if (param2 == MenuCancel_ExitBack && hAdminMenu != INVALID_HANDLE) { DisplayTopMenu(hAdminMenu, param1, TopMenuPosition_LastCategory); } } else if (action == MenuAction_Select) { decl String:info[32] new userid, target GetMenuItem(menu, param2, info, sizeof(info)) userid = StringToInt(info)
if ((target = GetClientOfUserId(userid)) == 0) { PrintToChat(param1, "[提示] %s", "玩家非長期可用") } else if (!CanUserTarget(param1, target)) { PrintToChat(param1, "[提示] %s", "目标不可用") } else { PerformEvilRocket(param1, target) } /* Re-draw the menu if they're still valid */ if (IsClientInGame(param1) && !IsClientInKickQueue(param1)) { DisplayPlayerMenu(param1) } } }
AttachParticle(ent, String:particleType[]) { new particle = CreateEntityByName("info_particle_system") new String:tName[128], String:pName[128] if (IsValidEdict(particle)) { new Float:pos[3] GetEntPropVector(ent, Prop_Send, "m_vecOrigin", pos) if (gametype == 1) { pos[2] += 10 TeleportEntity(particle, pos, NULL_VECTOR, NULL_VECTOR) } else if (gametype == 2) { pos[2] += 50 TeleportEntity(particle, pos, NULL_VECTOR, NULL_VECTOR) } Format(tName, sizeof(tName), "target%i", ent) DispatchKeyValue(ent, "targetname", tName) Format(pName, sizeof(pName), "particle%i", ent) DispatchKeyValue(particle, "targetname", pName) DispatchKeyValue(particle, "parentname", tName) DispatchKeyValue(particle, "effect_name", particleType) DispatchSpawn(particle) SetVariantString(tName) AcceptEntityInput(particle, "SetParent", particle, particle, 0) if (gametype == 1) { SetVariantString("flag") AcceptEntityInput(particle, "SetParentAttachment", particle, particle, 0) } ActivateEntity(particle) AcceptEntityInput(particle, "start") g_Ent[ent] = particle } }
DeleteParticle(any:particle) { if (IsValidEntity(particle)) { new String:classname[256] GetEdictClassname(particle, classname, sizeof(classname)) if (StrEqual(classname, "info_particle_system", false)) { RemoveEdict(particle) } } }
AttachFlame(ent) { new String:flame_name[128] Format(flame_name, sizeof(flame_name), "RocketFlame%i", ent) new String:tName[128] new flame = CreateEntityByName("env_steam") if (IsValidEdict(flame)) { new Float:pos[3] GetEntPropVector(ent, Prop_Send, "m_vecOrigin", pos) pos[2] += 30 new Float:angles[3] angles[0] = 90.0 angles[1] = 0.0 angles[2] = 0.0 Format(tName, sizeof(tName), "target%i", ent) DispatchKeyValue(ent, "targetname", tName) DispatchKeyValue(flame,"targetname", flame_name) DispatchKeyValue(flame, "parentname", tName) DispatchKeyValue(flame,"SpawnFlags", "1") DispatchKeyValue(flame,"Type", "0") DispatchKeyValue(flame,"InitialState", "1") DispatchKeyValue(flame,"Spreadspeed", "10") DispatchKeyValue(flame,"Speed", "800") DispatchKeyValue(flame,"Startsize", "10") DispatchKeyValue(flame,"EndSize", "250") DispatchKeyValue(flame,"Rate", "15") DispatchKeyValue(flame,"JetLength", "400") DispatchKeyValue(flame,"RenderColor", "180 71 8") DispatchKeyValue(flame,"RenderAmt", "180") DispatchSpawn(flame) TeleportEntity(flame, pos, angles, NULL_VECTOR) SetVariantString(tName) AcceptEntityInput(flame, "SetParent", flame, flame, 0) CreateTimer(3.0, DeleteFlame, flame) g_Ent[ent] = flame } }
public Action:DeleteFlame(Handle:timer, any:ent) { if (IsValidEntity(ent)) { new String:classname[256] GetEdictClassname(ent, classname, sizeof(classname)) if (StrEqual(classname, "env_steam", false)) { RemoveEdict(ent) } } }
public Action:Command_RocketMe(client, args) { if (IsClientInGame(client) && IsPlayerAlive(client)) { PerformEvilRocket(-1, client) CreateTimer(3.0, MessageUs, client) } else if (GetConVarInt(Cvar_RocketMe)) { if (IsClientInGame(client) && IsPlayerAlive(client)) { PerformEvilRocket(-1, client) CreateTimer(3.0, MessageUs, client) } } else { PrintToChat(client, "[提示] 未允许把自己送进火箭。") }
return Plugin_Handled }
public Action:MessageUs(Handle:timer, any:client) { PrintToChatAll("[死亡] %N 死于火箭意外坠落身亡.", client) }
|