Jump to content
  • 0

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


Mythryx

Question


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   0
  • Joined:  10/23/19
  • Last Seen:  

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

Any help would be very appreciated.

Thank you.

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  105
  • Topics Per Day:  0.02
  • Content Count:  446
  • Reputation:   229
  • Joined:  03/20/12
  • Last Seen:  

2 hours ago, Mythryx said:

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

Any help would be very appreciated.

Thank you.

https://rathena.org/board/files/file/4049-giveitem-command/

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   0
  • Joined:  10/23/19
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  49
  • Topics Per Day:  0.01
  • Content Count:  1511
  • Reputation:   227
  • Joined:  08/03/12
  • Last Seen:  

u need to whisper npc:gmnpc

About the map, I think because of new getmapxy 

https://github.com/rathena/rathena/blob/80810e24f820d0f5f92c3c62345de60a863eaf5a/doc/script_commands.txt#L3068

     getmapxy( .@map$,.@x,.@y,0,.@name$[.@i] );

try to change 0 to BL_PC

     getmapxy( .@map$,.@x,.@y,BL_PC,.@name$[.@i] );

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   0
  • Joined:  10/23/19
  • Last Seen:  

Thanks for all the answers!

 

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

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
Link to comment
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.

×
×
  • Create New...