Jump to content

[HELP] Police team...


lolman

Recommended Posts

Hey there,

I've got a new problem here with my code. I want that if you're in the Police team then you can't get wanted levels and you can't damage other players which are not wanted... if someone could help me out...

function wantedLevelChange(attacker, weapon, bodypart, loss) 
    if getTeamName(getPlayerTeam(attacker)) == "Police" then 
    cancelEvent() 
    end 
end 
addEventHandler("onPlayerDamage", getRootElement(), wantedLevelChange) 

I know that my code isn't a really good begin of it but I don't know how to begin with it in this case...

Link to comment

Try this

function wantedLevelChange(attacker, weapon, bodypart, loss) 
    local playerTeam = getPlayerTeam ( attacker ) 
        if playerTeam then 
        local teamName = getTeamName(playerTeam) 
            if ( teamName ~= "Police" ) then 
            setPlayerWantedLevel(attacker, 3)--If team not "Police", sets the wanted stars to 3. 
            else 
            setPlayerWanted(attacker, 0)--If team "Police", sets the wanted stars to 0.  
        end 
end 
end 
addEventHandler("onPlayerDamage", getRootElement(), wantedLevelChange) 

Link to comment
function wantedLevelChange(attacker, weapon, bodypart) 
    if isElement(attacker) and getElementType(attacker) == "player" then 
        local playerTeam = getPlayerTeam ( attacker ) 
        if playerTeam then 
        local teamName = getTeamName(playerTeam) 
            if ( teamName ~= "Police" ) then 
                if ( bodypart == 9 ) then 
                setPlayerWantedLevel(attacker,5) 
                else setPlayerWantedLevel(attacker,3) return end 
            else 
                if ( bodypart == 9 ) then 
                setPlayerWantedLevel(attacker,0) 
                else setPlayerWantedLevel(attacker,3) return end 
            end 
        end 
    end                  
end 
addEventHandler("onPlayerDamage", getRootElement(), wantedLevelChange) 

  • Like 1
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...