Announcement

Collapse
No announcement yet.

Problem with GetPlayerPropertyValue

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem with GetPlayerPropertyValue

    Hello,
    I got a problem with "GetPlayerPropertyValue", it works only Serverside.


    Serverscript - same result with other values.
    PHP Code:
    AddEvent("OnPlayerJoin", function(playerID)
      
    SetPlayerPropertyValue(playerID"testValue"playerID 1true)
    end

    Clientscript
    PHP Code:
    AddEvent("OnPlayerSpawn", function()
      
    AddPlayerChat("P: "..GetPlayerPropertyValue(GetPlayerId(), "testValue"))
    end

    Errorlog - clientside (no errors serverside)
    PHP Code:
    [2020.01.XX]: [string "test/client.lua"]:2attempt to concatenate a nil value 
    So the log isnt really useful.. in this case ^^

    Hope someone can help me

    #2
    Did you try using “player” instead of “playerID”?

    Comment


      #3
      Hello,
      I found a solution for your problem.
      I believe that the moment OnPlayerSpawn gets triggered the Client doesn't know the PlayerID you requested with GetPlayerId().
      If you do it like this:
      Code:
      AddEvent("OnPlayerSpawn", function()
          CreateCountTimer(function()
              AddPlayerChat("P: "..GetPlayerPropertyValue(GetPlayerId(), "testValue"))
          end,1000,1)
        end)
      It will work fine.
      I'm not sure if you can minimize the delay ( 1000ms/1second ) but this worked fine for me.
      If you have any other Questions just ask.
      ~Skydox

      Comment


        #4
        You can try and use AddPlayerChat to debug it.
        See if GetPlayerId() gives a value.

        PHP Code:
        AddPlayerChat(GetPlayerId()) 
        Try and work through it piece of piece.

        Comment

        Working...
        X