Guest User

Untitled

a guest
Jun 8th, 2012
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdkhooks>
  3.  
  4. #pragma semicolon 1
  5.  
  6. #define CS_TEAM_CT 3
  7. #define PLUGIN_VERSION "1.2"
  8.  
  9. new Handle:gH_ff = INVALID_HANDLE;
  10. new bool:boxenabled = false;
  11.  
  12. public Plugin:myinfo =
  13. {
  14. name = "Jailbreak Box",
  15. author = "TimeBomb",
  16. description = "Boxing Feature for T's only in Jailbreak.",
  17. version = PLUGIN_VERSION,
  18. url = ""
  19. }
  20.  
  21. public OnPluginStart()
  22. {
  23. RegConsoleCmd("sm_box", cmd_box);
  24. HookEvent("round_end", roundend);
  25. gH_ff = FindConVar("mp_friendlyfire");
  26. CreateConVar("sm_box_version", PLUGIN_VERSION, "Jailbreak Box Version");
  27. }
  28.  
  29. public OnClientPutInServer(client)
  30. {
  31. SDKHook(client, SDKHook_OnTakeDamage, dmg);
  32. }
  33.  
  34. public roundend(Handle:event, const String:name[], bool:dontBroadcast)
  35. {
  36. SetConVarInt(gH_ff, 0);
  37. boxenabled = false;
  38. }
  39.  
  40. public Action:dmg(victim, &attacker, &inflictor, &Float:damage, &damagetype)
  41. {
  42. new team, team2;
  43. team = GetClientTeam(victim);
  44. team2 = GetClientTeam(attacker);
  45. if(team == CS_TEAM_CT && team2 == CS_TEAM_CT && boxenabled && gH_ff && IsClientInGame(victim) && !IsFakeClient(attacker) && IsValidClient(attacker) && IsValidClient(victim))
  46. {
  47. damage = 0.0;
  48. return Plugin_Changed;
  49. }
  50. return Plugin_Continue;
  51. }
  52.  
  53. public Action:cmd_box(client, args)
  54. {
  55. new team = GetClientTeam(client);
  56. if(team == CS_TEAM_CT && IsPlayerAlive(client))
  57. {
  58. new Handle:boxmenu = CreateMenu(BoxmenuHandler);
  59. SetMenuTitle(boxmenu, "Box:\nBoxing with Each Other [T's only]");
  60. AddMenuItem(boxmenu, "1", "Enable");
  61. AddMenuItem(boxmenu, "0", "Disable");
  62. DisplayMenu(boxmenu, client, MENU_TIME_FOREVER);
  63. }
  64. else
  65. {
  66. PrintToChat(client, "\x04[SM]\x01 You have to be a Alive CT to Toggle Box.");
  67. }
  68. return Plugin_Handled;
  69. }
  70.  
  71. public BoxmenuHandler(Handle:boxmenu, MenuAction:action, iClient, iMenuItem)
  72. {
  73. new team = GetClientTeam(iClient);
  74. if(action == MenuAction_Select)
  75. {
  76. switch (iMenuItem)
  77. {
  78. case 0:
  79. {
  80. if(team == CS_TEAM_CT && IsPlayerAlive(iClient))
  81. {
  82. telleveryoneactivate(iClient);
  83. }
  84. else
  85. {
  86. PrintToChat(iClient, "\x04[SM]\x01 You have to be a Alive CT to Toggle Box.");
  87. }
  88. }
  89. case 1:
  90. {
  91. if(team == CS_TEAM_CT && IsPlayerAlive(iClient))
  92. {
  93. telleveryonedisabled(iClient);
  94. }
  95. else
  96. {
  97. PrintToChat(iClient, "\x04[SM]\x01 You have to be a Alive CT to Toggle Box.");
  98. }
  99. }
  100. }
  101. }
  102. else if(action == MenuAction_End)
  103. {
  104. CloseHandle(boxmenu);
  105. }
  106. }
  107.  
  108. public telleveryoneactivate(iClient)
  109. {
  110. if(boxenabled == true)
  111. {
  112. PrintToChat(iClient, "\x04[SM]\x01 Jailbreak Box is already enabled!");
  113. }
  114. else
  115. {
  116. decl String:name[MAX_NAME_LENGTH];
  117. GetClientName(iClient, name, sizeof(name));
  118. PrintToChatAll("\x04[SM]\x01 Box has been enabled by \x03%s\x01!", name);
  119. PrintCenterTextAll("Box has been enabled by \x03%s\x01!", name);
  120. SetConVarInt(gH_ff, 1);
  121. boxenabled = true;
  122. }
  123. }
  124.  
  125. public telleveryonedisabled(iClient)
  126. {
  127. if(boxenabled == true)
  128. {
  129. decl String:name[MAX_NAME_LENGTH];
  130. GetClientName(iClient, name, sizeof(name));
  131. PrintToChatAll("\x04[SM]\x01 Box has been disabled by \x03%s\x01!", name);
  132. PrintCenterTextAll("Box has been disabled by \x03%s\x01!", name);
  133. SetConVarInt(gH_ff, 0);
  134. boxenabled = false;
  135. }
  136. else
  137. {
  138. PrintToChat(iClient, "\x04[SM]\x01 Jailbreak Box is already disabled!");
  139. }
  140. }
  141.  
  142. stock bool:IsValidClient(client, bool:bAlive = false)
  143. {
  144. if(client >= 1 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && (bAlive == false || IsPlayerAlive(client)))
  145. {
  146. return true;
  147. }
  148. return false;
  149. }
Advertisement
Add Comment
Please, Sign In to add comment