Jump to content

why is this not working?


Recommended Posts

function presidentArrived(thePlayer)
local skin = getPlayerSkin(thePlayer)
if (skin == 21) then
outputChatBox("The President has arrived!", player, 0, 120, 80, false)
end
end
addEventHandler("onPlayerSpawn", getRootElement(), presidentArrived)

 

The point of the script is when the president spawns (he has skin id 21), everyone gets a message saying ''the president has arrived''

This should work, you would think. But it doesn't. Instead, it gives this error: bad argument @ getPlayerSkin, expected element at argument 1 got number 395.28475 and some other weird numbers

That's each time when someone spawns, and the number equals the X position of the location where the player spawns.

It doesn't make any sense. I tried getPlayerSkin, getElementModel, getPedSkin, different elements, nothing worked. Help please.

Edited by marty000123
Link to comment
function presidentArrived()
    setTimer(
        function( source )

            local skin = getElementModel(source)

            if (skin == 21) then
                outputChatBox("The President has arrived!", getRootElement(), 0, 120, 80, false)
            end
        end, 2500, 1, source
        )
end
addEventHandler("onPlayerSpawn", getRootElement(), presidentArrived)

Maybe your spawn script sets the skin a bit late, so I guess this should work.

Link to comment
17 minutes ago, Anubhav said:

function presidentArrived()
    setTimer(
        function( source )

            local skin = getElementModel(source)

            if (skin == 21) then
                outputChatBox("The President has arrived!", getRootElement(), 0, 120, 80, false)
            end
        end, 2500, 1, source
        )
end
addEventHandler("onPlayerSpawn", getRootElement(), presidentArrived)

Maybe your spawn script sets the skin a bit late, so I guess this should work.

Worked!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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