how to get a coords via code

whowhywhat

New Member
May 28, 2016
23
2
I'm starting to work on a new feature for plus emu r1 and will be planning to release it when done but before that i have one question i need help with, how would i get a script to wait till something is reached? a little example of what i mean

if the player enters :start
the script will wait for the player to reach x
then continue.

so far my method dose this
player types :start
runs if statment to check the players x is equal to my set location
script returns location not reached.
(if i stand on the tile, and then type :start, it returns location reached)

if this is in the wrong section i'm sorry :)
if it helps i could add my code i have so far.
 
Last edited:

JayC

Always Learning
Aug 8, 2013
5,493
1,398
While statement instead of IF
I would add a timer inside the while loop because it will freeze your thread until it's reached. May also prevent users from being able to talk or anything else -

Your best bet is to create a new thread and turn the thread ON and set a timeout. If timeout is reached it says "You didn't go to the starting position"

You can look at tasks already used in plusemu in the Game.cs file
 

whowhywhat

New Member
May 28, 2016
23
2
While statement instead of IF
I would add a timer inside the while loop because it will freeze your thread until it's reached. May also prevent users from being able to talk or anything else -

Your best bet is to create a new thread and turn the thread ON and set a timeout. If timeout is reached it says "You didn't go to the starting position"

You can look at tasks already used in plusemu in the Game.cs file
thanks for the reply so far my current code is this

after reading your post i will go attempt some changes and see how it will go may be best redoing it thanks for advice :)
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
thanks for the reply so far my current code is this

after reading your post i will go attempt some changes and see how it will go may be best redoing it thanks for advice :)
This is a very bad way to code this (In reference to how you determine if it is a game room)

Create a table called "rooms_events"
Columns should be:
room_id INT 11 0 Primary Key
x_tile INT 11 0 DEFAULT 0
y_tile INT 11 0 DEFAULT 0
active INT 11 0 DEFAULT 1

You then should create an object called something along the lines of "RoomEvent.cs" and it should contain the data roomId, intX, intY and Active

Then create a method inside of Game.cs and load all of the database entries into a Dictionary. Then reference that dictionary based on the room ID and it will return the RoomEvent object

So the code will be almost like:

RoomEvent event = PlusEnvironment.GetGame().GetRoomEventByRoomId(1);

if(event == null)
//No Event Found

if(!event.active)
//No Active Event

event.intX = X Tile
event.intY = Y Tile
 

Users who are viewing this thread

Top