Jump to content
  • 0

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


Question

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 .@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 );
        while( .@i < .@size ){
            if( .@aid[.@i] != .@self_id && !checkvending(.@name$[.@i]) ){
                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,.@aid[.@i];
                    set .@gave,.@gave + 1;
                }
            }
            set .@count,.@count + 1;
            set .@i,.@i + 1;
        }
        set .@offset,.@offset + .@size;
        deletearray .@aid,.@size;
        deletearray .@name$,.@size;
    }
    dispbottom "Gave "+.@amount+" x "+getitemname( .@itemid )+" to "+.@gave+" Player(s).";
}
end;
}

 

Edited by Mythryx
  • 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 (.@atcmd_parameters$[0] == "all" )
				.map$ = "all";
			else if (.@atcmd_parameters$[0] == "map" )
				.map$ = strcharinfo(3);
			else if (getmapusers(.@atcmd_parameters$[0]) >= 0)
				.map$ = .@atcmd_parameters$[0];
			else
				dispbottom "Error, pick 'map' or 'all' ";
				
			.itemid = atoi(.@atcmd_parameters$[1]);
			.amount = atoi(.@atcmd_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

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...