Request @sameip

Ridley

Community Administrator
Messages
1,157
Points
0
Age
38
Location
Germany
Discord
Ridley#5102
IRC Nickname
Ridley
Github
ridley8819
Emulator
Client Version
2019-03-22
Hello, I would like to request a command that displays all the duals on the map where the command is executed
example
 
i use @sameip in prontera
then display in the chat window 
 
---------------List of Same IP in Prontera---------
User 1<ip> and User 2<ip>
User 1<ip> and User 3<ip>
 
User 4<ip> and User 18<ip>
User 8<ip> and User 22<ip>
 
(and so on)
 
instead of "user" it shows the char name 
 
I got an old src code of this but i hoped someone got an idea about how to make it a plugin or do it via bindatcmd. Anyways, here is the src (eathena)
Code:
/*========================================== * @sameip * List all players on a map currently on the same IP. *------------------------------------------*/ACMD_FUNC(sameip){	int i, j;	int map_id;	char map_name[MAP_NAME_LENGTH];	struct s_mapiterator* iter;	struct map_session_data* ssd;	struct ip_record record[100];	struct same_record same[100];	nullpo_retr(-1, sd);		if (!message || !*message)	{		safestrncpy(map_name, map[sd->bl.m].name, MAP_NAME_LENGTH);	}	else	{		safestrncpy(map_name, message, MAP_NAME_LENGTH);	}	map_id = map_mapname2mapid(map_name);	if (map_id == -1)	{		sprintf(atcmd_output, "The map name '%s' doesn't exist.", map_name);		clif_displaymessage(sd->fd, atcmd_output);		return -1;	}	sprintf(atcmd_output, "---- Listing all players on %s ----", map_name);	clif_displaymessage(sd->fd, atcmd_output);		memset(same, 0, sizeof same);	memset(record, 0, sizeof record);	i = 0;	iter = mapit_getallusers();	for (ssd = (struct map_session_data*)mapit_first(iter); mapit_exists(iter); ssd = (struct map_session_data*)mapit_next(iter))	{		if (ssd == NULL)			continue;		if (ssd->state.autotrade)			continue;		if (ssd->fd < 0 || session[ssd->fd] == NULL)			continue;		if (ssd->bl.m != map_id)			continue;		ARR_FIND(0, 100, j, record[j].ip == session[ssd->fd]->client_addr);		if (j == 100)		{			ARR_FIND(0, 100, j, record[j].account_id == 0);			if (j == 100)				break;						record[j].ip = session[ssd->fd]->client_addr;			record[j].char_id = ssd->status.char_id;			record[j].account_id = ssd->status.account_id;			continue;		}				same[i].ip = session[ssd->fd]->client_addr;		same[i].pl1 = map_id2sd(record[j].account_id);		same[i].pl2 = ssd;		i++;	}	if (i > 0)	{		for (j = 0; i > j; j++)		{			if (same[j].pl1 && same[j].pl2)			{				sprintf(atcmd_output, "- Characters '%s' and '%s' are on the same IP.", same[j].pl1->status.name, same[j].pl2->status.name);				clif_displaymessage(sd->fd, atcmd_output);			}		}	}	sprintf(atcmd_output, "---- Found %d players on the same IP ----", i);	clif_displaymessage(sd->fd, atcmd_output);	mapit_free(iter);	return 0;}
 
Last edited by a moderator:
Here, this is done using bindatcmd. ( @sameip )

It displays in this format:

---------------- List of Same IP User -------------------------------------- Prontera ----------------------IP Address: 127.0.0.1Account ID: 2000001, 2000002, 2000003Character Names: Name1, Name2, Name3IP Address: 192.168.1.1Account ID: 2000004, 2000011Character Names: Name4, Name11etc...
It won't show duplicate account ids. Meaning, it will only show 1 IP address and then all the account ids using that IP address and then the names of those characters currently online. So if Player 1 has same IP address as Player2. And Player3 has same IP address as Player 1. It will only show 1 entry to make it neater.

