Simplish lua problem

SintSint Join Date: 2007-01-09 Member: 59540Members, Squad Five Blue
<div class="IPBDescription">Need to get Player SteamId in function NS2Gamerules:OnEntityCreate()</div>Hi, I am having problems trying to get player SteamId in function NS2Gamerules:OnEntityCreate(entity). Function is found at lua/NS2GameRules.lua file.

Normally I use:

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->local client = Server.GetOwner(player)
local steamId = client.GetUserId()<!--c2--></div><!--ec2-->

to get the steamId but can't really use that there it seems.

Function below will get SteamId sometimes, but not always and anyway its not very good way to get it. This won't get it when player exists commander chair or spawns from infantry portal at least.

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->local origin = entity.GetOrigin()

for index, player in ientitylist(Shared.GetEntitiesWithClassname("Player")) do                            

local porg = player:GetOrigin()

  if porg.x == origin.x and porg.y == origin.y and porg.z == origin.z then
    local client = Server.GetOwner(player)                        
      if client ~= nil then                                                          
        local steamId = client:GetUserId()
        break
      end

  end

end<!--c2--></div><!--ec2-->

I have tried some other ways to get it also, but not been able to get it 100% of time. So I wonder if anyone has any ideas how to get it there?

Comments

  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    I've not done much work on admin tools, but as far as I am aware the way NS deals with the steam id has caused a bit of frustration among modders. One of the best people to talk to about this would be player, ask in his overmind thread.
Sign In or Register to comment.