Jump to content

SLOTS AND CLIENTS


Lineaxe

Recommended Posts

Hi, In my mission I am writing we tend to crash a bit and use the slots to join back in again instead of restarting the whole game. In some places in my lua code I would like to find out what plane/helicopter/tank each player has selected and is inside of at the current moment. Since we do die and switch around, that is . It sure would make my current code smaller and smoother if I could get that information , I would think.:noexpression:

Link to comment
Share on other sites

You don't need to bump a thread again after half an hour.

 

Well the answer is fairly simple, though knowing the context is a little more difficult. I mean usually my group plays we sign up for certain slots and if any of us crash we just go back to the one we are in. The answer is quite different depending on if you are using the mission scripting environment or gameGUI with the intent to block slots.

 

If its mission then:

Client aircraft are only client aircraft, so if any of them exist then you know only a player can be in that aircraft. You can compile a list of each client, use coalition.getPlayers(), or whatever and use Unit.getPlayerName() to add to a table. Keep in mind that for multicrew aircraft the value returned with getPlayerName() changes based on who joined/left the aircraft last.

 

local clientAircraft = {}

local function checkPlayers()
local players = coalition.getPlayers(2)

for i = 1, #players do
   local pUnit = players[i]
       if pUnit:getPlayerName() then
            clientAircraft[pUnit:getName()] = pUnit.getPlayerName()
       end
   end
end

 

If its gamegui and you want to limit slots its similar but you'd build a table via the callbacks like onPlayerTryChangeSlot to keep track of who is where, save their UCID, and only allow that player into an empty slot.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...