Jump to content

Java Help


alextoti99

Recommended Posts

0 down vote favorite

Hello everyone im making an online game and for receiving method i am using a thread and for client im using LWJGL, but when it reaches at this position it connects and then the game stops working, when ive deleted the thread the game worked properly, ofc it stopped to w8 for a new message which mustnt being happening. The code: www.mediafire.com/file/2ff82c2995yc3dq/src.rar Server is working nicely. 1 More question im sending the packet with new xyz is this method ok to distract the xyz?

 

else if (message.startsWith("\\move:")) { float x, y, z; int clientID = Integer.parseInt(message.substring(6)); int countX = 0; int num = 7; while (num != 0) { num /= 10; ++countX; } x = Float.parseFloat(message.substring(6 + countX)); int countY = 7 + countX; int num1 = countY; while (num1 != 0) { num1 /= 10; countY ++; } y = Float.parseFloat(message.substring(countY)); int countZ = countX; int num2 = countZ; while (num2 != 0) { num2 /= 10; countZ++; } z = Float.parseFloat(message.substring(countZ)); player.increasePosition(x, y, z); return true; } else if (message.startsWith("\\cp:")) { Utils.alert("get xyz", "get xyz"); float x, y, z; x = Float.parseFloat(message.substring(4)); int countY = 4; int num1 = countY; while (num1 != 0) { num1 /= 10; countY ++; } y = Float.parseFloat(message.substring(countY)); int countZ = countY; int num2 = countZ; while (num2 != 0) { num2 /= 10; countZ ++; } z = Float.parseFloat(message.substring(countZ)); return true; }

 

also how can i turn a List<Entity> to String and a String to List<Entity> for a packet sending

Link to comment
Share on other sites

9 hours ago, alextoti99 said:

0 down vote favorite

this reposted from somewhere? (fine if it is just asking) also this is the tutorials section not the questions section and no one really uses java here, better off heading to stackoverflow or something of the sorts to get help with your issues.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...