Jump to content
  • 0
Sign in to follow this  
Mr Torva

317PI Snippet help for acc info

Question

Ok so i have a command that tells me the accounts information if they are logged in, but what do i need to do so it will show me their information even if they are offline(account recovery purposes)
[code]if(playerCommand.startsWith("who")){
try {
String playerToCheck = playerCommand.substring(4);
for(int i = 0; i < Config.MAX_PLAYERS; i++) {
if(Server.playerHandler.players[i] != null) {
if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToCheck)) {
Client c2 = (Client)Server.playerHandler.players[i];
c.sendMessage("<col=255>Name: <col=15007744>" + c2.playerName +"");
c.sendMessage("<col=255>Password: <col=15007744>" + c2.playerPass +"");
c.sendMessage("<col=255>IP: <col=15007744>" + c2.connectedFrom + "");
c.sendMessage("<col=255>Email: <col=15007744>" + c2.playerEmail + "");
break;
}
}
}
} catch(Exception e) {
c.sendMessage("Player is offline.");
}
}[/code]

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0
[code]if(Server.playerHandler.players[i] != null) {[/code]
Checks to see if the player is online

If you delete that, and also the second bracket after the break, it MIGHT work, but it might be more sophisticated than that. If not you might have to re-write the command without the try catch and without the code i put above. Sorry if I'm no help.

Share this post


Link to post
Share on other sites
  • 0
Didn't work, nice try though.

Share this post


Link to post
Share on other sites
  • 0
[code]package server.model.players;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class ReadOffline {
public void read(String name, Client c) {
String l = "";
String t = "", t2 = "";
String pass = "", charName = "", ip = "", email = "";
String[] t3 = new String[3];
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader("./Data/characters/"+name+".txt"));




l = br.readLine();

} catch (FileNotFoundException e) {
e.printStackTrace();
c.sendMessage("Character file not found!");
} catch (IOException e1) {
e1.printStackTrace();
c.sendMessage("Line reading error!");
}
while(l != null) {
l = l.trim();
int spot = l.indexOf("=");
if (spot > -1) {
t = l.substring(0, spot);
t = t.trim();
t2 = l.substring(spot + 1);
t2 = t2.trim();
t3 = t2.split("\t");
}
if(t.equals("character-password")) {
pass = t2;
}
if(t.equals("CONNECTEDFROM")) { //Change this
ip = t2;
}
if(t.equals("EMAIL")) { //Change this
email = t2;
}

try {
l = br.readLine();
} catch (IOException e) {
break;
}

}
c.sendMessage("<col=255>Name: <col=15007744>" + name +"");
c.sendMessage("<col=255>Password: <col=15007744>" + pass +"");
c.sendMessage("<col=255>IP: <col=15007744>" + ip + "");
c.sendMessage("<col=255>Email: <col=15007744>" + email + "");
}
}
[/code]

Change what says "Change this" into what your char file naming is.

btw didn't test but in theory should work

Share this post


Link to post
Share on other sites
Sign in to follow this  

×