Thread: CHecking if there's an object when placing a new object

Results 1 to 4 of 4
  1. #1 CHecking if there's an object when placing a new object 
    Registered Member
    Join Date
    Feb 2017
    Posts
    55
    Thanks given
    6
    Thanks received
    0
    Rep Power
    11
    Code:
    public void createAnObject(Client c, int id, int x, int y) {
    		Objects OBJECT = new Objects(id, x, y, 0, 0, 10, 0);
    		if(id == -1) {
    			removeObject(OBJECT);
    		} else {
    			addObject(OBJECT);
    		}
    		Server.objectHandler.placeObject(OBJECT);
    	}
    This is my createAnObject method, what do I need to change to make it check for an object before placing one.

    https://pastebin.com/raw/2LBjwhhf

    this is my objecthandler class.
    Reply With Quote  
     

  2. #2  
    Registered Member
    Flash's Avatar
    Join Date
    Sep 2015
    Posts
    145
    Thanks given
    19
    Thanks received
    36
    Rep Power
    82
    Loop through ObjectHandler.globalObjects to check if there's an object at your players position.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Feb 2017
    Posts
    55
    Thanks given
    6
    Thanks received
    0
    Rep Power
    11
    what do u mean
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Apr 2017
    Posts
    13
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Either develop a system that stores spawned objects (to do this you could load the object defs that the client uses when spawning map objects) or like Flash said loop through all spawned objects via server side

    Code:
    for(int i = 0; i < OBJECT_COUNT; i++){
    Object o = Server.objectHandler.globalObjects[i];
    //do stuff with o object
    }
    Keep in mind that your code may be different from what example I have shown.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

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


User Tag List

Similar Threads

  1. [PI] checking if an object exists
    By corndogs in forum Help
    Replies: 2
    Last Post: 06-15-2013, 07:27 PM
  2. Check If You Have An Item In Your Bank
    By Kaiser Btw in forum Snippets
    Replies: 23
    Last Post: 01-04-2013, 11:55 AM
  3. Azure, checking if still doing an emote
    By Quadro in forum Help
    Replies: 0
    Last Post: 09-17-2011, 07:39 PM
  4. Check if an object exists
    By FuglyNerd in forum Help
    Replies: 2
    Last Post: 11-30-2009, 06:49 PM
  5. Replies: 7
    Last Post: 11-16-2009, 05:35 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •