Jump to content

[help]mechanic_job


MoeezKhan

Recommended Posts

hi all I make mechanic_job when i press take job but skin not change all script have same problem . please fix it and please make it to show in tab panel Please read my all forum i have lot of problem in my script please

please make it player get in towtruck and attach damage car with car wire and go i n mechanic garage and he automaticaly repair player get pay please make it

----client side-----

local GUIEditor = { 
    memo = {}, 
    button = {}, 
    window = {}, 
} 
  
addEventHandler("onClientResourceStart", getResourceRootElement( getThisResource( )), 
    function() 
        local guiX,guiY = guiGetScreenSize() 
        GUIEditor.window[1] = guiCreateWindow((guiX-500)/2, (guiY-350)/2, 500, 350, "Mechanic", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetVisible(GUIEditor.window[1], false) 
         
        bAccept = guiCreateButton(10, 300, 110, 36, "Take job", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[1], "sa-header") 
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") 
        addEventHandler("onClientGUIClick", bAccept, hideGUImc, false) 
        addEventHandler("onClientGUIClick", bAccept, joinMechanicTeam, false) 
         
        bClose = guiCreateButton(126, 300, 110, 36, "Cancel", false, GUIEditor.window[1]) 
        guiSetProperty(bClose, "NormalTextColour", "FFAAAAAA")  
        addEventHandler("onClientGUIClick", bClose, hideGUImc, false) 
         
        GUIEditor.memo[1] = guiCreateMemo(10, 30, 480, 264,  
            "Mechanic\n".. 
            "Your job is to help people repair their cars, refuel ".. 
            "empty fueltanks and help other players in general by ".. 
            "giving them transport to a pay'n'spray where their ".. 
            "cars can be repaired\n\n".. 
            "This job provides you with heavy and powerful vehicles ".. 
            "like the towtruck wich should be used to tow vehicles, ".. 
            "Do not use it for stealing cars since then you will be fired!\n\n".. 
            "By using a pickup truck you can also deliver fuel to people who ".. 
            "ran out of it and need help to reach a gasstation." 
            , false, GUIEditor.window[1]) 
        guiEditSetReadOnly(GUIEditor.memo[1],true)   
    end 
) 
local joinBD3 = createMarker(-1918, 255, 40, "cylinder", 1.5, 255, 200, 0, 50) 
local joinBD4 = createMarker(1065, -1029, 31, "cylinder", 1.5, 255, 200, 0, 50) 
  
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( )), 
    function ( startedRes ) 
        createBlipAttachedTo( joinBD3, 56, 2, 0, 0, 0, 0, 0, 400); 
        createBlipAttachedTo( joinBD4, 56, 2, 0, 0, 0, 0, 0, 400); 
    end 
); 
  
function showGUImc(hitElement) 
    if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
        guiSetVisible(GUIEditor.window[1], true) 
        showCursor( true ) 
    end 
end 
addEventHandler("onClientMarkerHit", joinBD3, showGUImc)  
addEventHandler("onClientMarkerHit", joinBD4, showGUImc)  
function hideGUImc() 
    guiSetVisible (GUIEditor.window[1], false ) 
    showCursor ( false ) 
end 
  
function joinMechanicTeam() 
    triggerServerEvent("mechanic", localPlayer, "teamSet") 
