Skip to content

Conversation

@bWolfie
Copy link
Contributor

@bWolfie bWolfie commented Oct 17, 2018

Pull Request Prelude

Changes Proposed

Adds BUILDIN(getguildonline) which returns the amount of players online in a guild.
Optional param for type, which will exclude vendor characters from the count.
Returns -1 if guild not found.

I know getguildmember() can perform this functionality, but this is quicker and cleaner for scripters IMO.

Affected Branches:

  • master
  • stable

Issues addressed:

N/A

Known Issues and TODO List

N/A

@HerculesWSAPI
Copy link
Contributor

This change is Reviewable

@Emistry
Copy link
Member

Emistry commented Oct 17, 2018

well, in other way, vending player does consider online too ... it kinda beat the purpose aren't?
getguildmember + isloggedin could do the same? this could end up become redundant in future.


---------------------------------------

*getguildonline(<guild id>{, <type>});

This comment was marked as resolved.

src/map/script.c Outdated
if (script_hasdata(st, 3))
type = script_getnum(st, 3);

if (type == 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here better use constants too

src/map/script.c Outdated
struct map_session_data *sd;
for (int i = 0; i < MAX_GUILD; i++) {
sd = g->member[i].sd;
if (sd != NULL && sd->state.vending == 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably also better check g->member[i].online

@bWolfie bWolfie force-pushed the getguildonline branch 3 times, most recently from cb1d089 to a5b4c3d Compare October 18, 2018 10:44
@Emistry Emistry added component:core:scriptengine Affecting the script engine or the script commands component:documentation Affecting the documentation in the doc/ folder labels Oct 19, 2018
@AnnieRuru
Copy link
Contributor

AnnieRuru commented Jan 27, 2019

not really sure about this, but this feels like open a Pandora box
if this is allow, actually mean we are also missing
getclanmemberonline
getpartymemberonline
getpartymemberininstanceonline
getguildmemberininstanceonline
getclanmemberininstanceonline
getinstanceonline
getmaponline --- different from getmapusers because that couldn't count autotraders
getareauseronline -- different from getareausers ....
blah blah blah ....

oh and .... event script included !!
getarrayonline - count all players GID in the array, if player cheat in the event using autotrade

what else ?
I rather stick to getpartymember and getguildmember ... and maybe getunits

ok serious, If I actually want to write this for my private MVP room,
I will also add
getguildonline(<guild id>{, <type>, <map name>});

if ( !getguildonline( getcharid(CHAR_ID_GUILD), GUILD_ONLINE_ALL, strnpcinfo(NPC_MAP) ) )
mapannounce strnpcinfo(NPC_MAP), "All "+ strcharinfo(PC_GUILD) +" has quit from this event", bc_map;

OH AND ... if I have guild castle instance script,
getguildonline(<guild id>{, <type>, <instance ID>});
.... now I feel this PR can only do very limited stuffs, and can expand so much more

@dastgirp
Copy link
Member

I do agree, some commands can be useful like:
getclanmemberonline
getpartymemberonline

But I don't think we need instance based commands.

Also all other things you mentioned can be done with getunits command

@AnnieRuru
Copy link
Contributor

AnnieRuru commented Jan 27, 2019

But I don't think we need instance based commands.

why not ? this script command looks custom enough, and not use in any official script
means we can also expand to use this script command in certain custom made instance script

just the example I said, an instance guild base
so the guild master needs to know how many guild members are currently in the guild base

Details
prontera,155,180,0	script	Test Instance	1_F_MARIA,{
	if ( has_instance2("guild_vs1") >= 0 ) {
		warp has_instance("guild_vs1"), 49,49;
		end;
	}
	if ( ( .@ins = instance_create( "Test Instance", getcharid(CHAR_ID_GUILD), IOT_GUILD ) ) < 0 ) {
		mes "error : "+ .@ins;
		close;
	}
	for ( .@i = 0; .@i < 5; ++.@i ) {
		setarray .@inst_map$, "guild_vs1", "guild_vs2", "guild_vs3", "guild_vs4", "guild_vs5";
		if ( !getstrlen( instance_attachmap( .@inst_map$[.@i], .@ins, true, .@ins +"gcastle"+ .@i ) ) ) {
			mes "error : 5";
			instance_destroy .@ins;
			close;
		}
	}
	instance_set_timeout 0, 15, .@ins;
	instance_init .@ins;
	warp has_instance("guild_vs1"), 49,49;
	end;
}
//	lazy to code some warping points
guild_vs1,49,49,5	script	test dialog	1_F_MARIA,{
//	dispbottom strnpcinfo(4) +" "+ strcharinfo(3);
	.@origin = getcharid(CHAR_ID_ACCOUNT);
	getguildmember getcharid(CHAR_ID_GUILD), 1;
	getguildmember getcharid(CHAR_ID_GUILD), 2;
	for ( .@i = 0; .@i < $@guildmembercount; ++.@i ) {
		if ( isloggedin( $@guildmemberaid[.@i], $@guildmembercid[.@i] ) ) {
			attachrid $@guildmemberaid[.@i];
			setarray .@inst_map$, "guild_vs1", "guild_vs2", "guild_vs3", "guild_vs4", "guild_vs5";
			for ( .@j = 0; .@j < 5; ++.@j ) {
				if ( strcharinfo(PC_MAP) == has_instance(.@inst_map$[.@j]) ) {
					++.@online;
					break;
				}
			}
		}
	}
	attachrid .@origin;
	mes "There are "+ .@online +" guild member within guild castle";
	close;
}
OF COURSE I tested in-game

https://raw.githubusercontent.com/AnnieRuru/customs/master/screenshots/screen2019Hercules005.jpg

have fun shorten these lines into a single script command

	getguildmember getcharid(CHAR_ID_GUILD), 1;
	getguildmember getcharid(CHAR_ID_GUILD), 2;
	for ( .@i = 0; .@i < $@guildmembercount; ++.@i ) {
		if ( isloggedin( $@guildmemberaid[.@i], $@guildmembercid[.@i] ) ) {
			attachrid $@guildmemberaid[.@i];
			setarray .@inst_map$, "guild_vs1", "guild_vs2", "guild_vs3", "guild_vs4", "guild_vs5";
			for ( .@j = 0; .@j < 5; ++.@j ) {
				if ( strcharinfo(PC_MAP) == has_instance(.@inst_map$[.@j]) ) {
					++.@online;
					break;
				}
			}
		}
	}

@MishimaHaruna MishimaHaruna added this to the Release v2019.06.02 milestone Jun 1, 2019
@MishimaHaruna MishimaHaruna merged commit 6772362 into HerculesWS:master Jun 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:core:scriptengine Affecting the script engine or the script commands component:documentation Affecting the documentation in the doc/ folder

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants