rootKid Posted August 15, 2013 Posted August 15, 2013 How would I go about fetching the list of players on a certain map, in order to give one of the players an item? Quote
Skorm Posted August 16, 2013 Posted August 16, 2013 Could you give an example of how that is used? Say for example, to give an apple to a random player on that specific map? prontera,150,150,5 script Give Item 100,{ set(.player,getcharid(3)); deletearray(.players[0],128); addrid(1); set(.players[getarraysize(.players)],getcharid(3)); detachrid; attachrid(.player); getitem(512,1,set(.@a,.players[rand(getarraysize(.players))])); npctalk rid2name(.@a)+" got a Apple!"; end; } This is untested by me O_O and might not work because it will all happen at once. Tested working perfectly. Quote
Patskie Posted August 15, 2013 Posted August 15, 2013 Reference : http://rathena.org/wiki/Getusers getusers(0); Quote
rootKid Posted August 15, 2013 Author Posted August 15, 2013 I don't want a count of the players on the map. I want a list of players which then I can attach a rid to in order to do what I want with the player after Quote
Emistry Posted August 15, 2013 Posted August 15, 2013 doc/script_commands.txt#L3535 *addrid(<type>{,<flag>{,<parameters>}}); This command will attach other RIDs to the current script without detaching the invoking RID. It returns 1 if successful and 0 upon failure. <type> determines what RIDs are attached: 0: All players in the server. 1: All players in the map of the invoking player, or the invoking NPC if no player is attached. 2: Party members of a specified party ID. [ Parameters: <party id> ] 3: Guild members of a specified guild ID. [ Parameters: <guild id> ] 4: All players in a specified area of the map of the invoking player (or NPC). [ Parameters: <x0>,<y0>,<x1>,<y1> ] Account ID: The specified account ID. <flag> can prevent certain players from being attached: 0: Players are always attached. (default) 1: Players currently running another script will not be attached. 1 Quote
rootKid Posted August 16, 2013 Author Posted August 16, 2013 Could you give an example of how that is used? Say for example, to give an apple to a random player on that specific map? Quote
Capuche Posted August 16, 2013 Posted August 16, 2013 - script ijnoo -1,{ OnWhisperGlobal: deletearray .aid, .size_aid; deletearray .cid, .size_aid; deletearray .name$, .size_aid; .size_aid = 0; .@myaid = playerattached(); addrid(1);// attach all player on your map to the script if ( .size_aid < 128 && playerattached() != .@myaid ) { .aid[ .size_aid ] = playerattached(); .cid[ .size_aid ] = getcharid(0); .name$[ .size_aid ] = strcharinfo(0); .size_aid++; } if ( playerattached() != .@myaid ) end; while( .@i < .size_aid ) { .@menu$ = .@menu$ + .name$[.@i] +":"; .@i++; } mes "Select a player you want to give a reward."; next; .@s = select( .@menu$ ) -1; callsub L_check, .@s; mes "Item id"; input .@atoi_id; if ( getiteminfo( .@atoi_id,0 ) == -1 ) { mes "This item doesn't exist"; close; } mes "amount?"; input .@amount; if ( .@amount < 1 ) { mes "You can't send "+ .@amount +" item."; close; } next; mes "Give a ^ff0000"+ getitemname( .@atoi_id ) +" ("+ .@atoi_id +")^000000 x"+ .@amount +" to "+ .name$[.@s] +" ?"; next; if ( select( "Yes", "No" ) == 2 ) close; callsub L_check, .@s; getitem .@atoi_id, .@amount, .aid[.@s]; mes "The player get the reward."; close; L_check: .@s = getarg(0); if ( !isloggedin( .aid[.@s], .cid[.@s] ) ) { mes "this player is not online."; close; } else if ( !getmapxy( .@map$, .@x, .@y, 0, .name$[.@s] ) && .@map$ != strcharinfo(3) ) { mes "this player is no more on the same map of you."; close; } return; } whisper the npc ijnoo to give a reward to a player on your map Quote
rootKid Posted August 16, 2013 Author Posted August 16, 2013 (edited) Thank you very much. Edited August 16, 2013 by kou Quote
Question
rootKid
How would I go about fetching the list of players on a certain map, in order to give one of the players an item?
7 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.