yuhsing

Untitled

Oct 13th, 2013
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. // usage :
  2. // [npc:Sample]map#512#10
  3. // [npc:Sample]all#512#123
  4.  
  5.  
  6. - script Sample -1,{
  7. OnWhisperGlobal:
  8. if( getgmlevel() >= 99 ){
  9. // check map
  10. if( @whispervar0$ == "all" ) set .@type$,"";
  11. else if( @whispervar0$ == "map" ) set .@type$,strcharinfo(3);
  12. else {
  13. dispbottom "Error, pick 'map' or 'all' ";
  14. end;
  15. }
  16.  
  17. // check item
  18. set .@itemid,atoi( @whispervar1$ );
  19. set .@amount,atoi( @whispervar2$ );
  20. if( getitemname( .@itemid ) == "null" || .@amount < 1 ){
  21. dispbottom "Enter valid item id and amount.";
  22. }
  23.  
  24. set .@self_id,getcharid(3);
  25. query_sql( "SELECT COUNT(`account_id`) FROM `char` WHERE `online` = 1 ", .@total );
  26. while( .@count < .@total ){
  27. query_sql( "SELECT `account_id`,`name` FROM `char` WHERE `online` = 1 ORDER BY `account_id` LIMIT 128 OFFSET "+.@offset, .@aid,.@name$ );
  28. set .@i,0;
  29. set .@size,getarraysize( .@aid );
  30. while( .@i < .@size ){
  31. if( .@aid[.@i] != .@self_id ){
  32. if( .@type$ != "" ){
  33. getmapxy( .@map$,.@x,.@y,0,.@name$[.@i] );
  34. if( .@map$ == .@type$ ){
  35. getitem .@itemid,.@amount,.@aid[.@i];
  36. set .@gave,.@gave + 1;
  37. }
  38. }else{
  39. getitem .@itemid,.@amount,.@aid[.@i];
  40. set .@gave,.@gave + 1;
  41. }
  42. }
  43. set .@count,.@count + 1;
  44. set .@i,.@i + 1;
  45. }
  46. set .@offset,.@offset + .@size;
  47. deletearray .@aid,.@size;
  48. deletearray .@name$,.@size;
  49. }
  50. dispbottom "Gave "+.@amount+" x "+getitemname( .@itemid )+" to "+.@gave+" Player(s).";
  51. }
  52. end;
  53. }
Add Comment
Please, Sign In to add comment