TorNix~|nR Posted July 17, 2016 Share Posted July 17, 2016 Hi everyone, I have a panel of giving a team so I make a give skin in panel, I need to disable giving skin if a player is not in the team, check my code: function Skinc (sourcee1) local playerr = getPlayerFromName(sourcee1) if getPlayerTeam(playerr, "Militar") then outputChatBox (getPlayerName(playerr) .. ' is not Militar Member!', source, 255, 0, 0 ) return end setElementModel ( playerr, 17 ) outputChatBox (getPlayerName(playerr) .. ' #00FF00Has been giving a Militar Skin', source, 255, 0, 0) outputChatBox (getPlayerName(source) .. ' #00FF00Has been giving a Militar Skin', playerr, 255, 0, 0 ) end addEvent( "Skinc", true) addEventHandler( "Skinc", getRootElement(), Skinc ) Link to comment
RaceXtreme Posted July 18, 2016 Share Posted July 18, 2016 function Skinc (sourcee1) local playerr = getPlayerFromName(sourcee1) if getPlayerTeam ( playerr ) == nil then outputChatBox("The Player is not in a team.") return end ... end This line of code will check if the player's team is nil. If does, he doesn't belong to a team and the function terminates. And if your script isn't executing you commited syntax mistakes, like in the line 3. Try to enable debugging and check the Wiki. Link to comment
TorNix~|nR Posted July 18, 2016 Author Share Posted July 18, 2016 I need get this team "Militar" not nil and this is not work, also there is nothing in debug if getPlayerTeam ( playerr ) == nil then Link to comment
EstrategiaGTA Posted July 18, 2016 Share Posted July 18, 2016 You will have to use getTeamFromName. Try this: function Skinc (sourcee1) local playerr = getPlayerFromName(sourcee1) if getPlayerTeam(playerr) ~= getTeamFromName("Militar")) then outputChatBox (getPlayerName(playerr) .. ' is not Militar Member!', source, 255, 0, 0 ) return end setElementModel ( playerr, 17 ) outputChatBox (getPlayerName(playerr) .. ' #00FF00Has been giving a Militar Skin', source, 255, 0, 0) end addEvent( "Skinc", true) addEventHandler( "Skinc", getRootElement(), Skinc ) Also make sure you passed sourcee1 from the trigger as a player name (string) and not the player itself, else your code will be wrong. Source is not defined in your function either, so I am deleting the outputChatBox with it. 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