Jump to content

[HELP HELP HELP] Scripting


iFerasMO

Recommended Posts

Posted
i want the script works with key ( Like K or num_5 ) + car and does not appear ..

but if the player side the car and pressed the button script works

And if there are no nearby car does not work ..

Posted

Try using this (Not Tested)

client.lua

bindKey("k","down","lk") 

server.lua

    function ChopperGunner ( plr ) 
    local accName = getAccountName ( getPlayerAccount ( plr ) )  
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Everyone" ) ) then  
            blip = {} 
            local x, y, z = getElementPosition( plr ) 
            local Heli = createVehicle( 405, x+2, y+3, z+2 ) 
        blip[1] = ( createBlipAttachedTo ( Heli, 41 ) ) 
        setVehicleDamageProof ( Heli, true ) 
         
                                    local time1 = setTimer( 
             function() 
                                   xx = createPed ( 107, x, y, z )  
                                   setPedAnimation ( xx, "ped", "SEAT_idle", -1, true, false, false ) 
                                   attachElements( xx, Heli, -0.2, -2.2, 1 ) 
                                   attachElements( plr, Heli, -0.4, -1.8, 0.8 ) 
        setElementAlpha( plr, 0, true)  
                                   giveWeapon( plr, 38, 9999, true ) 
            end, 3000, 1) 
  
        local time2 = setTimer( 
             function() 
                                   giveWeapon( plr, 38, 9999, true ) 
            end, 3000, 1)   
  
        local time3 = setTimer( 
             function() 
        setElementPosition ( plr, x, y, z ) 
        takeWeapon ( plr, 38 ) 
        setElementAlpha( plr, 255 )  
        destroyElement( Pilot ) 
        destroyElement( xx ) 
        destroyElement( blip[1] ) 
                                   destroyElement( Heli ) 
            end, 30000, 1)  
    end 
end 
addCommandHandler("lk", ChopperGunner) 

Posted
  
-- Client 
bindKey("k", "down", function() 
     triggerServerEvent("call:test", resourceRoot) 
end) 
  

  
-- Server 
  
function ChopperGunner ( plr ) 
    local accName = getAccountName ( getPlayerAccount ( plr ) ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Everyone" ) ) then 
            blip = {} 
            local x, y, z = getElementPosition( plr ) 
            local Heli = createVehicle( 405, x+2, y+3, z+2 ) 
        blip[1] = ( createBlipAttachedTo ( Heli, 41 ) ) 
        setVehicleDamageProof ( Heli, true ) 
        
                                    local time1 = setTimer( 
             function() 
                                   xx = createPed ( 107, x, y, z ) 
                                   setPedAnimation ( xx, "ped", "SEAT_idle", -1, true, false, false ) 
                                   attachElements( xx, Heli, -0.2, -2.2, 1 ) 
                                   attachElements( plr, Heli, -0.4, -1.8, 0.8 ) 
        setElementAlpha( plr, 0, true) 
                                   giveWeapon( plr, 38, 9999, true ) 
            end, 3000, 1) 
  
        local time2 = setTimer( 
             function() 
                                   giveWeapon( plr, 38, 9999, true ) 
            end, 3000, 1)   
  
        local time3 = setTimer( 
             function() 
        setElementPosition ( plr, x, y, z ) 
        takeWeapon ( plr, 38 ) 
        setElementAlpha( plr, 255 ) 
        destroyElement( Pilot ) 
        destroyElement( xx ) 
        destroyElement( blip[1] ) 
                                   destroyElement( Heli ) 
            end, 30000, 1) 
    end 
end 
  
addEvent("call:test", true) 
addEventHandler("call:test", resourceRoot, function() 
     ChopperGunner(client) 
end) 
  

Posted

Heli is not defined client-side. You need to pass it to the Client via triggerClientEvent.

-- Server 
triggerClientEvent(plr, "llk" plr, Heli) 
  
-- Client 
function lkk(theHeli) 
attachElements(so, theHeli) 

Read the Wiki thoroughly and you'll be able to figure things like these out on your own :)

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