marty000123 Posted March 30, 2017 Share Posted March 30, 2017 (edited) 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 March 30, 2017 by marty000123 Link to comment
NeXuS™ Posted March 30, 2017 Share Posted March 30, 2017 (edited) function presidentArrived() local skin = getElementModel(source) if (skin == 21) then outputChatBox("The President has arrived!", getRootElement(), 0, 120, 80, false) end end addEventHandler("onPlayerSpawn", getRootElement(), presidentArrived) The "getPedSkin" function is deprecated. Edited March 30, 2017 by NeXuS™ Link to comment
marty000123 Posted March 30, 2017 Author Share Posted March 30, 2017 Thanks for your reply, it fixed the warning. But the message doesn't show up. I made sure the skin ID was indeed 21, but it just doesn't work. Link to comment
NeXuS™ Posted March 30, 2017 Share Posted March 30, 2017 Try debugging it. (Use outputChatBox with the skinID, so you can see what's happening.) Link to comment
Anubhav Posted March 30, 2017 Share Posted March 30, 2017 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
marty000123 Posted March 30, 2017 Author Share Posted March 30, 2017 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now