WASSIm. Posted June 8, 2013 Share Posted June 8, 2013 (edited) 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 June 8, 2013 by Guest Link to comment
xXMADEXx Posted June 8, 2013 Share Posted June 8, 2013 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
WASSIm. Posted June 8, 2013 Author Share Posted June 8, 2013 1- Projectile not working 2- Rotation object not moveing Link to comment
manawydan Posted June 8, 2013 Share Posted June 8, 2013 wikicreator: The element representing creator of the projectile. In case you want the projectile to be synced for everybody creator must be getLocalPlayer(). Link to comment
WASSIm. Posted June 8, 2013 Author Share Posted June 8, 2013 wikicreator: The element representing creator of the projectile. In case you want the projectile to be synced for everybody creator must be getLocalPlayer(). nothing Link to comment
iPrestege Posted June 9, 2013 Share Posted June 9, 2013 createObject > getElementPosition ? local x,y,z = getElementPosition ( v ); Link to comment
WASSIm. Posted June 9, 2013 Author Share Posted June 9, 2013 createObject > getElementPosition ? local x,y,z = getElementPosition ( v ); its already working position but my problem projectile and rotation object like camera not working Link to comment
Moderators IIYAMA Posted June 9, 2013 Moderators Share Posted June 9, 2013 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
WASSIm. Posted June 9, 2013 Author Share Posted June 9, 2013 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
Moderators IIYAMA Posted June 9, 2013 Moderators Share Posted June 9, 2013 I did not changed anything, it was more a question. ' ? ' -_-" You are bind/unbind a key every single frame. Link to comment
WASSIm. Posted June 9, 2013 Author Share Posted June 9, 2013 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 IIYAMA Posted June 10, 2013 Moderators Share Posted June 10, 2013 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
WASSIm. Posted June 10, 2013 Author Share Posted June 10, 2013 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 IIYAMA Posted June 10, 2013 Moderators Share Posted June 10, 2013 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
WASSIm. Posted June 10, 2013 Author Share Posted June 10, 2013 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 Link to comment
Moderators IIYAMA Posted June 10, 2013 Moderators Share Posted June 10, 2013 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? Learn lua pls and don't steal scripts. Link to comment
50p Posted June 10, 2013 Share Posted June 10, 2013 @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
Recommended Posts