Jump to content
  • 0

Question

Posted

Can somebody create a source mod that creates an array of online player data? Basically it would be like using getpartymember for online characters. Of course there will be some challanges such as the max array size, but it can be limited to a maximum number of arrays to prevent errors. A command like this could be used to easily give items to the entire server in an event or many other uses. I strongly believe that if somebody takes the time to create this it should be added to the SVN due to its possible uses!!!

I just cheaply took the getpartymember and changed it as an example of what it could be.

*getonlinemember <type>{,<maxelement>};

This command will find all online members and return the information depending on the value of "type" into an array of temporary global variables. Maxelement is the maximum amount of elements that an array will pull. Above this number the array will ignore all further elements. By default the maxelement is set to X.

Upon executing this,
$@onlinemembername$[] is a global temporary string array which contains all the names of online members.
				 (only set when type is 0 or not specified)
$@onlinemembercid[]   is a global temporary number array which contains the character id of online members.
				 (only set when type is 1)
$@onlinememberaid[]   is a global temporary number array which contains the account id of online members.
				 (only set when type is 2)
$@onlinemembercount   is the number of online members that were found.

Be sure to use $@onlinemembercount to go through this array, and not
'getarraysize', because it is not cleared between runs of 'getonlinemember'. If
someone uses this command with 30 online members when they invoke this script, the array would have 30
elements. But if another person calls up the NPC, and there is now 15 online members, the
server will not clear the array for you, overwriting the previous values instead while leaving any remaining values. So in
addition to returning the 15 member names, the additional 15 elements from the last
call remain, and you will get 15+15 members, of which the last 15 don't belong.
$@onlinemembercount will always contain the correct number, (15) unlike 'getarraysize()' which will return 30 in this case.

Example:
getonlinemember 1;
for(set .@i,0; .@i<$@onlinemembercount; set .@i,.@i+1)  { getitem .ItemType,.ItemAmount,$@onlinememberaid[.@i]; }
end;

4 answers to this question

Recommended Posts

Posted (edited)

idea architecture

map_foreachpc....
{
amount++
mapreg_setreg... reference_uid... add_str... "$@onlinememberaid_%d" ; %d = amount/128
...
}

EDIT:

(Auto-Delete After 1 Month)

Raw : http://pastebin.com/raw.php?i=dKRsRUjm

Download : http://pastebin.com/download.php?i=dKRsRUjm

PreView : http://goo.gl/9Fx9V

EDIT 2:

This is a sample of how I record AID.

EDIT 3:

seen I have used setd, I think we don't need to care array limit anymore

just make it be $@onlineaid_%d ; %d = sequence

Edited by goddameit
Posted (edited)

Thanks for your work. It was so much smaller than I puctured it! I figured it would be several different src files that all need modifying. Does this only give the number of people online or does it give account ids? Can it be used as part of the getitem?

Peopleperson49

Edited by Peopleperson49
Posted

Thanks for your work. It was so much smaller than I puctured it! I figured it would be several different src files that all need modifying. Does this only give the number of people online or does it give account ids? Can it be used as part of the getitem?

Peopleperson49

have you read it?

Posted

prontera,155,180,4	script	Test	100,{	
getonlinemember;
Announce "$@onlinecount:"+$@onlinecount,0;
set .@j,$@onlinecount/128;
for(set .@i,0;.@i<=.@j;set .@i,.@i+1)
	for(set .@k,0;set(.@u,getd("$@onlineaid_"+.@i+"_"+.@k+""));set .@k,.@k+1){
		getitem 501, 1, .@u;
		dispbottom ""+.@u;
}
end;
}

I have to say I tested his source modification ... it really works

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