• 0
Sign in to follow this  
Mythryx

Requesting an NPC that let's GM's send items to players in a specific Map.

Question

As title says, would it be possible? Fairly new with scripting and is still learning.

Any help would be very appreciated.

Thank you.

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0
Posted (edited)
On 3/4/2020 at 10:35 PM, Mabuhay said:

How would I actually use this? Sorry fairly new.

Requesting help regarding this script. all#item#amount works but when i use map#item#amount it doesn't give out the items.

-    script    gmnpc        -1,{
OnWhisperGlobal:
if( getgroupid() >= 99 ){
    // check map
    if( @whispervar0$ == "all" ) set [email protected]$,"";
    else if( @whispervar0$ == "map" ) set [email protected]$,strcharinfo(3);
    else {
        dispbottom "Error, pick 'map' or 'all' ";
        end;
    }
    
    // check item
    set [email protected],atoi( @whispervar1$ );
    set [email protected],atoi( @whispervar2$ );
    if( getitemname( [email protected] ) == "null" || [email protected] < 1 ){
        dispbottom "Enter valid item id and amount.";
    }
    
    set [email protected]_id,getcharid(3);
    query_sql( "SELECT COUNT(`account_id`) FROM `char` WHERE `online` = 1 ", [email protected] );
    while( [email protected] < [email protected] ){
        query_sql( "SELECT `account_id`,`name` FROM `char` WHERE `online` = 1 ORDER BY `account_id` LIMIT 128 OFFSET "[email protected], [email protected],[email protected]$ );
        set [email protected],0;
        set [email protected],getarraysize( [email protected] );
        while( [email protected] < [email protected] ){
            if( [email protected][[email protected]] != [email protected]_id && !checkvending([email protected]$[[email protected]]) ){
                if( [email protected]$ != "" ){
                    getmapxy( [email protected]$,[email protected],[email protected],0,[email protected]$[[email protected]] );
                    if( [email protected]$ == [email protected]$ ){
                        getitem [email protected],[email protected],[email protected][[email protected]];
                        set [email protected],[email protected] + 1;
                    }
                }else{
                    getitem [email protected],[email protected],[email protected][[email protected]];
                    set [email protected],[email protected] + 1;
                }
            }
            set [email protected],[email protected] + 1;
            set [email protected],[email protected] + 1;
        }
        set [email protected],[email protected] + [email protected];
        deletearray [email protected],[email protected];
        deletearray [email protected]$,[email protected];
    }
    dispbottom "Gave "[email protected]+" x "+getitemname( [email protected] )+" to "[email protected]+" Player(s).";
}
end;
}

 

Edited by Mythryx

Share this post


Link to post
Share on other sites
  • 0

Share this post


Link to post
Share on other sites
  • 0

Thanks for all the answers!

 

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

if you're using a newer version of rAthena

-	script	Sample	-1,{
	
	OnInit:
		bindatcmd "reward",strnpcinfo(3) + "::OnAtcommand", 99, 99;
		end;
		
	OnAtcommand:
		if (getgroupid() >= 99) {
			if ([email protected]_parameters$[0] == "all" )
				.map$ = "all";
			else if ([email protected]_parameters$[0] == "map" )
				.map$ = strcharinfo(3);
			else if (getmapusers([email protected]_parameters$[0]) >= 0)
				.map$ = [email protected]_parameters$[0];
			else
				dispbottom "Error, pick 'map' or 'all' ";
				
			.itemid = atoi([email protected]_parameters$[1]);
			.amount = atoi([email protected]_parameters$[2]);
			
			if (getitemname(.itemid) == "null" || .amount < 1)
				dispbottom "Invalid item id #"+.itemid+" and amount ("+.amount+").";
			else donpcevent strnpcinfo(3)+"::OnReward";
		}
		end;
		
	OnWhisperGlobal:
		if (getgroupid() >= 99) {
			if (@whispervar0$ == "all" )
				.map$ = "all";
			else if (@whispervar0$ == "map" )
				.map$ = strcharinfo(3);
			else if (getmapusers(@whispervar0$) >= 0)
				.map$ = @whispervar0$;
			else
				dispbottom "Error, pick 'map' or 'all' ";
				
			.itemid = atoi(@whispervar1$);
			.amount = atoi(@whispervar2$);
			
			if (getitemname(.itemid) == "null" || .amount < 1)
				dispbottom "Invalid item id #"+.itemid+" and amount ("+.amount+").";
			else donpcevent strnpcinfo(3)+"::OnReward";
		}
		end;
		
	OnReward:
		if (.map$ == "all")
			addrid(0);
		else if (.map$ != "")
			addrid(5, 0, .map$);
		
		getitem .itemid, .amount;
		end;
}
[npc:Sample] <map_mapname|map|all>#512#100
@reward <map_name|map|all> 512 100

 

Edited by Emistry

Share this post


Link to post
Share on other sites

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.

Sign in to follow this