end 
element = nil 
function openVehicleGui ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) 
    if ( clickedElement ) then 
        local elementType = getElementType( clickedElement ) 
        local dist = getDistanceBetweenPoints3D( worldX, worldY, worldZ, getElementPosition( localPlayer )) 
        if elementType == "vehicle" and not getPedOccupiedVehicle( localPlayer ) and ((( getPlayerTeam( localPlayer ) == getTeamFromName( "Civilians" ) and  
            getElementData( localPlayer, "Occupation" ) == "Mechanic" ) or 
            getElementData( localPlayer, "admin" )) and (( not isTimer( cooldown ) and ( dist < 4 )) 
            or getElementData( localPlayer, "admin" ))) then 
            -- Open gui 
            element = clickedElement 
            local guiX,guiY = guiGetScreenSize() 
            if isElement( GUIEditor.window[2] ) then 
                destroyElement( GUIEditor.window[2] ) 
            end 
            GUIEditor.window[2] = guiCreateWindow((guiX-200)/2, (guiY-300)/2, 200, 300, "Vehicle", false) 
            GUIEditor.button[3] = guiCreateButton(10, 30, 180, 40, "Repair", false, GUIEditor.window[2]) 
            GUIEditor.button[4] = guiCreateButton(10, 80, 180, 40, "Refuel", false, GUIEditor.window[2]) 
            GUIEditor.button[5] = guiCreateButton(10, 240, 180, 40, "Close", false, GUIEditor.window[2]) 
            if getElementData( localPlayer, "admin" ) and not ( getPlayerTeam( localPlayer ) == getTeamFromName( "Civilians" )) then 
                guiSetText( GUIEditor.button[3], "Destroy" ) 
                guiSetText( GUIEditor.button[4], "Information" ) 
            end 
            showCursor ( true ) 
            guiSetVisible( GUIEditor.window[2], true ) 
            addEventHandler("onClientGUIClick", GUIEditor.button[3], button1 ) 
            addEventHandler("onClientGUIClick", GUIEditor.button[4], button2 ) 
            addEventHandler("onClientGUIClick", GUIEditor.button[5], buttonClose ) 
            cooldown = setTimer( function() end, 1000, 1 ) 
        end 
    end 
end 
addEventHandler ( "onClientClick", getRootElement(), openVehicleGui ) 
  
function button1( ) 
    if isElement( element ) then 
        if getPlayerTeam( localPlayer ) == getTeamFromName( "Civilians" ) then           
            destroyElement( GUIEditor.window[2] ) 
            showCursor( false ) 
             
            -- Create progress 
            if getElementData( element, "owner" ) then 
                repairTime = (1000-getElementHealth( element ))*60 
                if repairTime > 100 then 
                    pb = guiCreateProgressBar( 0.4, 0.9, 0.2, 0.05, true ) 
                    setTimer( function() 
                        local progress = guiProgressBarGetProgress( pb ) 
                        if progress < 99 then 
                            guiProgressBarSetProgress( pb, progress+1 ) 
                        else 
                            destroyElement( pb ) 
                        end 
                    end, math.floor(repairTime/100), 100 ) 
                end 
                triggerServerEvent( "fix", getRootElement(), element ) 
            else 
                topBarMessage( "This vehicle has no owner", 255, 255, 0 ) 
            end 
        elseif getElementData( localPlayer, "admin" ) then 
            showCursor( false ) 
            destroyElement( GUIEditor.window[2] ) 
            exports["AC_message"]:outputTopBar( "Vehicle was sucsessfully removed!", 0, 255, 0 ) 
            triggerServerEvent( "destroy", getRootElement(), element ) 
        end 
    end 
end 
function button2( ) 
    if isElement( element ) then 
        if getPlayerTeam( localPlayer ) == getTeamFromName( "Civilians" ) and not isTimer( cooldown ) then           
            showCursor( false ) 
            destroyElement( GUIEditor.window[2] ) 
            local fuel = getElementData( element, "vehicleFuel" ) 
            if tonumber( getElementData( element, "vehicleFuel" )) < 91 then 
                setElementData( element, "vehicleFuel", fuel+10 ) 
                exports["AC_message"]:outputTopBar( "Vehicle sucsessfully refueld (10 hits of fuel)", 0, 255, 0 ) 
            else 
                setElementData( element, "vehicleFuel", 100 ) 
                exports["AC_message"]:outputTopBar( "This vehicle already have enough fuel", 255, 0, 0 ) 
            end 
            cooldown = setTimer( function() end, 10000, 1 ) 
        elseif getElementData( localPlayer, "admin" ) then 
            showCursor( false ) 
            destroyElement( GUIEditor.window[2] ) 
            local owner = getElementData( element, "owner" ) 
            if owner then 
                outputChatBox( "INFO: owner="..owner, 255, 255, 255 ) 
            end 
        end 
    end 
