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;
Question
Peopleperson49
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.
Link to comment
Share on other sites
4 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.