Jump to content

my police script doesn't work!


Monty

Recommended Posts

Posted

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) 
  

ANY SCRIPT REQUEST FOR FREE HERE: http://www.stolka.altervista.org

Posted

Great, so you expect us to know the bug like that? give more information if you really want help.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Post the meta.xml.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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) 

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

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