HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /************************************************\
  2. ==================================
  3. * || [ZP] Donate Plugin v1.0|| *
  4. ==================================
  5. *by @bdul!*
  6.  
  7. -------------------
  8. *||DESCRIPTION||*
  9. -------------------
  10.  
  11. With this plugin u can donate ammo packs
  12. to others. Usage say:
  13. /donate <nickname> <amount>
  14.  
  15. \************************************************/
  16.  
  17. #include <amxmodx>
  18. #include <amxmisc>
  19. #include <zombieplague>
  20.  
  21. new const PLUGIN[] = "[ZP] Donate Plugin"
  22. new const AUTHOR[] = "@bdul!"
  23. new const VERSION[] = "1.0"
  24.  
  25. new g_msgSayText
  26.  
  27. public plugin_init()
  28. {
  29. register_plugin(PLUGIN, VERSION, AUTHOR)
  30.  
  31. register_clcmd("say", "handleSay")
  32. register_clcmd("say_team", "handleSay")
  33.  
  34. g_msgSayText = get_user_msgid("SayText")
  35. }
  36.  
  37.  
  38. public handleSay(id)
  39. {
  40. new args[64]
  41.  
  42. read_args(args, charsmax(args))
  43. remove_quotes(args)
  44.  
  45. new arg1[16]
  46. new arg2[32]
  47.  
  48. strbreak(args, arg1, charsmax(arg1), arg2, charsmax(arg2))
  49.  
  50. if (equal(arg1,"/kuldes", 7))
  51. donate(id, arg2)
  52.  
  53. }
  54.  
  55. public donate(id, arg[])
  56. {
  57. new to[32], count[10]
  58. strbreak(arg, to, 31, count, 9)
  59.  
  60. if (!to[0] || !count[0])
  61. {
  62. client_printcolor(0, "/g[ZP KULDES] /yLoszer csomag kuldesehez ird chatbe:/g /kuldes <NEV> <LOSZERCSOMAG>")
  63. return
  64. }
  65. new ammo_sender = zp_get_user_ammo_packs(id)
  66. new ammo
  67. if (equal(count, "all"))
  68. ammo = ammo_sender
  69. else
  70. ammo = str_to_num(count)
  71. if (ammo <= 0)
  72. {
  73. client_printcolor(id, "/g[ZP Donate] /yValami hibas,nez meg ujra mennyit akarsz kuldeni,meg hogy van e annyid! !")
  74. return
  75. }
  76. ammo_sender -= ammo
  77. if (ammo_sender < 0)
  78. {
  79. ammo+=ammo_sender
  80. ammo_sender = 0
  81.  
  82. }
  83. new reciever = cmd_target(id, to, (CMDTARGET_OBEY_IMMUNITY|CMDTARGET_ALLOW_SELF))
  84. if (!reciever || reciever == id)
  85. {
  86. client_printcolor(id, "/g[ZP Donate] /yNincs ilyen nev . ! Valamit elge'pelte'l")
  87. return
  88. }
  89.  
  90. zp_set_user_ammo_packs(reciever, zp_get_user_ammo_packs(reciever) + ammo)
  91. zp_set_user_ammo_packs(id, ammo_sender)
  92. new aName[32], vName[32]
  93.  
  94. get_user_name(id, aName, 31)
  95. get_user_name(reciever, vName, 31)
  96.  
  97. set_hudmessage(255, 10, 10, -1.0, 0.3, 1, 6.0, 6.0)
  98. show_hudmessage(id, "%s Kuldott %d Loszercsomagot neki %s", aName, ammo, vName)
  99.  
  100. set_hudmessage(255, 10, 10, -1.0, 0.3, 1, 6.0, 6.0)
  101. show_hudmessage(reciever, "%s Kuldott %d Loszercsomagot neki %s", aName, ammo, vName)
  102. }
  103.  
  104. stock client_printcolor(id, const input[], any:...)
  105. {
  106. new iCount = 1, iPlayers[32]
  107.  
  108. static szMsg[191]
  109. vformat(szMsg, charsmax(szMsg), input, 3)
  110.  
  111. replace_all(szMsg, 190, "/g", "^4") // green txt
  112. replace_all(szMsg, 190, "/y", "^1") // orange txt
  113. replace_all(szMsg, 190, "/ctr", "^3") // team txt
  114. replace_all(szMsg, 190, "/w", "^0") // team txt
  115.  
  116. if(id) iPlayers[0] = id
  117. else get_players(iPlayers, iCount, "ch")
  118.  
  119. for (new i = 0; i < iCount; i++)
  120. {
  121. if (is_user_connected(iPlayers[i]))
  122. {
  123. message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, iPlayers[i])
  124. write_byte(iPlayers[i])
  125. write_string(szMsg)
  126. message_end()
  127. }
  128. }
  129. }