Mythryx Posted March 4, 2020 Posted March 4, 2020 As title says, would it be possible? Fairly new with scripting and is still learning. Any help would be very appreciated. Thank you. Quote
0 Mabuhay Posted March 4, 2020 Posted March 4, 2020 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/ Quote
0 Mythryx Posted March 5, 2020 Author Posted March 5, 2020 (edited) On 3/4/2020 at 10:35 PM, Mabuhay said: https://rathena.org/board/files/file/4049-giveitem-command/ 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 March 5, 2020 by Mythryx Quote
0 Chaos92 Posted March 15, 2020 Posted March 15, 2020 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] ); Quote
0 Emistry Posted March 16, 2020 Posted March 16, 2020 (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 March 16, 2020 by Emistry Quote
Question
Mythryx
As title says, would it be possible? Fairly new with scripting and is still learning.
Any help would be very appreciated.
Thank you.
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.