most credits go to fedexer for makeing the global object tuts
this is a good way to get doors to open for everyone or to let everyone see that an object has been updated
this does not save the object id if a player logs in or out
this all takes place in client.java or if you have handled it it goes in your handler
i tried to explain the best i could even tho theres not much to explain and its mostly comon sense
i hope this helps out everyone
i am openice123 on moparscape do not say i leeched
this will be are main method
it can replace anyobject if you have the right object type
Code:
public void Object(int objectX, int objectY, int NewObjectID, int Face, int ObjectType) {
for (Player p : server.playerHandler.players) {
if(p != null) {
client person = (client)p;
if((person.playerName != null || person.playerName != "null")) {
if(person.distanceToPoint(objectX, objectY) <= 60) {
person.createNewTileObject(objectX, objectY, NewObjectID, Face, ObjectType);
}}}}}
now to explain what it does
will be the location of where the object is on absX
will be the location of where the object is on absY
will be the new or same object id of the object
this will be the new direction of the object
the object type will be the type of the object
example:
10 for most objects like trees or doors
0 for most walls
for (Player p : server.playerHandler.players) {
if(p != null) {
client person = (client)p;
if((person.playerName != null || person.playerName != "null")) {
this will locate and find the players name so it can be used latter on
if(person.distanceToPoint(objectX, objectY) <= 60) {
not to sure what that does but im pretty sure it makes it so it doesnt double spawn
person.createNewTileObject(objectX, objectY, NewObjectID, Face, ObjectType);
will update the object useing the createnewtitleobject method
heres one way you can use object
Code:
Object(objectX, objectY, 6951, -1, 10);
this part will make a object where you are standing face north with the object type of 10
0=West
-1=North
-2=East
-3=South
Object2
it uses the same format of method Object but no object type
it may work i use it for the simple objects like fires or replaceing rocks
Code:
public void Object2(int objectX, int objectY, int NewObjectID, int Face) {
for (Player p : server.playerHandler.players) {
if(p != null) {
client person = (client)p;
if((person.playerName != null || person.playerName != "null")) {
if(person.distanceToPoint(objectX, objectY) <= 80) {
person.ReplaceObject(objectX, objectY, NewObjectID, Face);
}}}}}
here is one way you can use object2
Code:
Object2(objectX, objectY, 1531, -1);
this will be locating the object you click on absX and absY
is your new object id or in this case a door id
this will be the direction the object will be faceing after you click it
0=West
-1=North
-2=East
-3=South
Using The Methods
useing these methods can be used in
object click one
Code:
public void objectClick
object click two
Code:
public void objectClick2
and object click three
Code:
public void objectClick3
for example
Code:
case ID:
Object(objectX, objectY, ID, -1, 10);
break;
or
Code:
case ID:
Object2(objectX, objectY, ID, -1);
break;
you can also use this in the itemonitem method or item on object methods
if you do not have createNewTileObject here it is
Code:
public void createNewTileObject(int x, int y, int typeID, int orientation, int tileObjectType)
{
outStream.createFrame(85);
outStream.writeByteC(y - (mapRegionY * 8));
outStream.writeByteC(x - (mapRegionX * 8));
outStream.createFrame(151);
//outStream.writeByteA(((x&7) << 4) + (y&7));
outStream.writeByteA(0);
outStream.writeWordBigEndian(typeID);
outStream.writeByteS((tileObjectType<<2) +(orientation&3));
}