Jump to content

help


WASSIm.

Recommended Posts

hi all

i have problem in rotation (minigun1)

i want rotation like target projectile on vehicle

addEventHandler("onClientResourceStart", root, 
    function( ) 
       for k, v in ipairs(getElementsByType ("vehicle")) do 
        if getElementModel(v) == 600 then 
        minigun1= createObject ( 3267,getElementPosition (v)) 
        attachElements (minigun1, v,  0, -1.7, -0.4) 
        end 
      end 
    end 
) 
  
function move ( ) 
theVehicle = getPedOccupiedVehicle ( localPlayer )  
    if (theVehicle) then 
        if (getElementModel(theVehicle) == 600) and (minigun1) then 
             bindKey ( "vehicle_fire", "down", shot )   
             local xt, yt, zt, rxt, ryt, rzt  = getCameraMatrix(localPlayer) 
             attachElements (minigun1, theVehicle,  0, -1.7, -0.4, 0, 0, zt ) 
         else 
             unbindKey ( "vehicle_fire", "down", shot )   
         end 
    end 
end 
addEventHandler ( "onClientRender", root, move) 
     
function shot( ) 
theVehicle = getPedOccupiedVehicle ( localPlayer )  
    if (theVehicle) then 
        if getElementModel(theVehicle) == 600 and minigun1 then 
            local x, y, z = getElementPosition ( minigun1 ) 
            local rx,ry,rz = getElementRotation ( minigun1 ) 
            theProjectile = createProjectile(theVehicle,20,x,y,z+10,1,vehicle) 
            end 
        end 
    end 

Edited by Guest
Link to comment

Try this:

minigun = { } 
addEventHandler("onClientResourceStart", root, 
    function( ) 
        for k, v in ipairs(getElementsByType ("vehicle")) do 
            if getElementModel(v) == 600 then 
                minigun [ v ] = createObject ( 3267,getElementPosition (v)) 
                attachElements (minigun [ v ], v,  0, -1.7, -0.4) 
            end 
        end 
    end 
) 
  
function move ( ) 
    theVehicle = getPedOccupiedVehicle ( localPlayer ) 
    if (theVehicle) then 
        if (getElementModel(theVehicle) == 600) and (minigun [ v ] ) then 
             bindKey ( "vehicle_fire", "down", shot )   
             local xt, yt, zt, rxt, ryt, rzt  = getCameraMatrix(localPlayer) 
             attachElements (minigun [ v ] , theVehicle,  0, -1.7, -0.4, 0, 0, zt ) 
         else 
             unbindKey ( "vehicle_fire", "down", shot )   
         end 
    end 
end 
addEventHandler ( "onClientRender", root, move) 
   
theProjectile = { } 
function shot( ) 
    theVehicle = getPedOccupiedVehicle ( localPlayer ) 
    if (theVehicle) then 
        if getElementModel(theVehicle) == 600 and minigun [ v ]  then 
            local x, y, z = getElementPosition ( minigun [ v ]  ) 
            local rx,ry,rz = getElementRotation ( minigun [ v ]  ) 
            theProjectile[localPlayer] = createProjectile(theVehicle,20,x,y,z+10,1,vehicle) 
        end 
    end 
end 

( IF any errors, post them )

Link to comment
  • Moderators
function move ( ) 
theVehicle = getPedOccupiedVehicle ( localPlayer ) 
    if (theVehicle) then 
        if (getElementModel(theVehicle) == 600) and (minigun1) then 
             bindKey ( "vehicle_fire", "down", shot )   
             local xt, yt, zt, rxt, ryt, rzt  = getCameraMatrix(localPlayer) 
             attachElements (minigun1, theVehicle,  0, -1.7, -0.4, 0, 0, zt ) 
         else 
             unbindKey ( "vehicle_fire", "down", shot )   
         end 
    end 
end 
addEventHandler ( "onClientRender", root, move) 

how many times do you want to bind/unbind a key?

Link to comment
function move ( ) 
theVehicle = getPedOccupiedVehicle ( localPlayer ) 
    if (theVehicle) then 
        if (getElementModel(theVehicle) == 600) and (minigun1) then 
             bindKey ( "vehicle_fire", "down", shot )   
             local xt, yt, zt, rxt, ryt, rzt  = getCameraMatrix(localPlayer) 
             attachElements (minigun1, theVehicle,  0, -1.7, -0.4, 0, 0, zt ) 
         else 
             unbindKey ( "vehicle_fire", "down", shot )   
         end 
    end 
