dsmatias Posted October 6, 2016 Posted October 6, 2016 (edited) --- Error's - F8 Help? Edited October 6, 2016 by dsmatias
pa3ck Posted October 6, 2016 Posted October 6, 2016 We would have already helped you if you could take your time and *READ BEFORE POSTING*
Tekken Posted October 7, 2016 Posted October 7, 2016 As far as I can see your script is full of errors and warnings so you pretty much have to re-write it.
..:D&G:.. Posted October 7, 2016 Posted October 7, 2016 (edited) For the "getElementData" error you can do a simple check like this: if isElement(theElement) then getElementData(theElement, "theData") end for like 87 in client.lua but for the red errors... we need to see the code especially the line 39 from the steering_c.lua... Edited October 7, 2016 by ..:D&G:..
Gravestone Posted October 7, 2016 Posted October 7, 2016 After seeing the first photo I can see that your file 'backfire.wav' isn't defined in meta.xml of the resource.
dsmatias Posted October 13, 2016 Author Posted October 13, 2016 (edited) <meta> <info name="backfire" author="EquipeDS_Matias" version="1.0" type="script" /> <script src="backfire_server.lua" type="server"/> <script src="backfire_client.lua" type="client"/> <file src="sound/backfire1.wav" /> <file src="backfire_settings.xml" /> </meta> local fxShowValTest = false local curEngine = 0 function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] 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 end function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end function getVectors(x, y, z, x2, y2, z2) return x - x2, y - y2, z-z2; end function createBackFire(theVeh, scx, scy, scz) local fireChords={} local dist = 0.04 for i = 1, 6 do local x, y, z = getPositionFromElementOffset(theVeh,scx,scy-dist,scz) fireChords[i]= {pX = x, pY = y, pZ = z} dist = dist + 0.2 end local x,y,z = getPositionFromElementOffset(theVeh,scx,scy,scz) local x2,y2,z2 = getPositionFromElementOffset(theVeh,scx,0,scz) local v1, v2, v3 = getVectors(x,y,z, x2,y2,z2) for i, val in ipairs(fireChords) do fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2,v3, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1+1.5,v2,v3, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1-1.5,v2,v3, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2,v3-0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2+1,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2+2,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2+10,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2-10,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2-2,v3+0.8, true) fxAddGunshot(val.pX,val.pY,val.pZ, v1,v2-1,v3+0.8, true) end local s = playSound3D("sound/backfire1.wav", x,y,z, false) setSoundMaxDistance( s, 80 ) setSoundVolume(s, 0.5) end function chandeMonitoringState(state,veh) if (state) then theVehicle = veh addEventHandler ( "onClientPreRender", root, monitorCurEngine ) else removeEventHandler ( "onClientPreRender", root, monitorCurEngine ) theVehicle=nil theTestVehicle=nil end end addEvent ( "chandeMonitoringState", true ) addEventHandler ( "chandeMonitoringState", getRootElement(), chandeMonitoringState) --[[ addEventHandler("onClientPlayerVehicleExit",getRootElement(), function(theVeh, seat) if ( seat==0 ) then theVehicle = nil theTestVehicle=nil removeEventHandler ( "onClientPreRender", root, monitorCurEngine ) end end ) ]] addCommandHandler("devm", function(cmd, val) if tonumber(val) == 0 then removeEventHandler ( "onClientPreRender", root, testMode ) removeEventHandler("onClientKey", root, playerPressedKey) else theTestVehicle = getPedOccupiedVehicle ( localPlayer ) if theTestVehicle then tpx, tpy, tpz = 0, 0, 1 if fxShowValTest then --fxShowValTest = false --removeEventHandler ( "onClientPreRender", root, testMode ) else fxShowValTest = true addEventHandler ( "onClientPreRender", root, testMode ) addEventHandler("onClientKey", root, playerPressedKey) end else outputChatBox("get in vehicle!!!", 255,0,0) end end end) local step = 0.2 function playerPressedKey(button, press) if button == "arrow_u" or button == "arrow_d" or button == "arrow_r" or button == "arrow_l" then local curstep = step if (press) then if getKeyState( "lalt" ) == true or getKeyState( "ralt" ) == true then curstep=step/2 end if button == "arrow_u" then if getKeyState( "lctrl" ) == true or getKeyState( "rctrl" ) == true then tpy = tpy+curstep else tpz = tpz+curstep end elseif button == "arrow_d" then if getKeyState( "lctrl" ) == true or getKeyState( "rctrl" ) == true then tpy = tpy-curstep else tpz = tpz-curstep end elseif button == "arrow_l" then tpx = tpx-curstep elseif button == "arrow_r" then tpx = tpx+curstep end outputChatBox("x= "..tostring(tpx).." y= "..tostring(tpy).." z= "..tostring(tpz), 255,255,0) end end end function testMode() local x, y, z = getPositionFromElementOffset(theTestVehicle,tpx, tpy, tpz) local x2, y2, z2 = getPositionFromElementOffset(theTestVehicle,tpx, 0, tpz) local v1, v2, v3 = getVectors(x, y, z, x2, y2, z2) fxAddGunshot(x, y, z, v1,v2,v3, true) end local refreshTime = 50 --ms local aLastCheck = 0 function monitorCurEngine() if ( getTickCount() >= aLastCheck ) then local cur = tonumber(getVehicleCurrentGear (theVehicle)) if ( cur ~= curEngine ) then if (tonumber(getElementSpeed(theVehicle, "kph")) > 5 ) then triggerServerEvent ( "create3DBackfireSound", root, theVehicle) curEngine = cur end end aLastCheck = getTickCount() + refreshTime end end addEvent ( "create3DBackfireSoundClient", true ) addEventHandler ( "create3DBackfireSoundClient", getRootElement(), createBackFire) local CarsSettings = {} function setElementSpeed(element, unit, speed) if (unit == nil) then unit = 0 end if (speed == nil) then speed = 0 end speed = tonumber(speed) local acSpeed = getElementSpeed(element, unit) if (acSpeed~=false) then local diff = speed/acSpeed local x,y,z = getElementVelocity(element) setElementVelocity(element,x*diff,y*diff,z*diff) return true end return false end function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end addEventHandler ( "onResourceStart", resourceRoot, function ( ) local StationsFile = xmlLoadFile ( "backfire_settings.xml" ) if ( StationsFile ) then outputDebugString ( "backfire_settings.xml successfully open") for _, data in ipairs ( xmlNodeGetChildren ( StationsFile ) ) do local attrs = xmlNodeGetAttributes ( data ) CarsSettings[tostring(attrs.name)] = { x = tonumber(attrs.x), y = tonumber(attrs.y), z = tonumber(attrs.z) } end else outputDebugString ( "Failed to open to backfire_settings.xml", 1 ) end end ) addEvent ( "create3DBackfireSound", true ) addEventHandler ( "create3DBackfireSound", root, function ( theVehicle) if ( theVehicle ) then local vehicleName = getVehicleName( theVehicle ) if ( type(CarsSettings[vehicleName]) == "table" ) then local x, y, z = tonumber(CarsSettings[vehicleName].x), tonumber(CarsSettings[vehicleName].y), tonumber(CarsSettings[vehicleName].z); triggerClientEvent(root, "create3DBackfireSoundClient", root, theVehicle, x, y, z) end end end ) function startMonitoring ( thePlayer, seat, jacked ) if (seat == 0) then triggerClientEvent(thePlayer, "chandeMonitoringState", thePlayer, true, source) end end addEventHandler ( "onVehicleEnter", getRootElement(), startMonitoring ) function stopMonitoring ( thePlayer, seat, jacked ) if (seat == 0) then triggerClientEvent(thePlayer, "chandeMonitoringState", thePlayer, false) end end addEventHandler ( "onVehicleExit", getRootElement(), stopMonitoring ) The script ta normal functioning, but errors can cause a server problem? Matter of giving lag etc ...? Edited October 13, 2016 by dsmatias
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