The question I have is are areas declared in the Lua script useable in the plugin or do you have to declare the useable plugin areas separately?
PlayerEnterAreaEvent?
-
- English
- angriff
- Thread is marked as Resolved.
A new update is now available, introducing a lot of new content!
Latest hotfix: 0.7.5.1 (2024-09-02)
Latest hotfix: 0.7.5.1 (2024-09-02)
-
-
As I asked in your other post of this question, which plug-in? PlayerEnterAreaEvent is an event any plug-in can listen to, if it needs.
-
The question more direct is are the areas capable of being used in the Player Enter even or does every plug in have to define its own areas? Are the Areas defined in Area Protection stored in the overall program so that other plugins can use them or are they hidden and a total rewrite of the script is needed to allow them to be used in a general sense?
-
Area is an RW defined class; once a plug-in defines an Area object and adds it to the Server with the Server.addArea() method, whenever a player enters or leaves it, a PlayerEnterAreaEvent / PlayerLeaveAreaEvent will be generated and any plug-in listening for them will know about.
The important point is adding the defined Areas to the server.
I cannot be 100% sure about the old LUA script, but I imagine it does exactly that.
This is completely separate from having access the the areas themselves from other plug-ins. In my plug-in, I chose NOT to give this access, as adding / deleting / modifying an area requires collateral housekeeping jobs and therefore should only be done via the plug-in itself and not from other plug-ins.
As RW does not support, as far as I remember, any inter-LUA-script communication, I imagine this external access to the Area objects themselves to be impossible with the LUA script
-
Thanks.. I have been running my own server with the lua script for sometime so I am aware of the pitfalls. I was writing another script to do something else in the area and wanted to understand if I had to redefine the areas again. The Lua script uses a database and theon PlayerChangePosition Event to track people so it can negate a movement into an area. I just want to piggyback onto the area to do other things. I could read the database but since it is always using it I wanted to avoid the conflict possibility. I will try your suggestions.
-
[..]The Lua script uses a database and theon PlayerChangePosition Event to track people so it can negate a movement into an area.
Listening to the PlayerChangePositionEvent to track players entering and leaving areas is a strange choice; the server already does that and triggers PlayerEnter/LeaveAreaEvent whenever this happens, so it is a duplication of work (possibly the LUA script listens to PlayerChangePositionEvent also for other reasons and/or the PlayerEnter/LeaveAreaEvent were not available yet when the LUA script has been written).
Check that the LUA script adds to the server the Areas it creates (right now I cannot do it myself); if it does, then simply use the PlayerEnter/LeaveAreaEvent to know when a player enters or leaves an area.
I just want to piggyback onto the area to do other things.
I could read the database but since it is always using it I wanted to avoid the conflict possibility. I will try your suggestions.Reading from a DB should not raise any conflict, but:
1) if the DB is read at start-up and than kept in memory (which could be wise to minimise CPU load), data would become obsolete once a new area is added or an existing one deleted.
2) Again, you would have to check players crossing area boundaries, which is a task the server already does; as PlayerChangePositionEvent is a very frequent event, minimising the work done in it is quite important.
-
Well I am just looking at it with notepad++ and did a search for the PlayerEnter and it does not show up. The code seems to be tracking the player with vectors and then check the point is in the area. It is supposedly old script it does not use UID for sure but DBID which is ok for an individual server like mine. I like it but I bet it causes a performance hit for some people in some areas. (hoping they make a comparable version in the API).
Thanks I have to teach myself how to detect the AreaEnterEvent (player area) not sure if area is a name or the ID. Also how to get the area ID or name whichever is stored in the server. The Lua checks it's database for group permissions once it has the ID but I dont want that information I was wanting to detect you re in a certain area for some other routines.
-
Well thanks for that I figured it out ok .. but Lua does not register them with the server. I have to load them. That is ok I only want a few for execution of codes.. The lua can handle the ones for the protections. For the next guy this is what I used.
cannon = new Area(-6,0,-2,8,55,10,-3,2,2,9,6,9);
Server server = getServer();
server.addArea(cannon);Then the event method
@EventMethod
public void onPlayerEnterArea(PlayerEnterAreaEvent event){
Player player = event.getPlayer();
if (cannon == event.getArea()){
player.sendTextMessage("you are detected in area cannon");
}
}
Thanks againPS dont put the add in the onplayerspawn or you get tons of them.
-
Glad eventually things fell into place.
PS dont put the add in the onplayerspawn or you get tons of them.Of course! An area has to be added only once, not every time a player connects or spawns.
-
well I thought it was a local server event and if it had the same name.. luckily I was looking at
java.util.Collection myAreas = server.getAllAreas();
int asize = myAreas.size(); -
well I thought it was a local server event and if it had the same name..
Would mind defining "local server event"? On it surface, it seems a self-contradictory clause; or is it intended in a rather peculiar meaning...?
And what has the same name of what?
Participate now!
Don’t have an account yet? Create a new account now and be part of our community!