Jump to content

[HELP]Police system


Erhan1

Recommended Posts

  
  
function polisOl () 
  local account = getPlayerAccount ( source ) 
   if ( account ) then 
    local data = getAccountData ( account, "meslek2" ) 
     if not ( data == "polis" ) then 
      setAccountData ( account , "meslek2", "polis" ) 
      setAccountData ( account , "Meslek", "Polis" )     
      setElementData ( source, "meslek2", "tirci" ) 
      setElementModel(source,265) 
      giveWeapon ( source, 3 ) 
         outputChatBox("Polis oldun, sana verilen jop ile suçluları yakalayabilirsin.Suçluların üzerinde yıldız işareti vardır.",source,0,255,0) 
         setElementData ( source, "Meslek", "Polis" ) 
    else 
        outputChatBox("Mesleğiniz zaten polis veya giriş yapmadınız !",source,255,0,0) 
      
end 
end 
end 
addEvent("polisOl",true) 
addEventHandler("polisOl", root, polisOl) 
  
  
function yildizAlma1 ( attacker, weapon, bodypart, loss ) 
if  ( attacker and getElementType ( attacker ) == "player" )  then 
 local attackerJob = getElementData ( attacker, "meslek2" ) 
  local sourceJob = getElementData ( source , "meslek2" ) 
   local attackerYildiz = getPlayerWantedLevel ( attacker ) 
    if attackerYildiz  == 0 then 
     if not attackerJob == "polis"  then 
      setPlayerWantedLevel ( attacker, attackerYildiz + 1 ) 
end 
end 
end    
end 
addEventHandler ( "onPlayerDamage", getRootElement (), yildizAlma1 ) 
  
function yildizAlma2 ( ammo, attacker, weapon, bodypart ) 
 if ( attacker ) then 
   if ( getElementType ( attacker ) == "player" ) then 
     local sourceJob = getElementData ( source , "meslek2" ) 
     local attackerJob = getElementData ( attacker, "meslek2" ) 
       local attackerYildiz = getPlayerWantedLevel ( attacker ) 
        local attackerKillSayisi = getElementData ( attacker, "kills" ) 
         if ( attackerKillSayisi < 3 ) then 
          if not attackerJob == "polis" then 
           if attackerYildiz < 2 then 
            setPlayerWantedLevel ( attacker, attackerYildiz + 1 )     
             setElementData ( attacker, "kills" , attackerKillSayisi + 1 ) 
            end 
            end 
         elseif ( attackerKillSayisi > 3 ) then  
          if not attackerJob == "polis" then 
           if attackerYildiz < 4 then 
            setPlayerWantedLevel ( attacker, attackerYildiz + 1 )    
              setElementData ( attacker, "kills" , attackerKillSayisi + 1 )          
              end 
              end 
         elseif ( attackerKillSayisi > 6 ) then      
            if not attackerJob == "polis" then   
              if attackerYildiz < 6 then     
               setPlayerWantedLevel ( attacker, attackerYildiz + 1 )     
                setElementData ( attacker, "kills" , attackerKillSayisi + 1 )    
       end 
end    
end 
end 
end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), yildizAlma2 ) 
  
  
  
function yildizAlma3 ( ammo, attacker, weapon, bodypart ) 
if ( attacker ) then 
 if ( getElementType ( attacker ) == "vehicle" ) then 
  local surucu = getVehicleController ( attacker ) 
   if surucu then 
     local sourceJob = getElementData ( source , "meslek2" ) 
     local attackerJob = getElementData ( surucu, "meslek2" ) 
     local attackerYildiz = getPlayerWantedLevel ( surucu ) 
      if not attackerJob == "polis" then 
        if attackerYildiz < 2 then 
         setPlayerWantedLevel ( surucu, attackerYildiz + 1 ) 
end 
end 
end 
end 
end 
end       
addEventHandler ( "onPlayerWasted", getRootElement(), yildizAlma3 ) 
  
  
  
