Jump to content
  • 0

Access to \onlinecount as an ingame integer?


Uranochos

Question

I am testing multiplayer and need a way to calculate with the number of players which are online. The chatbox message works fine, so the game has a way to access the variable I need.

But if I try to use this as a variable for a conditional branch, the integer remains 0. (You see this in the picture in the text line "..you are the only player online...", which depends on the condition: number of players =< 1).

 

e0471202ebd79112e62139f6077c1012.png

 

There is an event trigger "login", will there be the counterpart "logout"?

The reason why I have to find a solution is that re-arrangement of pathways and resetting of dungeons is preferably done when the first player logs in on the empty server.

 

Any suggestions?

 

____________________________________________________________________________________________________________________________

EDIT:

 

Thank you, AisenArvalis!

 

The game has access to the variable, since the correct value is displayed in the chatbox. But it is presented as a string, not as an integer, hence I can not calculate with the variable.

 

Quote

Set Variable > Online Players Int = Online Players String 

 

Since with numbers, the string is the same as the integer, this works fine as a substitute for functions like Int to String, Float to Int and so on, which are not (yet) in the engine.

 

I rewrote the event which now works fine. I will do some testing with players that logout during battles.

 

46f9036a80414b73de7a97ce16e6d3e2.png

 

EDIT 2:

 

...Afterthought:

For the purpose of creating such a simple condition as in the event shown above, without having to calculate, you could skip the conversion from string to integer and use the condition: NOT [PlayersActiveString = 1].

 

 

Edited by Uranochos
Simple solution found
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Got a fix for this. It's a little roundabout because of how Intersect handles variables.
Make a Global Variable of String type and call it "Online Players String" (Or w/e you wanna call it)
Make another Global Variable of Integer type this time, I'm calling it "Online Players Int" with the variable ID of "onlineplayers"

Make a Common Event with the trigger "Login"

Set Variable > Online Players String = \onlinecount                             This will set this variable to be equal to the onlinecount

Set Variable > Online Players Int = Online Players String                     I know this looks weird, but trust me, it'll make the variable = to onlinecount just fine.

Conditional Branch (Online Players Int > X)                                           This will now function just fine.

Link to comment
Share on other sites

  • 0
3 hours ago, Uranochos said:

There is an event trigger "login", will there be the counterpart "logout"?

So, there is no such thing, since to activate events the player needs to be online. It doesn't make sense to have the login activator (although it would be extremely useful on hundreds of occasions)

 

By your title you wanted to access \onlinecount as if it were a variable integer?

 

The easy part is that you can put a variable to check when someone logs in and use it for different things. Every time someone logs in add 1.

 

The hard part is checking through events how many players are online to remove when someone leaves so that events are activated in that case.

 

What's more, there are "false positives" players online. Players who left due to being in battle with monsters but that their accounts are kept online thanks to the intersect system to prevent players from going out in battle.

 

I tested and these players, for example, the server identifies that they are offline.

 

6a241ed36b0a95b2a8fe7ed6ba8abf57.png

 

That player above the text box is an offline account. \onlinecount shows that only I am online.

 

In my tests.

 

If he for example is in a party, he gains xp and get new level. Even if he leaves the party, when he logs back in, he remains in the party of the player who did not leave and gains xp too.

 

In this photo, this player has a light around it, it is a "consumable" item it is an item that is removed by events after a certain period of use. And yes, it was removed after a while, conclusion:  events continue to run even without anyone online (0 players) if there is an account stopped in the game in this way. Until the current moment of the engine (use version 6.1.259).

 

Final Conclusion: through events we can somehow check when a player leaves, (two people have already done this for events here on the forum), but now there are other situations like this, where the offline player remains and the events recognize him as online. In your counts this could disrupt everything.

Link to comment
Share on other sites

  • 0

Most reliable way of doing this would probably be to add a new conditional check yourself for how many players are online.

 

Alternatively, run an external cronjob against the api to check things and change variables around to reset stuff when you need to. This method is more reliable as it can even run when nobody is online.

Link to comment
Share on other sites

  • 0
1 hour ago, AisenArvalis said:

Got a fix for this. It's a little roundabout because of how Intersect handles variables.
Make a Global Variable of String type and call it "Online Players String" (Or w/e you wanna call it)
Make another Global Variable of Integer type this time, I'm calling it "Online Players Int" with the variable ID of "onlineplayers"

Make a Common Event with the trigger "Login"

Set Variable > Online Players String = \onlinecount                             This will set this variable to be equal to the onlinecount

Set Variable > Online Players Int = Online Players String                     I know this looks weird, but trust me, it'll make the variable = to onlinecount just fine.

Conditional Branch (Online Players Int > X)                                           This will now function just fine.

This is great! The server itself will update the variable when someone logs in. Have you tested these with people who go offline in battle? Would it be possible to find ways to know when someone logged out? I will apply your comment to my game right now. :8_laughing:

Link to comment
Share on other sites

×
×
  • Create New...