end 
function buttonClose( ) 
    showCursor ( false ) 
    destroyElement( GUIEditor.window[2] ) 
end 
  
function topBarMessage( message, r, g, b ) 
    exports["AC_message"]:outputTopBar( message, r, g, b ) 
end 
addEvent( "onTopMessage", true ) 
addEventHandler( "onTopMessage", getRootElement(), topBarMessage ) 
  
  
  
  

----server side-----

local team = getTeamFromName ( "Civilians" ) 
  
  
      function teamSet( ) 
     
       setElementData( client, "Occupation", "Mechanic" ) 
     
      local team = getTeamFromName ( "Civilians" ) 
    
      if team then 
        setPlayerTeam ( client, team ) 
         
         setPlayerNametagColor ( client, 255, 200, 0 ) 
         
     local skinID = 50 
         
     setElementModel( client, skinID ) 
        
     createBlipAttachedTo( client, 0, 2, 255, 200, 0, 255, 1 ) 
      
     exports["AC_message"]:outputTopBar( "You are now emplyed as mechanic!", client, 0, 255, 0 ) 
       
     setElementData( client, "admin", false ) 
    
      else 
        
     exports["AC_message"]:outputTopBar( "You are already emplyed as mechanic!", client, 255, 0, 0 ) 
   
    end 
  
 end 
  
addEvent( "mechanic", true) 
  
 addEventHandler( "mechanic", root, teamSet ) 
  
  
   function repair( veh ) 
     
     if isElement( veh ) then 
         
          local repairTime = (1000-getElementHealth( veh ))*60 
         
    if repairTime > 100 then 
            local playerName = getElementData( veh, "owner" ) 
            if playerName then 
                local owner = getPlayerFromName( playerName ) 
                outPutTopbarMessage( "Reparing vehicle...", client, 0, 255, 0 ) 
                setPedAnimation( client, "GRAFFITI", "spraycan_fire", -1, true ) 
                setTimer( fixVehicle, math.floor(repairTime), 1, veh ) 
                setElementFrozen( veh, true ) 
                setElementFrozen( client, true ) 
                setTimer( showCursor, math.floor(repairTime), 1, client, false ) 
                setTimer( setElementFrozen, math.floor(repairTime), 1, veh, false ) 
                setTimer( setElementFrozen, math.floor(repairTime), 1, client, false ) 
                setTimer( outPutTopbarMessage, math.floor(repairTime), 1, "Vehicle was sucsessfully repaired!", client, 0, 255, 0 ) 
                setTimer( payRepair, math.floor(repairTime), 1, client, veh, repairTime ) 
                setTimer( setPedAnimation, math.floor(repairTime), 1, client, nil, nil ) 
            end 
        else 
            outPutTopbarMessage( "Vehicle is already in good condition", client, 0, 255, 0 ) 
        end 
    else 
        outPutTopbarMessage( "No vehicle found", client, 255, 0, 0 ) 
    end 
     
end 
addEvent ( "fix", true) 
addEventHandler ( "fix", root, repair ) 
  
function payRepair( mech, veh, owner, time ) 
    if isElement( owner ) then 
        givePlayerMoney( mech, (time/100 )) 
        takePlayerMoney( owner, ((time/100)/2 )) 
    end 
end 
  
function adminClean( veh ) 
    if isElement( veh ) then 
        destroyElement( veh ) 
    end 
end 
addEvent( "destroy", true) 
addEventHandler ( "destroy", root, adminClean ) 
  
function outPutTopbarMessage( message, thePlayer, r, g, b ) 
    exports["AC_message"]:outputTopBar( message, thePlayer, r, g, b ) 
end 
  
  

need police job please not convert in luac like that if you want to give :o

thanks for reply

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