end 
addEventHandler ( "onClientRender", root, move) 

how many times do you want to bind/unbind a key?

nothing :(

Link to comment

Projectile not working

rocket = { } 
col = { } 
theProjectile = { } 
function move ( ) 
        for k, v in ipairs(getElementsByType ("vehicle")) do 
            if getElementModel(v) == 600 then 
                if not rocket [ v ] then 
                local x, y, z = getElementPosition (v) 
                rocket [ v ] = createObject ( 3267, x, y, z) 
                col [ v ] =  createColSphere ( x, y, z, 50) 
                attachElements (rocket[ v ], v,  0, -1.7, -0.4) 
                attachElements (col [ v ], rocket [ v ],  0, 0, 0) 
                end 
            end 
        end 
  
  for k, v in ipairs(getElementsByType ("player")) do 
   local  theVehicle = getPedOccupiedVehicle ( v ) 
    if (theVehicle) then 
        if (getElementModel(theVehicle) == 600) and (rocket) then 
             local xt, yt, zt, rxt, ryt, rzt  = getCameraMatrix(theVehicle) 
                --attachElements (rocket[ v ], theVehicle,  0, -1.7, -0.4, 0, 0, ryt ) 
         end 
    end 
end 
end 
addEventHandler ( "onClientRender", root, move) 
  
function shot(player) 
            if getElementType(player) == "player" then 
                if getPedOccupiedVehicle(player) then 
                     if getVehicleType(getPedOccupiedVehicle(player)) == "Helicopter" or getVehicleType(getPedOccupiedVehicle(player)) == "Plane" then 
                         if isElementWithinColShape(player,col [ v ]) then 
                             local x, y, z = getElementPosition ( rocket [ v ] ) 
                             theProjectile [ v ] = createProjectile(player,x,y,z+10,1) 
                         end 
                     end 
                end 
            end 
         end 
  
  
function onHit(hitElement) 
    if hitElement and getElementType(hitElement) == "player" then 
        if isTimer(shootTimer) then 
            killTimer(shootTimer) 
        end 
        shootTimer = setTimer(shoot,2500,0,hitElement) 
    end 
end 
addEventHandler("onColShapeHit",getRootElement(),onHit) 
  
function onLeave() 
    if isTimer(shootTimer) then 
        killTimer(shootTimer) 
    end 
end 
setDevelopmentMode ( true ) 
addEventHandler("onColShapeLeave",getRootElement(),onLeave) 

Link to comment
  • Moderators
Projectile not working

Is that everything you can say?

Well why don't you create it your self?

Instead of post other people their code and let us fix it.

You did not even mention the owner of this script, in my opinion this one can be locked.

Link to comment
Projectile not working

Is that everything you can say?

Well why don't you create it your self?

Instead of post other people their code and let us fix it.

You did not even mention the owner of this script, in my opinion this one can be locked.

-_____________-

i create this script and i want fixed it

Link to comment
  • Moderators

of course, that is why Castillo locked one of your previous topics.

  
shootTimer = setTimer(shoot,2500,0,hitElement) 
  

Where is the "shoot" function?

I only see a "shot" function.

Link to comment
  • Moderators
of course, that is why Castillo locked one of your previous topics.
  
shootTimer = setTimer(shoot,2500,0,hitElement) 
  

Where is the "shoot" function?

I only see a "shot" function.

nothing projectile

seriously? :roll:

Learn lua pls and don't steal scripts.

Link to comment

@WASSIm.

You seem to struggle with creating more advanced scripts. Why don't you learn by simply understanding the event system and element tree then some Lua basics and after that you can start creating simple scripts like output message to chat box when someone joins in the server? This is what I suggest you do. You come here with a script more advanced than you can create and ask for fix? The use of createProjectile is simpler than setTimer so the script can't be yours, do you even have privileges to publicly post parts of the code?

Please, understand that we are not going to create/fix the scripts for you especially if they are not yours.

For your information, I'm locking this topic due to stolen script being posted here. If you have a good reason and want me to open it, let me know via private message.

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...