Announcement

Collapse
No announcement yet.

Problem with OnPlayerJoin Function

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem with OnPlayerJoin Function

    I have this code:
    Server side
    Code:
     AddEvent("OnPlayerJoin", function(player)
    SetPlayerSpawnLocation(player, 125773.000000, 80246.000000, 1645.000000, 90.0)
    Delay(10000, function(player)
    local chars = {26, 27, 28, 29}
    local r = math.random(4)
    CallRemoteEvent(player, "SetClientClothingPreset", chars[r])
    end)
    end)
    Client side
    Code:
     AddRemoteEvent("SetClientClothingPreset", function (presetId)
    SetPlayerClothingPreset(GetPlayerId(), presetId)
    end)
    But i receive the following error on the console.

    Code:
    [error] [string "ttt/ttt_s.lua"]:12: bad argument #1 to 'CallRemoteEvent' (expected integer-like argument)
    How i can fix this ?
    A Command with the same code works.
    Code:
     functioncmd_new(player)
    local chars = {26, 27, 28, 29}
    local r = math.random(4)
    CallRemoteEvent(player, "SetClientClothingPreset", chars[r])
    AddPlayerChat(player, "New.")
    end
    AddCommand("new", cmd_new)

    #2
    Try this ( tested ):

    Code:
    AddEvent("OnPlayerJoin", function(player)
        SetPlayerSpawnLocation(player, 125773.000000, 80246.000000, 1645.000000, 90.0)
        CreateCountTimer(function()
            local chars = {26, 27, 28, 29}
            local r = math.random(4)
            CallRemoteEvent(player, "SetClientClothingPreset", chars[r])
        end,1000,1)
    end)
    Last edited by Skydox; 01-14-2020, 07:00 PM.

    Comment

    Working...
    X