- script at_sameip -1,{OnInit:bindatcmd "sameip",strnpcinfo(3)+"::OnAtSameIP";//,99,99,0; // 0 = No log, 1 = Log usageend;OnAtSameIP:.@size = query_sql("SELECT `account_id` FROM `char` WHERE `online` = '1' AND `last_map` = '"+ strcharinfo(3) +"'",.@acct_id);.@size2 = query_sql("SELECT `account_id`, `last_ip` FROM `login` WHERE `account_id` != '1'", .@aid, .@ip$);while( .@a < .@size ) { for( .@i = 0; .@i < getarraysize(.@aid); .@i++ ) { if( .@aid[.@i] == .@acct_id[.@a] ) { .@tempaid$[.@a] = ""+ .@aid[.@i] +""; .@tempaip$[.@a] = .@ip$[.@i]; } } .@a++;}.@size3 = getarraysize(.@tempaid$);while( .@c != .@size3 ) { for( .@i = 0; .@i < getarraysize( .@usedaids$ ); .@i++ ) { if( .@usedaids$[.@i] == .@tempaid$[.@c] ) { //Account ID already in array. .@used = 1; } } if( !.@used ) { .@usedaids$[( getarraysize( .@usedaids$ ) + 1 )] = .@tempaid$[.@c]; .@duplicateaid$[.@c] = "Account IDs: "+ .@tempaid$[.@c] +""; .@duplicaterid2name$[.@c] = "Character Names: "+ rid2name( atoi( .@tempaid$[.@c] ) ) +""; .@duplicateaip$[.@c] = "IP Address: "+ .@tempaip$[.@c] +""; for( .@i = 0; .@i < getarraysize( .@tempaid$ ); .@i++ ) { if( .@tempaip$[.@c] == .@tempaip$[.@i] && .@tempaid$[.@c] != .@tempaid$[.@i] ) { .@duplicateaid$[.@c] = .@duplicateaid$[.@c] +", "+ .@tempaid$[.@i] +""; .@duplicaterid2name$[.@c] = .@duplicaterid2name$[.@c] +", "+ rid2name( atoi( .@tempaid$[.@i] ) ) +""; .@usedaids$[( getarraysize( .@usedaids$ ) + 1 )] = .@tempaid$[.@i]; } } } .@used = 0; .@c++; }dispbottom "---------------- List of Same IP User ----------------";dispbottom "---------------------- "+ setchar( strcharinfo(3), strtoupper(charat(strcharinfo(3),0)), 0 ) +" ----------------------";for( .@i = 0; .@i < getarraysize(.@duplicateaid$); .@i++ ) { if( .@duplicateaid$[.@i] != "" ) { dispbottom " "; dispbottom .@duplicateaip$[.@i]; dispbottom .@duplicateaid$[.@i]; dispbottom .@duplicaterid2name$[.@i]; } }end;}

Enjoy D:

 
Last edited by a moderator:
hm it works thanks, 

mine was a bit different and didnt work with dispbottom (i have actually no idea why) with mes it worked fine. o_o

 
O.o that is weird. But glad it works. If theres anything else regarding this let me know.

 
[Error]: run_script: infinity loop ![Debug]: Source (NPC): at_sameip (invisible/not on a map)
default_sad.png


 
Infinityloop... must mean theres too much being requested at one time. I'll add a fix....

Edit: This should fix it. Just added freeloop(1) at the begining and freeloop(0) at the end.

Code:
-	script	at_sameip	-1,{OnInit:bindatcmd "sameip",strnpcinfo(3)+"::OnAtSameIP";//,99,99,0; // 0 = No log, 1 = Log usageend;OnAtSameIP:freeloop(1);.@size = query_sql("SELECT `account_id` FROM `char` WHERE `online` = '1' AND `last_map` = '"+ strcharinfo(3) +"'",.@acct_id);.@size2 = query_sql("SELECT `account_id`, `last_ip` FROM `login` WHERE `account_id` != '1'", .@aid, .@ip$);while( .@a < .@size ) {	for( .@i = 0; .@i < getarraysize(.@aid); .@i++ ) {		if( .@aid[.@i] == .@acct_id[.@a] ) {			.@tempaid$[.@a] = ""+ .@aid[.@i] +"";			.@tempaip$[.@a] = .@ip$[.@i];			}		}	.@a++;}.@size3 = getarraysize(.@tempaid$);while( .@c != .@size3 ) {	for( .@i = 0; .@i < getarraysize( .@usedaids$ ); .@i++ ) {		if( .@usedaids$[.@i] == .@tempaid$[.@c] ) { //Account ID already in array.		.@used = 1;		}	}	if( !.@used ) {		.@usedaids$[( getarraysize( .@usedaids$ ) + 1 )] = .@tempaid$[.@c];		.@duplicateaid$[.@c] = "Account IDs: "+ .@tempaid$[.@c] +"";		.@duplicaterid2name$[.@c] = "Character Names: "+ rid2name( atoi( .@tempaid$[.@c] ) ) +"";		.@duplicateaip$[.@c] = "IP Address: "+ .@tempaip$[.@c] +"";				for( .@i = 0; .@i < getarraysize( .@tempaid$ ); .@i++ ) {			if( .@tempaip$[.@c] == .@tempaip$[.@i] && .@tempaid$[.@c] != .@tempaid$[.@i] ) {				.@duplicateaid$[.@c] = .@duplicateaid$[.@c] +", "+ .@tempaid$[.@i] +"";				.@duplicaterid2name$[.@c] = .@duplicaterid2name$[.@c] +", "+ rid2name( atoi( .@tempaid$[.@i] ) ) +"";				.@usedaids$[( getarraysize( .@usedaids$ ) + 1 )] = .@tempaid$[.@i];				}			}		}	.@used = 0;	.@c++;	}dispbottom "---------------- List of Same IP User ----------------";dispbottom "---------------------- "+ setchar( strcharinfo(3), strtoupper(charat(strcharinfo(3),0)), 0 ) +" ----------------------";for( .@i = 0; .@i < getarraysize(.@duplicateaid$); .@i++ ) {	if( .@duplicateaid$[.@i] != "" ) {		dispbottom " ";		dispbottom .@duplicateaip$[.@i];		dispbottom .@duplicateaid$[.@i];		dispbottom .@duplicaterid2name$[.@i];		}	}freeloop(0);end;}
 
Last edited by a moderator:
- script at_sameip -1,{OnInit:bindatcmd "sameip",strnpcinfo(3)+"::OnAtSameIP";//,99,99,0; // 0 = No log, 1 = Log usageend;OnAtSameIP:freeloop(1);.@size = query_sql("SELECT `account_id` FROM `char` WHERE `online` = '1'",.@acct_id);.@size2 = query_sql("SELECT `account_id`, `last_ip` FROM `login` WHERE `account_id` != '1'", .@aid, .@ip$);while( .@a < .@size ) { for( .@i = 0; .@i < getarraysize(.@aid); .@i++ ) { if( .@aid[.@i] == .@acct_id[.@a] ) { .@tempaid$[.@a] = ""+ .@aid[.@i] +""; .@tempaip$[.@a] = .@ip$[.@i]; } } .@a++;}.@size3 = getarraysize(.@tempaid$);while( .@c != .@size3 ) { for( .@i = 0; .@i < getarraysize( .@usedaids$ ); .@i++ ) { if( .@usedaids$[.@i] == .@tempaid$[.@c] ) { //Account ID already in array. .@used = 1; } } if( !.@used ) { .@usedaids$[( getarraysize( .@usedaids$ ) + 1 )] = .@tempaid$[.@c]; .@duplicateaid$[.@c] = "Account IDs: "+ .@tempaid$[.@c] +""; .@duplicaterid2name$[.@c] = "Character Names: "+ rid2name( atoi( .@tempaid$[.@c] ) ) +""; .@duplicateaip$[.@c] = "IP Address: "+ .@tempaip$[.@c] +""; for( .@i = 0; .@i < getarraysize( .@tempaid$ ); .@i++ ) { if( .@tempaip$[.@c] == .@tempaip$[.@i] && .@tempaid$[.@c] != .@tempaid$[.@i] ) { .@duplicateaid$[.@c] = .@duplicateaid$[.@c] +", "+ .@tempaid$[.@i] +""; .@duplicaterid2name$[.@c] = .@duplicaterid2name$[.@c] +", "+ rid2name( atoi( .@tempaid$[.@i] ) ) +""; .@usedaids$[( getarraysize( .@usedaids$ ) + 1 )] = .@tempaid$[.@i]; } } } .@used = 0; .@c++; }dispbottom "---------------- List of Same IP User ----------------";for( .@i = 0; .@i < getarraysize(.@duplicateaid$); .@i++ ) { if( .@duplicateaid$[.@i] != "" ) { dispbottom " "; dispbottom .@duplicateaip$[.@i]; dispbottom .@duplicateaid$[.@i]; dispbottom .@duplicaterid2name$[.@i]; } }freeloop(0);end;}
All you needed to do was just change the sql query to omit the requirement for a map name, and then it'll get data on everyone who is online at the time of the scripts activation.

My only concern is that your using rAthena emulator. This means your arrays are limited to 128 elements. A lot more would have to be changed to make it work 100% for you. So, you can just take this edit and have someone over there change it to work with rA's array system

 
@@GmOcean

i'm trying this script but everytime i type @sameip YourRO.exe has been stopped working.

is there any problem on the script? i'm using Hercules Emulator.

 
Last edited by a moderator:
- script at_sameip -1,{OnInit:bindatcmd "sameip",strnpcinfo(3)+"::OnAtSameIP";//,99,99,0; // 0 = No log, 1 = Log usageend;OnAtSameIP:freeloop(1);.@size = query_sql("SELECT `account_id` FROM `char` WHERE `online` = '1'",.@acct_id);.@size2 = query_sql("SELECT `account_id`, `last_ip` FROM `login` WHERE `account_id` != '1'", .@aid, .@ip$);while( .@a < .@size ) { for( .@i = 0; .@i < getarraysize(.@aid); .@i++ ) { if( .@aid[.@i] == .@acct_id[.@a] ) { .@tempaid$[.@a] = ""+ .@aid[.@i] +""; .@tempaip$[.@a] = .@ip$[.@i]; } } .@a++;}.@size3 = getarraysize(.@tempaid$);while( .@c != .@size3 ) { for( .@i = 0; .@i < getarraysize( .@usedaids$ ); .@i++ ) { if( .@usedaids$[.@i] == .@tempaid$[.@c] ) { //Account ID already in array. .@used = 1; } } if( !.@used ) { .@usedaids$[( getarraysize( .@usedaids$ ) + 1 )] = .@tempaid$[.@c]; .@duplicateaid$[.@c] = "Account IDs: "+ .@tempaid$[.@c] +""; .@duplicaterid2name$[.@c] = "Character Names: "+ rid2name( atoi( .@tempaid$[.@c] ) ) +""; .@duplicateaip$[.@c] = "IP Address: "+ .@tempaip$[.@c] +""; for( .@i = 0; .@i < getarraysize( .@tempaid$ ); .@i++ ) { if( .@tempaip$[.@c] == .@tempaip$[.@i] && .@tempaid$[.@c] != .@tempaid$[.@i] ) { .@duplicateaid$[.@c] = .@duplicateaid$[.@c] +", "+ .@tempaid$[.@i] +""; .@duplicaterid2name$[.@c] = .@duplicaterid2name$[.@c] +", "+ rid2name( atoi( .@tempaid$[.@i] ) ) +""; .@usedaids$[( getarraysize( .@usedaids$ ) + 1 )] = .@tempaid$[.@i]; } } } .@used = 0; .@c++; }dispbottom "---------------- List of Same IP User ----------------";for( .@i = 0; .@i < getarraysize(.@duplicateaid$); .@i++ ) { if( .@duplicateaid$[.@i] != "" ) { dispbottom " "; dispbottom .@duplicateaip$[.@i]; dispbottom .@duplicateaid$[.@i]; dispbottom .@duplicaterid2name$[.@i]; } }freeloop(0);end;}
All you needed to do was just change the sql query to omit the requirement for a map name, and then it'll get data on everyone who is online at the time of the scripts activation.

My only concern is that your using rAthena emulator. This means your arrays are limited to 128 elements. A lot more would have to be changed to make it work 100% for you. So, you can just take this edit and have someone over there change it to work with rA's array system
its working and its very cool

but when i type @sameip all players on every map will be shown

can u make it like when i type @sameip it will only show the ip of the players (on a certain map where i am)

 
and @sameip cannot be use by normal players to avoid the ip privacy of the players

 
Back
Top