Jump to content

need help!


Recommended Posts

hei raga.... ma cos'è che ho ciccato in sto codice???

server

createBlip ( 1552.4996337891, -1677.3264160156, 15.1953125, 30 ) 
local jailBlip = createBlip ( 1799.9298095703, -1584.1966552734, 13.488187789917, 20 ) 
local jailMark = createMarker( 1799.9298095703, -1584.1966552734, 13.488187789917, "Cylinder" , 1.5, 0, 0, 255, 150) 
  
function createSAPDTeam () 
    SAPDteam = createTeam ("police", 100, 149, 237) 
end 
addEventHandler ("onResourceStart", resourceRoot, createSAPDTeam) 
  
function joinSAPD() 
     setPlayerTeam(source,SAPDteam) 
     setElementModel(source, 280) 
      giveWeapon ( source, 3 ) 
     setElementData( source, "Occupation", "Copteam", true ) 
     outputChatBox("You are now SAPD agent.",source,0,255,0) 
end 
addEvent("setSAPD", true) 
addEventHandler("setSAPD",root,joinSAPD) 
  
function policeJob ( attacker, attackerweapon, bodypart, loss ) 
if attacker and getElementType(attacker) == "player" then 
    theTeam = getPlayerTeam ( attacker )  
    theWL = getPlayerwantedLevel( source ) 
     attackerweapon = getPedWeapon(attacker) 
    if (attackerweapon == 3) and (loss > 2 ) then 
     if getTeamName(getPlayerTeam(attacker)) == "police" then 
     if ( theWL > 0 ) then  
triggerEvent ( "CriminalFollow", root, "test" ) 
        end 
         end 
        end 
  end 
end 
addEventHandler ("onPlayerDamage", getRootElement(), policeJob) 
  
  
--FORCES A PRISONER TO FOLLOW THE COP 
function walktheprisoner(thecop, theprisoner) 
    if (getElementData ( theprisoner, "currentstatus" ) == "underarrest") and (getPedOccupiedVehicle ( theprisoner ) == false ) then 
        local copx, copy, copz = getElementPosition ( thecop ) 
        local prisonerx, prisonery, prisonerz = getElementPosition ( theprisoner ) 
        copangle = ( 360 - math.deg ( math.atan2 ( ( copx - prisonerx ), ( copy - prisonery ) ) ) ) % 360 
        setPedRotation ( theprisoner, copangle ) 
        setCameraTarget ( theprisoner, theprisoner ) 
        local dist = getDistanceBetweenPoints2D ( copx, copy, prisonerx, prisonery ) 
        if ( dist > 16 ) then 
            freetheguy ( theprisoner ) --FREES PRISONER IF HE GETS FAR AWAY 
        elseif ( dist > 12 ) then 
            setControlState ( theprisoner, "sprint", true ) 
            setControlState ( theprisoner, "walk", false ) 
            setControlState ( theprisoner, "forwards", true ) 
            local zombify = setTimer ( walktheprisoner, 500, 1, thecop, theprisoner ) 
        elseif ( dist > 6 ) then 
            setControlState ( theprisoner, "sprint", false ) 
            setControlState ( theprisoner, "walk", false ) 
            setControlState ( theprisoner, "forwards", true ) 
            local zombify = setTimer ( walktheprisoner, 500, 1, thecop, theprisoner ) 
        elseif ( dist > 1.5 ) then 
            setControlState ( theprisoner, "sprint", false ) 
            setControlState ( theprisoner, "walk", true ) 
            setControlState ( theprisoner, "forwards", true ) 
            local zombify = setTimer ( walktheprisoner, 500, 1, thecop, theprisoner ) 
        elseif ( dist < 1.5 ) then 
            setControlState ( theprisoner, "sprint", false ) 
            setControlState ( theprisoner, "walk", false ) 
            setControlState ( theprisoner, "forwards", false ) 
            local zombify = setTimer ( walktheprisoner, 500, 1, thecop, theprisoner ) 
        end 
    end 
end 
addEvent("CriminalFollow", true ) 
addEventHandler( "CriminalFollow", root, walktheprisoner ) 
  
  
--FREES A PLAYER (RESETS THEIR CONTROLS AND STATUS) 
function freetheguy (theprisoner) 
    local thecaptor = (getElementData ( theprisoner, "captor" )) 
    setElementData ( theprisoner, "currentstatus", "none" ) 
    setElementData ( theprisoner, "captor", "none" ) 
    showCursor ( theprisoner, false ) 
    setControlState ( theprisoner, "sprint", false ) 
    setControlState ( theprisoner, "walk", false ) 
    setControlState ( theprisoner, "forwards", false ) 
    toggleAllControls (theprisoner, true)    
    local prisonercheck = setTimer ( checkforprisoners, 1500, 1, thecaptor ) 
    TimoutTimer = (getElementData ( theprisoner, "arrestTimeout" )) 
    if isTimer(TimoutTimer) then 
         killTimer(TimoutTimer) 
         setElementData ( theprisoner, "arrestTimeout", nil) 
         TimeoutTimer = nil 
         setElementPosition( theprisoner, 4076.3999023438, -1788.5, 3.511967, true ) 
     setTimer ( setElementPosition, 10000, 1, theprisoner, 1544.4332275391, -1674.7698974609, 13.688399200439)       
     setPlayerWantedLevel (theprisoner, 0) 
    end 
end 
addEventHandler( "onMarkerHit", jailMark , freetheguy ) 
  
function checkforprisoners(thecop) 
    if isElement(thecop) then 
        local prisoners = 0 
        local players = getElementsByType ( "player" ) 
        for theKey,thePlayer in ipairs(players) do 
            if (getElementData ( thePlayer, "captor" ) == thecop ) then 
                prisoners = prisoners+1 
            end 
        end 
        if prisoners == 0 then 
            setElementData ( thecop, "currentarrests", "none" ) 
            triggerClientEvent( thecop,"clearcopdirections",thecop) 
        elseif prisoners == 1 then 
            setElementData ( thecop, "currentarrests", "single" ) 
        elseif prisoners == 2 then 
            setElementData ( thecop, "currentarrests", "double" ) 
        end 
    end 
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_Button[2] = guiCreateButton(179,200,110,36,"Cancel",false,windowjob) 
        GUIEditor_Label[1] = guiCreateLabel(19,33,273,100,"Are you sure you want to take this job?",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) 
    

Link to comment

La wiki credo che parli chiaro :|

  
function MarkerHit( hitElement, matchingDimension ) -- define MarkerHit function for the handler 
  
-- mentre la tua funzione è : 
  
function freetheguy (theprisoner) 
  
-- Try this one 
  
function freetheguy (hitElement, matchingDimension) 
  
-- l evento e giusto 
  
addEventHandler( "onMarkerHit", jailMark , freetheguy ) 
  
--    jailMark (nome del marker)          freetheguy (nome funzione) 
  
  

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