Guest User

Untitled

a guest
Oct 18th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.01 KB | None | 0 0
  1. local Police = createTeam("Police", 0, 0, 255)
  2. setTeamFriendlyFire( Police, false )
  3.  
  4. addEventHandler("onPlayerDamage", root,
  5. function( attacker, attackerweapon, bodypart, loss )
  6.     if ( getPlayerTeam( source ) == Police ) then
  7.         if ( attacker ) and ( loss >= 10 ) then
  8.             local wantedLevel=getPlayerWantedLevel(attacker)
  9.             wantedLevel=wantedLevel+math.floor(loss/10)
  10.             if wantedLevel>6 then wantedLevel=6 end
  11.             setPlayerWantedLevel(attacker,wantedLevel)
  12.         end
  13.     end
  14. end)
  15.  
  16. addEventHandler("onPlayerWasted", root,
  17. function( _, killer )
  18.     if ( getPlayerTeam( source ) == Police ) then
  19.         if ( killer ) then
  20.             setPlayerWantedLevel(killer, math.max(math.min(getPlayerWantedLevel(killer)+1,6),3))
  21.         end
  22.     end
  23. end)
  24.  
  25. local function thereAreNoPoliceNearby(player,range)
  26.     local x,y,z=getElementPosition(player)
  27.     local cs=createColSphere(x,y,z,range or 50)
  28.     local playersNearby=getElementsWithinColShape(cs,"player")
  29.     destroyElement(cs)
  30.     for _,otherPlayer in ipairs(playersNearby) do
  31.         if getPlayerTeam(otherPlayer)==Police then
  32.             return false
  33.         end
  34.     end
  35.     return true
  36. end
  37.  
  38. local function lowerPlayersWantedLevel()
  39.     for _,player in ipairs(getElementsByType("player")) do
  40.         local wantedLevel=getPlayerWantedLevel(player)
  41.         if wantedLevel>0 then
  42.             if thereAreNoPoliceNearby(player) then
  43.                 setPlayerWantedLevel(player, wantedLevel-1)
  44.             end
  45.         end
  46.     end
  47. end
  48. setTimer( lowerPlayersWantedLevel, 60*1000*3, 0)
  49.  
  50. -- take a look here
  51. addEventHandler("onPlayerDamage", root,
  52. function( attacker, attackerweapon, bodypart, loss )
  53.     local policeTeam = getPlayerTeam( attacker )
  54.         if ( policeTeam == Police ) and ( attacker == Police ) then
  55.         if ( wantedLevel > 0 ) then
  56.         if ( attackerweapon == 3 ) and ( loss > 10 ) then
  57.             outputChatBox(getPlayerName(source) .. "was Jailed by" .. getPlayerName( attacker ))
  58.         end
  59.         end
  60.         end
  61.     end
  62. end)
Add Comment
Please, Sign In to add comment