Jump to content

my police script doesn't work!


Monty

Recommended Posts

don't work

server

createBlip ( 1552.4996337891, -1677.3264160156, 15.1953125, 30 ) 
  
function createSAPDTeam () 
    SAPDteam = createTeam ("SAPD", 100, 149, 237) 
end 
addEventHandler ("onResourceStart", resourceRoot, createSAPDTeam) 
  
function joinSAPD() 
     setPlayerTeam(source,SAPDteam) 
     setElementModel(source, 280) 
      giveWeapon ( source, 3 ) 
     setElementData( source, "Occupation", "SAPD", true ) 
     outputChatBox("You are now SAPD agent.",source,0,255,0) 
end 
addEvent("setSAPD", true) 
addEventHandler("setSAPD",root,joinSAPD) 
  
addEvent("police:arrest", true) 
addEventHandler("police:arrest", root, 
function (police) 
    setElementPosition( source, 68.12606811523, 83.171829223633, 1001.0390625 ) 
        givePlayerMoney(police, 1000) -- Gives 100$ to the medic each time the function is executed 
        takePlayerMoney(source, 100) -- Takes 100$ from the source when he get healed 
    end) 
  

client

local marker = createMarker( 1552.4996337891, -1677.3264160156, 15.1953125, "Cylinder", 1.5, 0, 0, 255, 150) 
  
GUIEditor_Button = {} 
    GUIEditor_Memo = {} 
    GUIEditor_Label = {} 
      
    function guiMyCwindow(w,h,t) 
      local x,y = guiGetScreenSize() 
      return guiCreateWindow((x-w)/2,(y-h)/2,w,h,t,false) 
    end 
      
    windowjob = guiMyCwindow(301,250,"SAPD agent") 
    guiSetVisible(windowjob, false) 
    GUIEditor_Button[1] = guiCreateButton(22,200,108,35,"Take job",false,windowjob) 
    GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,windowjob) 
    GUIEditor_Button[2] = guiCreateButton(179,200,110,36,"Cancel",false,windowjob) 
    GUIEditor_Memo[1] = guiCreateMemo(19,33,273,100,"To take SAPD job, press Take job.\n\nIf you don't want to, press Cancel.",false,windowjob) 
     guiEditSetReadOnly(GUIEditor_Memo[1],true) 
      
    function SAPDjob(hitElement) 
         if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
              if not guiGetVisible(windowjob) then 
                   guiSetVisible(windowjob, true) 
                   showCursor(true) 
              end 
         end 
    end 
    addEventHandler("onClientMarkerHit", marker, SAPDjob) 
      
    function FBIjobleave(leaveElement) 
         if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then 
              if guiGetVisible(windowjob) then 
                   guiSetVisible(windowjob, false) 
                   showCursor(false) 
              end 
         end 
    end 
    addEventHandler("onClientMarkerLeave", marker, SAPDjobleave) 
      
    function joinTeam() 
         triggerServerEvent("setSAPD",localPlayer) 
         guiSetVisible(windowjob, false) 
         showCursor(false) 
    end 
    addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) 
      
    function removeSAPDWindow() 
         guiSetVisible(windowjob, false) 
         showCursor(false) 
    end 
    addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeSAPDWindow, false) 
  
--------  
addEventHandler("onClientPlayerDamage", localPlayer, 
function(attacker, weapon, bodypart, loss) 
team = getPlayerTeam(attacker) 
    if (attacker and getElementType(attacker) == "player" and weapon == 3 and team and getTeamName(team) == "SAPD") then -- Checks if the player is using spray and is into Medic team 
        cancelEvent() -- Cancels the damage cause by the spray 
        if (not isTimer(pause)) then  
            triggerServerEvent("police:arrest", localPlayer, attacker) -- Calls the Server Event 
            pause = setTimer(function() end, 1000, 1) -- Makes a timer for the function so it won't fully heal in the first time 
            end 
        end 
    end 
end) 
  

Link to comment

There was error here i fixed it try it now

local marker = createMarker( 1552.4996337891, -1677.3264160156, 15.1953125, "Cylinder", 1.5, 0, 0, 255, 150) 
  
GUIEditor_Button = {} 
    GUIEditor_Memo = {} 
    GUIEditor_Label = {} 
      
    function guiMyCwindow(w,h,t) 
      local x,y = guiGetScreenSize() 
      return guiCreateWindow((x-w)/2,(y-h)/2,w,h,t,false) 
    end 
      
    windowjob = guiMyCwindow(301,250,"SAPD agent") 
    guiSetVisible(windowjob, false) 
    GUIEditor_Button[1] = guiCreateButton(22,200,108,35,"Take job",false,windowjob) 
    GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,windowjob) 
    GUIEditor_Button[2] = guiCreateButton(179,200,110,36,"Cancel",false,windowjob) 
    GUIEditor_Memo[1] = guiCreateMemo(19,33,273,100,"To take SAPD job, press Take job.\n\nIf you don't want to, press Cancel.",false,windowjob) 
     guiEditSetReadOnly(GUIEditor_Memo[1],true) 
      
    function SAPDjob(hitElement) 
         if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
              if not guiGetVisible(windowjob) then 
                   guiSetVisible(windowjob, true) 
                   showCursor(true) 
              end 
         end 
    end 
    addEventHandler("onClientMarkerHit", marker, SAPDjob) 
      
    function FBIjobleave(leaveElement) 
         if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then 
              if guiGetVisible(windowjob) then 
                   guiSetVisible(windowjob, false) 
                   showCursor(false) 
              end 
         end 
    end 
    addEventHandler("onClientMarkerLeave", marker, SAPDjobleave) 
      
    function joinTeam() 
         triggerServerEvent("setSAPD",localPlayer) 
         guiSetVisible(windowjob, false) 
         showCursor(false) 
    end 
    addEventHandler("onClientGUIClick", GUIEditor_Button[1] , joinTeam, false) 
      
    function removeSAPDWindow() 
         guiSetVisible(windowjob, false) 
         showCursor(false) 
    end 
    addEventHandler("onClientGUIClick", GUIEditor_Button[2] , removeSAPDWindow, false) 
  
--------  
addEventHandler("onClientPlayerDamage", localPlayer, 
function(attacker, weapon, bodypart, loss) 
team = getPlayerTeam(attacker) 
    if (attacker and getElementType(attacker) == "player" and weapon == 3 and team and getTeamName(team) == "SAPD") then -- Checks if the player is using spray and is into Medic team 
        cancelEvent() -- Cancels the damage cause by the spray 
        if (not isTimer(pause)) then  
            triggerServerEvent("police:arrest", localPlayer, attacker) -- Calls the Server Event 
            pause = setTimer(function() end, 1000, 1) -- Makes a timer for the function so it won't fully heal in the first time 
            end 
        end 
        end) 

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