HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*
  2. botdropbomb.sp
  3.  
  4. Description:
  5. Drop the Bomb Plugin for SourceMod. Lets players tell nearby bots to drop the bomb so they can complete their objectives.
  6.  
  7. Credits:
  8. Thanks to everyone in the scripting forum. You guys have been super supportive of all my questions.
  9.  
  10. Versions:
  11. 1.0
  12. * Initial Release
  13.  
  14. 1.1
  15. * Added an admin command sm_dropbomb
  16.  
  17. Fordította: BBk
  18. */
  19.  
  20.  
  21. #include <sourcemod>
  22. #include <sdktools>
  23.  
  24. #pragma semicolon 1
  25.  
  26. #define PLUGIN_VERSION "1.1"
  27.  
  28. // Plugin definitions
  29. public Plugin:myinfo =
  30. {
  31. name = "Bot, drop the bomb",
  32. author = "dalto",
  33. description = "Lehetove teszi a jatekosok szamara, hogy a kozelben levo botok eltudjak dobni a bombat, igy teljesitheto a kuldetes.",
  34. version = PLUGIN_VERSION,
  35. url = "http://forums.alliedmods.net"
  36. };
  37.  
  38. // Global Variables
  39. new Handle:hGameConf = INVALID_HANDLE;
  40. new Handle:hDropWeapon = INVALID_HANDLE;
  41.  
  42. public OnPluginStart()
  43. {
  44. // Create the CVARs
  45. CreateConVar("sm_bot_drop_bomb_version", PLUGIN_VERSION, "Bot, Bomba Eldobas Verzio", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
  46.  
  47. // Load the gamedata file
  48. hGameConf = LoadGameConfigFile("botdropbomb.games");
  49. if(hGameConf == INVALID_HANDLE)
  50. {
  51. SetFailState("gamedata/botdropbomb.games.txt not loadable");
  52. }
  53.  
  54. StartPrepSDKCall(SDKCall_Player);
  55. PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "CSWeaponDrop");
  56. PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer);
  57. PrepSDKCall_AddParameter(SDKType_Bool, SDKPass_Plain);
  58. PrepSDKCall_AddParameter(SDKType_Bool, SDKPass_Plain);
  59. hDropWeapon = EndPrepSDKCall();
  60.  
  61. RegConsoleCmd("say", CommandSay);
  62. RegConsoleCmd("say_team", CommandSay);
  63. RegAdminCmd("sm_dropbomb", CommandDropBomb, ADMFLAG_GENERIC);
  64. }
  65.  
  66. public Action:CommandSay(client, args)
  67. {
  68. if(client < 1 || client > GetMaxClients() || !IsClientInGame(client))
  69. {
  70. return Plugin_Continue;
  71. }
  72.  
  73. // Get the command argument
  74. new String:buffer[20];
  75. decl String:buffer2[20];
  76.  
  77. for(new i = 0; i < args; i++)
  78. {
  79. GetCmdArg(i + 1, buffer2, sizeof(buffer2));
  80. if(buffer[0] == 0)
  81. {
  82. buffer = buffer2;
  83. } else {
  84. Format(buffer, sizeof(buffer), "%s %s", buffer, buffer2);
  85. }
  86. }
  87.  
  88. if(strcmp(buffer, "drop the bomb") == 0)
  89. {
  90. new team = GetClientTeam(client);
  91. new Float:clientVec[3];
  92. GetClientAbsOrigin(client, clientVec);
  93. for(new i = 1; i <= GetMaxClients(); i++)
  94. {
  95. if(IsClientInGame(i) && IsFakeClient(i) && GetPlayerWeaponSlot(i, 4) != -1 && GetClientTeam(i) == team)
  96. {
  97. new Float:botVec[3];
  98. GetClientAbsOrigin(i, botVec);
  99. if(GetVectorDistance(clientVec, botVec) < 750)
  100. {
  101. SDKCall(hDropWeapon, i, GetPlayerWeaponSlot(i, 4), false, false);
  102. }
  103. }
  104. }
  105. }
  106. return Plugin_Continue;
  107. }
  108.  
  109. public Action:CommandDropBomb(client, args)
  110. {
  111. for(new i = 1; i <= GetMaxClients(); i++)
  112. {
  113. if(IsClientInGame(i) && GetPlayerWeaponSlot(i, 4) != -1)
  114. {
  115. SDKCall(hDropWeapon, i, GetPlayerWeaponSlot(i, 4), false, false);
  116. }
  117. }
  118.  
  119. return Plugin_Handled;
  120. }