HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* Plugin Template generated by Pawn Studio */
  2.  
  3. #include <sourcemod>
  4.  
  5. new Handle:Enabled
  6. new Handle:pBonus
  7. new Handle:dBonus
  8. new bool:g_isHooked
  9.  
  10. new g_iAccount
  11.  
  12. public Plugin:myinfo =
  13. {
  14. name = "Plant/Defuse Money",
  15. author = "Fredd",
  16. description = "Penzt kap a jatekos ha elesiti/hatastalanitja a bombat!",
  17. version = "1.0",
  18. url = "www.sourcemod.net"
  19. }
  20.  
  21. public OnPluginStart()
  22. {
  23. CreateConVar("pdm_version", "1.0")
  24.  
  25. Enabled = CreateConVar("pdm_enabled", "1", "Plugin ki/be kapcsolasa (1/0) (Alap:1-bekapcsolva)")
  26. dBonus = CreateConVar("pdm_defuse", "500", "Ennyi penzt kap aki hatastalanitja a bombat (alap:500)")
  27. pBonus = CreateConVar("pdm_plant", "500", "Ennyi penzt kap aki elesiti a bombat (alap:500)")
  28.  
  29. g_iAccount = FindSendPropOffs("CCSPlayer", "m_iAccount")
  30.  
  31. HookEvent("bomb_planted", BombPlanted)
  32. HookEvent("bomb_defused", BombDefused)
  33.  
  34. HookConVarChange(Enabled, ConvarChanged)
  35. }
  36. public OnPluginEnd()
  37. {
  38. if (g_isHooked == true)
  39. {
  40. UnhookEvent("bomb_planted", BombPlanted)
  41. UnhookEvent("bomb_defused", BombDefused)
  42. }
  43.  
  44. UnhookConVarChange(Enabled, ConvarChanged);
  45. }
  46. public ConvarChanged(Handle:convar, const String:oldValue[], const String:newValue[])
  47. {
  48. new value = !!StringToInt(newValue);
  49. if (value == 0)
  50. {
  51. if (g_isHooked == true)
  52. {
  53. g_isHooked = false;
  54.  
  55. UnhookEvent("bomb_planted", BombPlanted)
  56. UnhookEvent("bomb_defused", BombDefused)
  57. }
  58. }
  59. else
  60. {
  61. g_isHooked = true;
  62.  
  63. HookEvent("bomb_planted", BombPlanted)
  64. HookEvent("bomb_defused", BombDefused)
  65.  
  66. }
  67. }
  68. public Action:BombPlanted(Handle:event, const String:name[], bool:dontBroadcast)
  69. {
  70. new client = GetClientOfUserId(GetEventInt(event, "userid"))
  71.  
  72. SetMoney(client, (GetMoney(client) + GetConVarInt(pBonus)))
  73.  
  74. return Plugin_Continue;
  75. }
  76. public Action:BombDefused(Handle:event, const String:name[], bool:dontBroadcast)
  77. {
  78. new client = GetClientOfUserId(GetEventInt(event, "userid"))
  79.  
  80. SetMoney(client, (GetMoney(client) + GetConVarInt(dBonus)))
  81.  
  82. return Plugin_Continue;
  83. }
  84. public GetMoney(client)
  85. {
  86. if(g_iAccount != -1)
  87. {
  88. return GetEntData(client, g_iAccount);
  89. }
  90. return 0;
  91. }
  92. public SetMoney(client, amount)
  93. {
  94. if(g_iAccount != -1)
  95. {
  96. SetEntData(client, g_iAccount, amount);
  97. }
  98. }
  99.  
  100.