Jump to content

Change skin


Recommended Posts

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
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

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

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...