lolman Posted July 6, 2015 Share Posted July 6, 2015 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
HUNGRY:3 Posted July 6, 2015 Share Posted July 6, 2015 What u need is setPlayerWantedLevel getPlayerWantedLevel Link to comment
bosslorenz Posted July 6, 2015 Share Posted July 6, 2015 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
lolman Posted July 6, 2015 Author Share Posted July 6, 2015 Friendlyfire part? Btw your script doesn't work : error attempt to call global 'setPlayerWantedLevel' (a nil value) Link to comment
bosslorenz Posted July 6, 2015 Share Posted July 6, 2015 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) 1 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