Guest User

Untitled

a guest
Jan 18th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. //================= Hercules Script=======================================
  2. //= _ _ _
  3. //= | | | | | |
  4. //= | |_| | ___ _ __ ___ _ _| | ___ ___
  5. //= | _ |/ _ \ '__/ __| | | | |/ _ \/ __|
  6. //= | | | | __/ | | (__| |_| | | __/\__ \
  7. //= \_| |_/\___|_| \___|\__,_|_|\___||___/
  8. //================= License===============================================
  9. //= This file is part of Hercules.
  10. //= http: //herc.ws - http: //github.com/HerculesWS/Hercules
  11. //=
  12. //= Copyright (C) Emistry
  13. //= Copyright (C) Ridley
  14. //=
  15. //= Hercules is free software: you can redistribute it and/or modify
  16. //= it under the terms of the GNU General Public License as published by
  17. //= the Free Software Foundation, either version 3 of the License, or
  18. //= (at your option) any later version.
  19. //=
  20. //= This program is distributed in the hope that it will be useful,
  21. //= but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. //= MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. //= GNU General Public License for more details.
  24. //=
  25. //= You should have received a copy of the GNU General Public License
  26. //= along with this program. If not, see <http: //www.gnu.org/licenses/>.
  27. //=========================================================================
  28. //= @itemall to give item to all players online
  29. //= @itemmap to give item to all players on same map as you
  30. //================= Description===========================================
  31. //= Use command to track a specific player
  32. //================= Current Version=======================================
  33. //= 1.0a
  34. //=========================================================================
  35.  
  36. - script atcmd_item FAKE_NPC,{
  37.  
  38. // configuration start
  39. OnInit:
  40. bindatcmd("itemmap", strnpcinfo(NPC_NAME) +"::OnAtcommanda", 14, 99); // who can use it?
  41. bindatcmd("itemall", strnpcinfo(NPC_NAME) +"::OnAtcommandb", 14, 99); // who can use it?
  42. .max = 50; // max amount of items to give out at once
  43. end;
  44. // configuration end
  45.  
  46. OnAtcommanda:
  47. .@type = 1; // @itemmap
  48. .@gmmap$ = strcharinfo(PC_MAP);
  49. OnAtcommandb:
  50. if (.@atcmd_numparameters <= 1) { // need to input something
  51. message(strcharinfo(PC_NAME), sprintf(_$("Usage: %s <Item ID>, <Amount"), .@atcmd_command$));
  52. message(strcharinfo(PC_NAME), sprintf(_$("%s failed."), .@atcmd_command$));
  53. end;
  54. }
  55. .@itemid = atoi(.@atcmd_parameters$[0]); // check item
  56. .@amount = atoi(.@atcmd_parameters$[1]);
  57. if (getitemname(.@itemid) == "null") {
  58. message(strcharinfo(PC_NAME), "Item not found.");
  59. end;
  60. } else if (.@amount == 0 || .@amount > .max) {
  61. message(strcharinfo(PC_NAME), sprintf(_$("Invalid amount of Items. Needs to be between 1 and %d."), .max));
  62. end;
  63. }
  64. .@self_id = getcharid(CHAR_ID_ACCOUNT);
  65. if (!.@type)
  66. .@users = getusers(1);
  67. else
  68. .@users = getusers(0);
  69. while (.@count < .@users) { // Emistry Function
  70. query_sql("SELECT `account_id`, `name` FROM `char` WHERE `online` = 1 ORDER BY `account_id` LIMIT 128 OFFSET "+.@offset, .@aids, .@name$);
  71. .@i = 0;
  72. .@size = getarraysize(.@aids);
  73. while (.@i < .@size) {
  74. if (.@aids[.@i] != .@self_id) {
  75. if (.@type == 1) {
  76. getmapxy(.@map$, .@x, .@y, 0, .@name$[.@i]);
  77. if (.@map$ == .@gmmap$) {
  78. getitem(.@itemid, .@amount, .@aids[.@i]);
  79. .@gave++;
  80. }
  81. } else {
  82. getitem(.@itemid, .@amount, .@aids[.@i]);
  83. .@gave++;
  84. }
  85. }
  86. .@count++;
  87. .@i++;
  88. }
  89. .@offset = .@offset + .@size;
  90. deletearray(.@aids, .@size);
  91. deletearray(.@name$, .@size);
  92. }
  93. dispbottom(sprintf(_$("Gave %d x %s to %d Players."), .@amount, getitemname(.@itemid), .@gave));
  94. }
Add Comment
Please, Sign In to add comment