Yaverbey Posted October 11, 2016 Share Posted October 11, 2016 (edited) Hello i have problem with createprojectile when i make Rustler bomber and S.W.AT Tank he is blowing up. Sorry for my bad english What is my problem in Script? w, h = guiGetScreenSize () local function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) -- Get the matrix local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] -- Apply transform local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z -- Return the transformed point end local poses = { [531] = {0, 0, 0}, } addEvent("cl_bulletSpawn", true) addEventHandler("cl_bulletSpawn",getRootElement(),function(x, y, z, player) createProjectile(player,19,x,y,z+3) end) function fireBTR() local veh = getPedOccupiedVehicle(localPlayer) if isElement(veh) and getElementModel(veh) == 531 then local xv,yv,zv = getElementVelocity(veh) local mid = getElementModel(veh) local x,y,z = getPositionFromElementOffset(veh, poses[mid][1],poses[mid][2],poses[mid][3]+math.abs(zv*5)) x,y = x+xv*5, y+yv*5 triggerServerEvent("sv_bulletSpawn", getRootElement(), x, y, z, localPlayer) end end bindKey("mouse1","down",fireBTR) function disableFireSwat ( theVehicle, seat ) if ( getElementModel ( theVehicle ) == 531 ) then toggleControl ( "vehicle_fire", false ) else toggleControl ( "vehicle_fire", true ) end end addEventHandler ( "onClientPlayerVehicleEnter", getLocalPlayer(), disableFireSwat ) function disableFireSwat1 ( theVehicle, seat ) if ( getElementModel ( theVehicle ) == 531 ) then toggleControl ( "lctrl_fire", false ) else toggleControl ( "lctrl_fire", true ) end end addEventHandler ( "onClientPlayerVehicleEnter", getLocalPlayer(), disableFireSwat1 ) function renderVehCross () local veh = getPedOccupiedVehicle(localPlayer) if isElement(veh) and getElementModel(veh) == 531 then dxDrawImage (w/2-32, h/2-90,64,64,"shotgun.png",0,0,0) end end addEventHandler('onClientRender', root, renderVehCross ) Server addEvent("sv_bulletSpawn", true) addEventHandler("sv_bulletSpawn",getRootElement(),function(x, y, z, player) triggerClientEvent("cl_bulletSpawn", getRootElement(), x, y, z, player) end) function crb(source) local x,y,z = getElementPosition(source) veh = createVehicle(601,x,y,z) vehCol = createColSphere(x,y,z,2) attachElements ( vehCol, veh, 0, 0, 0 ) setElementData(vehCol,"parent",veh) setElementData(veh,"parent",vehCol) setElementData(vehCol,"vehicle",true) setElementData(vehCol,"MAX_Slots",50) --Engine + Tires setElementData(vehCol,"Tire_inVehicle",6) setElementData(vehCol,"Engine_inVehicle",1) setElementData(vehCol,"Parts_inVehicle",1) for i=1,1 do setElementData(vehCol,"engineHealth_"..i,1000) end for i=1,1 do setElementData(vehCol,"partHealth_"..i,1000) end for i=1,6 do setElementData(vehCol,"tireHealth_"..i,1000) end setElementData(vehCol,"fuel",200) end addCommandHandler("btr",crb) how to fix it? Edited October 11, 2016 by Yaverbey Link to comment
Yaverbey Posted October 11, 2016 Author Share Posted October 11, 2016 Anyone can help? Link to comment
Adolfram Posted October 11, 2016 Share Posted October 11, 2016 have you tried to set z position lower? it might help avoid the cause of explosion Link to comment
Yaverbey Posted October 11, 2016 Author Share Posted October 11, 2016 i tried it but dont work when i start that script my car blowing up self How do fix it? Anyone can help? Link to comment
Gravestone Posted October 12, 2016 Share Posted October 12, 2016 6 hours ago, Yaverbey said: when i start that script my car blowing up self Does the projectile fall on the vehicle? 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now