function jopYakala ( attacker, weapon ) 
 if  ( attacker and getElementType ( attacker ) == "player" )  then 
  if ( weapon == 3 and not isPedDead(source) ) then 
    local attackerJob = getElementData ( attacker, "meslek2" ) 
    local sourceJob = getElementData ( source , "meslek2" ) 
     if ( attackerJob == "polis" ) then 
      local wanted = getPlayerWantedLevel ( source )  
       if ( wanted > 0 ) then 
        local arrestedmi = getElementData ( source , "arrested" ) 
        local jailedmi = getElementData ( source, "jailed" ) 
         if not ( arrestedmi or jailedmi == "evet" ) then 
          setElementData ( source, "arrested", "evet" ) 
           showCursor ( source, true ) 
           setElementData ( source, "yildizsayisi", wanted ) 
           local ad = getPlayerName ( source ) 
           local acc = getPlayerAccount ( source ) 
            local acc2 = getAccountName ( acc ) 
           setAccountData ( attacker, "suclu", acc2 ) 
           triggerClientEvent(source, "yakalandi", source) 
            triggerClientEvent(attacker, "yakaladi", attacker) 
           toggleAllControls(source, false, true, false) 
           local copX, copY, copZ = getElementPosition(attacker) 
           local PrisonerX, PrisonerY, PrisonerZ = getElementPosition(source) 
           local dis = getDistanceBetweenPoints3D(copX, copY, copZ, PrisonerX, PrisonerY, PrisonerZ) 
           if (dis > 20) then  
            if not isTimer(tooFarCopTimer) then 
             setElementPosition ( source, copX + 1, copY + 1, copZ ) 
                setControlState(source,"forwards", false) 
                setControlState(source,"walk", false) 
                setControlState(source,"sprint", false) 
                tooFarCopTimer = setTimer(function() end, 3000, 1) 
                end 
           elseif (dis > 10) then 
            setControlState(source,"forwards", true) 
            setControlState(source,"sprint", true) 
            setControlState(source,"walk", false) 
           elseif (dis > 3) then 
            setControlState(source,"forwards", true) 
            setControlState(source,"sprint", false) 
            setControlState(source,"walk", false) 
           elseif (dis > 2) then 
            setControlState(source,"forwards", true) 
            setControlState(source,"sprint", false) 
            setControlState(source,"walk", true) 
           elseif (dis > 1) then 
            setControlState(source,"forwards", false) 
            setControlState(source,"walk", false) 
            setControlState(source,"sprint", false)  
end 
setPedRotation(source, 360-math.deg(math.atan2((copX-PrisonerX), (copY-PrisonerY))) % 360)           
        end 
    end 
end 
end 
end 
addEventHandler ( "onPlayerDamage", getRootElement(), jopYakala ) 
  
  
function hapseAt ( ) 
local data = getPlayerAccount ( source ) 
 local ad = getAccountData ( data , "suclu" ) 
  local hirsiz = getPlayerFromName ( ad )  
   if ( hirsiz ) then 
    setElementInterior ( hirsiz , 200 ) 
    setElementPosition ( hirsiz , 1533.3000488281 , -1506.5999755859 , 2534.1000976563 ) 
    setElementData ( hirsiz, "jailed", "evet" ) 
    setAccountData ( data, "suclu", false ) 
    local yildiz = getPlayerWantedLevel ( hirsiz ) 
     givePlayerMoney ( source, 1000*yildiz ) 
      triggerClientEvent ( hirsiz, "hapseGirdi", hirsiz, yildiz ) 
     end  
    end  
addEvent ( "hapseAt", true ) 
addEventHandler("hapseAt", root , hapseAt) 
  
  
function olumsuzluk ( attacker, weapon, bodypart, loss ) 
local data = getElementData ( source, "arrested" ) 
local data2 = getElementData ( source, "jailed" ) 
 if ( data or data2 == "evet" ) then 
  cancelEvent () 
  end 
  end 
addEventHandler ( "onPlayerDamage", getRootElement (), olumsuzluk ) 
  
function olumsuzluk2 ( attacker, weapon, bodypart, loss ) 
local data = getElementData ( attacker, "arrested" ) 
local data2 = getElementData ( attacker, "jailed" ) 
 if ( data or data2 == "evet" ) then 
  cancelEvent () 
  end 
  end 
addEventHandler ( "onPlayerDamage", getRootElement (), olumsuzluk ) 
  

I'm trying to make a police system, But when i hit someone with nightstick it's not working.And when i kill or shoot someone i

don't get stars. Please help me what's the problem?

Link to comment

Go in-game, then press 't' and typ:

/debugscript 3

You need to be logged in and you need to be Admin.

You also can press 'F8' and typ:

debugscript 3

Same with Admin.

Then, start/restart your resource. All error's that appear there, post them here. (For quick-copy, press 'F8' and typ them there. If you are done, then copy and paste them here)

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