Jump to content

getobjects to get Player IDs on a map


Cydh

Recommended Posts


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

*getobjects(<type>,<data>{,"<map name>"{,<x1>,<y1>,<x2>,<y2>}})

Get object GIDs on specified location based on specified 'type'. The returned
value is number of all objects found. The GIDs is stored in temporary NPC
variables.

<type> can be combined value as bitwise of
	BL_PC   - Character object
	BL_MOB  - Monster object
	BL_PET  - Pet object
	BL_HOM  - Homunculus object
	BL_NPC  - NPC object
	BL_MER  - Mercenary object
	BL_ELEM - Elemental object

'data' values are bitmask of
	0x1 - GID (default)
	0x2 - Name
	0x4 - Char ID (only for BL_PC)
	0x8 - Class (Job ID for BL_PC, Sprite ID for BL_NPC, and Class
		  for other types)

Default 'map name' for look up is invoker location or NPC if no invoker found.

Object GID found will be saved in these arrays, while 'type' is value of
UNITTYPE_*. Use getd for good practice.

	.@obj_type_id[]
	.@obj_type_name$[]
	.@obj_type_cid[]
	.@obj_type_class[]

Example 1:

	getobjects(BL_PC,0x1);
	.@n = getarraysize(getd(".@obj_"+BL_PC+"_id"));
	for (.@i = 0; .@i < .@n; .@i++) {
		getitem 607,1,getd(".@obj_"+BL_PC+"_id["+.@i+"]");
	}

Example 2:

	getobjects(BL_PC|BL_NPC,0x1|0x2);
	// For players
	.@pc = getarraysize(getd(".@obj_"+BL_PC+"_id"));
	for (.@i = 0; .@i < .@pc; .@i++) {
		getitem 501,1,getd(".@obj_"+BL_PC+"_id["+.@i+"]");
	}
	// For NPCs
	.@npc = getarraysize(getd(".@obj_"+BL_NPC+"_id"));
	for (.@i = 0; .@i < .@npc; .@i++) {
		npctalk "My number is "+(.@i+1)+"",getd(".@obj_"+BL_NPC+"_name$["+.@i+"]");
	}

 

Keywords

how to get players (account id) on a map, how to get player/char name on a map, how to get char id on a map, how to get char's job on a map, how to get npc id on a map, how to get npc name on a map (exname with hidden part), how to get monster gid on a map, how to get monster name on a map, how to get monster id (class) on a map, .... so does with homunculus, elementals, pets, mercenaries

 

Downloads

Edited by Cydh
  • Upvote 6
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

There are lots of interesting release lately, thanks for this :))

Link to comment
Share on other sites

  • 4 weeks later...

  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

On 7/9/2018 at 3:13 PM, crazyarashi said:

There are lots of interesting release lately, thanks for this :))

glad u like it

 

just update the file for Git Hash: 65df844d (2018-08-06)

  • Since aleos added BL to script constants in previous mapflag cleanups, I just removed mine and add back BL_NPC
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
Reply to this topic...

×   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...