Jump to content

Question

8 answers to this question

Recommended Posts

Posted (edited)

Doesn't the @whomap commands already do that?

 

Anyways this will work like an @command warp to the map you'd like to know how many normal players are on and do @getusers...

If you want to just input the map name that would probably require surfing your sqldb via script or something.

-	script	user_count	-1,{
	OnUserGet:
		attachrid(.aid);
		addrid(1);
		if(getgmlevel()>20) end;
		set(.a,.a+1);
		end;

	OnEventDo:
		set(.aid, getcharid(3));
		donpcevent "user_count::OnUserGet";
		dispbottom(.a+" User(s) found on "+strcharinfo(3)+".");
		set(.a,0);
		end;

	OnInit:
		bindatcmd "getusers","user_count::OnEventDo",99,99;
}

Remove ",99,99" if this command was intended for normal player use.

Edited by Skorm
Small Fix Etc...
  • Upvote 1
Posted

hahaha, I'm just about to point out that bug xD

anyway, optimized ~

 

-	script	user_count	-1,{
OnInit:
	bindatcmd "getusers", strnpcinfo(0)+"::OnCommand";
	end;
OnCommand:
	.@origin = getcharid(3);
	addrid 1;
	if ( getgmlevel() <= 20 ) // GM level here
		.count++;
	if ( getcharid(3) != .@origin ) end;
	dispbottom .count +" User"+( .count > 1 ? "s" : "" )+" found on "+strcharinfo(3)+".";
	.count = 0;
	end;
}
tested

@MeWhoMustNotBeNamed

if you are writing an event script like last man standing,

its better to store them in an array

http://rathena.org/board/topic/91723-please-help-this-script-about-mac-address/?p=240887

Posted (edited)
-	script	user_count	-1,{
OnInit:
	bindatcmd "getusers", strnpcinfo(0)+"::OnCommand";
	end;
OnCommand:
	.@origin = getcharid(3);
	addrid 1;
	if ( getgmlevel() <= 20 ) // GM level here
		.count++;
	if ( getcharid(3) != .@origin ) end;
	dispbottom .count +" User"+( .count > 1 ? "s" : "" )+" found on "+strcharinfo(3)+".";
	.count = 0;
	end;
}

As I remember, Variable prefix with .@ will be lost when script use addrid.

I think that except for the player who used that command, no one has var .@origin

http://rathena.org/board/topic/88331-addrid-addition/?p=226484

Edited by QQfoolsorellina
Posted

hahaha, I'm just about to point out that bug xD

anyway, optimized ~

 

-	script	user_count	-1,{
OnInit:
	bindatcmd "getusers", strnpcinfo(0)+"::OnCommand";
	end;
OnCommand:
	.@origin = getcharid(3);
	addrid 1;
	if ( getgmlevel() <= 20 ) // GM level here
		.count++;
	if ( getcharid(3) != .@origin ) end;
	dispbottom .count +" User"+( .count > 1 ? "s" : "" )+" found on "+strcharinfo(3)+".";
	.count = 0;
	end;
}
tested

@MeWhoMustNotBeNamed

if you are writing an event script like last man standing,

its better to store them in an array

http://rathena.org/board/topic/91723-please-help-this-script-about-mac-address/?p=240887

 

 

In all honestly I think this would actually be slower than my version...

 

You're running the entire map through more checks.

 

I attached the main player called a new event then re-attached him to get the map location but all other players only go through 1 check and one condition.

 

Instead of 2 checks with a subsequent conditional count.

Posted (edited)

I was the one who keep bringing up addrid in rathena forum until it was added months later

run a search "addrid" in rathena confirm this

I knew the existance of addrid while I was still on eathena forum playing around with Brainstorm

http://www.eathena.ws/board/index.php?s=&showtopic=271105&view=findpost&p=1484769

@QQfoolsorellina

the .@scope variable is not persistent after attachrid on other players

but its still available to the current player

so actually its possible to set a .@scope variable with just anything,

other attached player will actually just return .@origin as 0

 

-	script	user_count	-1,{
OnInit:
	bindatcmd "getusers", strnpcinfo(0)+"::OnCommand";
	end;
OnCommand:
	.@attached = 1;
	addrid 1;
	if ( getgmlevel() <= 20 ) // GM level here
		.count++;
	if ( !.@attached ) end;
	dispbottom .count +" User"+( .count > 1 ? "s" : "" )+" found on "+strcharinfo(3)+".";
	.count = 0;
	end;
}
also works

the .@origin has been stuck to my scripting style, so don't mind that

so yeah, the dispbottom will only display on the attached player, not anyone else

@Skorm

http://www.eathena.ws/board/index.php?s=&showtopic=186459&view=findpost&p=1038374

weird, what I did was actually a method from the author himself ... /hmm

I have read through addrid source code many times to confirm this

https://github.com/rathena/rathena/blob/master/src/map/script.c#L10668

Edited by AnnieRuru
Posted

thanks for the response. what if i just have to get those players[non GM] that are still alive on a certain map. example prontera.

@skorm

i was trying to make an event npc thats why im asking.

@annieruru

yeah i was making an event npc. i was just wondering if i have to used array. what if someobe got disconnected due to connection errors does tge script if lms is not bug?

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...