xyz Posted March 27, 2016 Share Posted March 27, 2016 So the thing is I can't get this working. function staffskin(player) if getPlayerTeam(player) == "Staff" then cancelEvent() else end end addEventHandler("onElementModelChange", getRootElement(), staffskin) What's wrong? Link to comment
Moderators Citizen Posted March 27, 2016 Moderators Share Posted March 27, 2016 An empty else is no needed and you are comparing a team element (left) with a team name (right). Also, this event doesn't support cancelation (as 3FreT pointed out) so you have to use setElementModel with the previous model. This event will give you only one parameter which is the previous model so your "player" is wrong, you wanted to use source instead in your getPlayerTeam function call: function staffskin(prevSkin) if getPlayerTeam(source) == getTeamFromName("Staff") then setElementModel(source, prevSkin) end end addEventHandler("onElementModelChange", getRootElement(), staffskin) Also as this event will also be triggered for other elements like objects, cars etc, you need to check if source is a player element or you will get warnings or errors: function staffskin(prevSkin) if getElementType(source) == "player" and getPlayerTeam(source) == getTeamFromName("Staff") then setElementModel(source, prevSkin) end end addEventHandler("onElementModelChange", getRootElement(), staffskin) So this code will prevent any skin change if the player is in the "Staff" team, is it really what you wanted to do ? Link to comment
xyz Posted March 27, 2016 Author Share Posted March 27, 2016 Ohh shit, thanks anyway! 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