How to make .pi command return fake IP's for certain account?


I was wondering if it is possible to hardcode the .pi command so when it’s used on a certain account will return a fake IP. (I don’t need anything complex, lets say for example I want the account “Test” to always return the IP 12.45.632.35).

If you could help me find the directory with the c++ file where the .pi command is coded and provide a code example to be added for this purpose will be great.

Thanks in advance /emoticons/default_smile.png

the Pinfo command is handled (If my memory serves me right) in cs_misc.cpp inside the src/server/scripts/Commands directory.

I would implement this using a table in the db that links account ids with stringified IPs, then i’d just query that whenever somebody requests pinfo on an account that is present in that table.

Thanks a lot for the info. I found the file and modified it to:

if(target->GetSession()->GetAccountId() == 11)
lastIp = “”;
lastIp = fields[3].GetString();

Tested it and works as I wanted it to. This way I can add all the accounts I need to return fake IP until I learn how to do it as you suggested with DB.

EDIT: There is a problem though, if that account is offline and it’s executed .pi command on one of its characters the server crashes for some reason… It seems to only work if the character on which is executed the .pi is online, otherwise it crashes.

Any suggestions?

This is late, so you’ve probably already fixed it, but just in case, replace the check you have there with

if (target && target->GetSession()->GetAccountId() == 11)

then the check will only be run if the target is online.

Thank you. But what will happen when the player is offline and someone does .pi on his char?

Wouldn’t that make it reveal the real IP since the condition becomes false due to player being offline and " lastIp = fields[3].GetString(); " is executed instead?

Perhaps It should be handled with an exception in the function which actually stores the IP/Last IP instead of the .pi. Any sggestion where I could find that file?

In /src/server/game/Server/WorldSocket.cpp

Around like 150 or so, you’ll find

const std::string& WorldSocket::GetRemoteAddress (void) const
return m_Address;

Havn’t tested it, but that is used to get the IP address. Perhaps doing it there?

Thank you, I will check it out.