Hello again Lapo
And I'm back with a question)
Thanks for helping with .jar last time, now I know how to write my extensions on the server and it works as I want)
But now I have a question, I have doors and when the player re-enters, the state of the door changes to default
I want new players to receive information about the status of players and doors, as I understand it, I need to implement it through server variables, entity.variables;
Did I understand correctly? if yes, then how to save the doors approximately, just according to the documentation on the site I didn't really understand, it would be on the example of the doors or the state of the player's health, then I would figure it out
thank you in advance, dear Lapo
enitity.variables .jar
Re: enitity.variables .jar
refresh actuality
Re: enitity.variables .jar
Hello.
For the doors state you should use a Room Variable. This can be set using the SetRoomVariablesRequest. You have to give each door an id, and you could use a boolean to indicate if it is opened or closed:
Whenever a door changes it state, set its Room Variable again and all users in the room will be notified. In the OnRoomVarsUpdate listener you can then retrieve the door state and display it on screen.
For the player health instead you should use a User Variable. Usage is the same as above.
For the doors state you should use a Room Variable. This can be set using the SetRoomVariablesRequest. You have to give each door an id, and you could use a boolean to indicate if it is opened or closed:
Code: Select all
void SomeMethod() {
sfs.AddEventListener(SFSEvent.ROOM_VARIABLES_UPDATE, OnRoomVarsUpdate);
List<RoomVariable> roomVars = new List<RoomVariable>();
roomVars.Add( new SFSRoomVariable("door1", false) );
roomVars.Add( new SFSRoomVariable("door2", false) );
roomVars.Add( new SFSRoomVariable("door3", true) );
sfs.Send( new SetRoomVariablesRequest(roomVars) );
}
Whenever a door changes it state, set its Room Variable again and all users in the room will be notified. In the OnRoomVarsUpdate listener you can then retrieve the door state and display it on screen.
For the player health instead you should use a User Variable. Usage is the same as above.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Re: enitity.variables .jar
Hello)
Thank you very much, this is what I wanted to see and what I just asked for)
I use the list of doors (id) on the client, but on the server I just wanted to find out)
thank you very much
Thank you very much, this is what I wanted to see and what I just asked for)
I use the list of doors (id) on the client, but on the server I just wanted to find out)
thank you very much
Re: enitity.variables .jar
I figured it out, everything works, I just had to turn on my head, I didn't think that everything was so simple, I thought that everything was more complicated. It only remains to find out how to find out the state of the variable after logging on to the server, I change it, but when I log into the game I do not know its state, what is the name of such a method?
I think I realized that I used the wrong thing, the variables are stored until the creator turns off, I need to make sure that the players who even went to an empty server saw the doors that were opened a long time ago or closed a long time ago
I think I realized that I used the wrong thing, the variables are stored until the creator turns off, I need to make sure that the players who even went to an empty server saw the doors that were opened a long time ago or closed a long time ago
Re: enitity.variables .jar
If the Room is "owned" by the server (which means it's created on the server side by your Extension), its Room Variables are never destroyed (unless you restart the server, or you implement Room Persistence - check this article we just published).
To check the state of Room Variables, after joining a Room, the client can access the SFSRoom.GetVariable or SFSRoom.GetVariables methods.
To check the state of Room Variables, after joining a Room, the client can access the SFSRoom.GetVariable or SFSRoom.GetVariables methods.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Re: enitity.variables .jar
https://imgur.com/jaiWD5z
https://imgur.com/9Au476U
I kind of understood everything, but when loading the scene, all the doors behave strangely and gives an error for each door. Is it possible that you will shoot any video on the setup? it will be clearer to everyone, because so far I find the information in chunks and my hands do not quite understand what to do
Thank you for taking the time
Do I just need to implement the room save initialization extension and shove it into my BasicExemple Zone ?
https://imgur.com/9Au476U
I kind of understood everything, but when loading the scene, all the doors behave strangely and gives an error for each door. Is it possible that you will shoot any video on the setup? it will be clearer to everyone, because so far I find the information in chunks and my hands do not quite understand what to do
Thank you for taking the time
Do I just need to implement the room save initialization extension and shove it into my BasicExemple Zone ?
Re: enitity.variables .jar
I'm not sure how to help. I guess it's a matter of checking the errors you get and fix them.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Who is online
Users browsing this forum: No registered users and 103 guests