Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Police = createTeam("Police", 0, 0, 255)
- setTeamFriendlyFire( Police, false )
- addEventHandler("onPlayerDamage", root,
- function( attacker, attackerweapon, bodypart, loss )
- if ( getPlayerTeam( source ) == Police ) then
- if ( attacker ) and ( loss >= 10 ) then
- local wantedLevel=getPlayerWantedLevel(attacker)
- wantedLevel=wantedLevel+math.floor(loss/10)
- if wantedLevel>6 then wantedLevel=6 end
- setPlayerWantedLevel(attacker,wantedLevel)
- end
- end
- end)
- addEventHandler("onPlayerWasted", root,
- function( _, killer )
- if ( getPlayerTeam( source ) == Police ) then
- if ( killer ) then
- setPlayerWantedLevel(killer, math.max(math.min(getPlayerWantedLevel(killer)+1,6),3))
- end
- end
- end)
- local function thereAreNoPoliceNearby(player,range)
- local x,y,z=getElementPosition(player)
- local cs=createColSphere(x,y,z,range or 50)
- local playersNearby=getElementsWithinColShape(cs,"player")
- destroyElement(cs)
- for _,otherPlayer in ipairs(playersNearby) do
- if getPlayerTeam(otherPlayer)==Police then
- return false
- end
- end
- return true
- end
- local function lowerPlayersWantedLevel()
- for _,player in ipairs(getElementsByType("player")) do
- local wantedLevel=getPlayerWantedLevel(player)
- if wantedLevel>0 then
- if thereAreNoPoliceNearby(player) then
- setPlayerWantedLevel(player, wantedLevel-1)
- end
- end
- end
- end
- setTimer( lowerPlayersWantedLevel, 60*1000*3, 0)
- -- take a look here
- addEventHandler("onPlayerDamage", root,
- function( attacker, attackerweapon, bodypart, loss )
- local policeTeam = getPlayerTeam( attacker )
- if ( policeTeam == Police ) and ( attacker == Police ) then
- if ( wantedLevel > 0 ) then
- if ( attackerweapon == 3 ) and ( loss > 10 ) then
- outputChatBox(getPlayerName(source) .. "was Jailed by" .. getPlayerName( attacker ))
- end
- end
- end
- end
- end)
Add Comment
Please, Sign In to add comment