Thread: getting an object to update for everyone

Results 1 to 4 of 4
  1. #1 getting an object to update for everyone 
    Registered Member
    Shamon King's Avatar
    Join Date
    Aug 2007
    Posts
    3,335
    Thanks given
    90
    Thanks received
    228
    Rep Power
    1363
    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
    objectX
    will be the location of where the object is on absX

    objectY
    will be the location of where the object is on absY

    int NewObjectID
    will be the new or same object id of the object

    [b]int Face,
    this will be the new direction of the object

    int ObjectType
    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);
    objectX, objectY,
    this will be locating the object you click on absX and absY

    1531
    is your new object id or in this case a door id

    -1
    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));
    	}
     

  2. #2  
    btbtbtbt
    Guest
    good job ***+
     

  3. #3  
    Donator
    Volar's Avatar
    Join Date
    Nov 2007
    Age
    31
    Posts
    567
    Thanks given
    0
    Thanks received
    6
    Rep Power
    72
    nice tutorial good job.
     

  4. #4  
    Registered Member
    Shamon King's Avatar
    Join Date
    Aug 2007
    Posts
    3,335
    Thanks given
    90
    Thanks received
    228
    Rep Power
    1363
    thanks for both the replys
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •