Jump to content
  • 0

request: Item drop at random player position


AsuraBro

Question


  • Group:  Members
  • Topic Count:  19
  • Topics Per Day:  0.00
  • Content Count:  74
  • Reputation:   3
  • Joined:  07/12/14
  • Last Seen:  

Hello,

 

i have a request of script that drops an item at random player location.

 

for ex i want to drop item id 501 every 10 ~ 20 hour at a random player from the server (where ever he is at his location).

 

also if possible to make it check if player talking to npc / used teleporting item in the past 2~5 sec would be cool.

 

even getitem is cool.

 

thank you.

 

EDIT:

 

i tried and made progress with this script

// usage :
// [npc:Sample]map#512#10
// [npc:Sample]all#512#123


-	script	Sample	-1,{
OnWhisperGlobal:
if( getgmlevel() >= 99 ){
	// check map
	if( @whispervar0$ == "all" ) set .@type$,"";
	else if( @whispervar0$ == "map" ) set .@type$,strcharinfo(3);
	else {
		dispbottom "Error, pick 'map' or 'all' ";
		end;
	}
	
	// check item
	set .@itemid,atoi( @whispervar1$ );
	set .@amount,atoi( @whispervar2$ );
	if( getitemname( .@itemid ) == "null" || .@amount < 1 ){
		dispbottom "Enter valid item id and amount.";
	}
	
	set .@self_id,getcharid(3);
	query_sql( "SELECT COUNT(`account_id`) FROM `char` WHERE `online` = 1 ", .@total );
	while( .@count < .@total ){
		query_sql( "SELECT `account_id`,`name` FROM `char` WHERE `online` = 1 ORDER BY `account_id` LIMIT 128 OFFSET "+.@offset, .@aid,.@name$ );
		set .@i,0;
		set .@size,getarraysize( .@aid );
		set .@randomplayer, .@aid[rand(getarraysize(.@aid))];
		while( .@i < .@size ){
			if( .@aid[.@i] != .@self_id ){
				if( .@type$ != "" ){
					getmapxy( .@map$,.@x,.@y,0,.@name$[.@i] );
					if( .@map$ == .@type$ ){
						getitem .@itemid,.@amount,.@aid[.@i];
						set .@gave,.@gave + 1;
					}
				}else{
					getitem .@itemid,.@amount,.@randomplayer;
					set .@gave,.@gave + 1;
				}
			}
			set .@count,.@count + 1;
			set .@i,.@i + 1;
		}
		set .@offset,.@offset + .@size;
		deletearray .@aid,.@size;
		deletearray .@name$,.@size;
	}
	announce "Player "+ .@randomplayer + " has recevied " + .@amount + "x " + getitemname( .@itemid ),0;
}
end;
}

but the thing is i want it to be automatic script, like every X hour give item, and it can be more simple than this, but i have no experience in this thing :(

 

ref to

https://rathena.org/board/topic/75469-qselect-random-player-in-map/?p=162586

https://rathena.org/board/topic/86246-i-need-npc-item-rewards-for-all-online-players/?p=216803

 

solved in https://rathena.org/board/topic/104224-can-someone-please-show-me-what-is-wrong-with-this-script/

Edited by AsuraBro
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...