ElecrtiFy Posted July 23, 2019 Share Posted July 23, 2019 Hi Everyone! I want to make a movable spoiler script. I have wrote the client and server side script, but when I tried it out the spoiler was moved, but only on my display. Can somebody help me? How can I move vehicle components on every players display? Link to comment
HassoN Posted July 23, 2019 Share Posted July 23, 2019 Hey, Send a trigger from server side to client side and it will move for everyone. Link to comment
ElecrtiFy Posted July 23, 2019 Author Share Posted July 23, 2019 (edited) -- Client Side x=0 function igen(veh, ID) local TheVeh = veh if getPedOccupiedVehicleSeat(localPlayer)==0 then if ID==(598) then local a, b, c = getVehicleComponentPosition(TheVeh, "movspoiler3_-2_4600") -- movspoiler3_13_2000 if c<=0.34355602955818 then setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler3_-2_4600", a, b, c) c=c+1.00055 end, 50, 20) end if c>=0.35155602002144 then --0.34255602955818 0.35255602002144 setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler3_-2_4600", a, b, c) c=c-1.00055 end, 50, 20) end end if ID==(541) then local a, b, c = getVehicleComponentPosition(TheVeh, "movspoiler") --outputChatBox(b) if b>=-1.8285953092575 then setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler", a, b, c) b=b-0.005 c=c+0.0088 end, 50, 25) end if b<=-1.7677409887314 then setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler", a, b, c) b=b+0.005 c=c-0.0088 end, 50, 25) end end if ID==(503) then local a, b, c = getVehicleComponentPosition(TheVeh, "movspoiler_16.0_2000") if c<=0.86206574201584 then setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler_16.0_2000", a, b, c) --b= b - 0.0064 c=c+0.008 b=b-0.0064 end, 50, 25) end if c>=1.0320657300949 then setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler_16.0_2000", a, b, c) --b=b+0.0064 c=c-0.008 b=b+0.0064 end, 50, 25) end end if ID==(602) then local a, b, c = getVehicleComponentPosition(TheVeh, "movspoiler") local e, f, g = getVehicleComponentPosition(TheVeh, "movspoiler2") local j, k, l = getVehicleComponentRotation(TheVeh, "movspoiler2") --outputChatBox(g) if c<=1.0975383878754 then --movspoiler -9.4771385192871e-06 -1.4522950649261 1.0975383877754 setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler", a, b, c) setVehicleComponentPosition(TheVeh, "movspoiler2", e, f, g) setVehicleComponentRotation(TheVeh, "movspoiler2", j, k, l) j=j-1 c=c+0.0045 b=b-0.0055 -- -2.1935946941376 g=g-0.0085 f=f+0.007 end, 50, 30) end if c>=1.0975383877754 then setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler", a, b, c) setVehicleComponentPosition(TheVeh, "movspoiler2", e, f, g) setVehicleComponentRotation(TheVeh, "movspoiler2", j, k, l) j=j+1 c=c-0.0045 b=b+0.0055 -- -2.1935946941376 g=g+0.0085 f=f-0.007 end, 50, 30) end end if ID==(587) then local a, b, c = getVehicleComponentPosition(TheVeh, "movspoiler") --outputChatBox(c) if c<=0.46466327667236 then --0.52247399687767 setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler", a, b, c) c=c+0.003 end, 70, 20) end if c>=0.46766328859329 then setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler", a, b, c) c=c-0.003 end, 70, 20) end end if ID==(543) then local a, b, c = getVehicleComponentPosition(TheVeh, "movspoiler_20.0_1000") if c<=0.24353285551071 then setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler_20.0_1000", a, b, c) c=c+0.0035 end, 70, 20) end if c>=0.27353284835815 then setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler_20.0_1000", a, b, c) c=c-0.0035 end, 70, 20) end end if ID==(411) then local a, b, c = getVehicleComponentPosition(TheVeh, "movspoiler") -- movspoiler3_13_2000 local d, e, f = getVehicleComponentRotation(TheVeh, "movspoiler") local g1, h1 ,i1 = getVehicleComponentPosition(TheVeh, "movspoiler3_6_2500") local g2, h2 ,i2 = getVehicleComponentPosition(TheVeh, "movspoiler2_-6_2500") --outputChatBox(c) if c<=0.4131715297799 then --movspoiler3_6_2500 movspoiler2_-6_2500 setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler", a, b, c) setVehicleComponentRotation(TheVeh, "movspoiler", d, e, f) setVehicleComponentPosition(TheVeh, "movspoiler3_6_2500", g1, h1, i1) setVehicleComponentPosition(TheVeh, "movspoiler2_-6_2500", g2, h2, i2) g1=g1+0.001 g2=g2-0.001 c=c+0.0011 d=d-0.70 end, 50, 20) end if c>=0.42407154083252 then --0.34255602955818 0.35255602002144 setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler", a, b, c) setVehicleComponentRotation(TheVeh, "movspoiler", d, e, f) setVehicleComponentPosition(TheVeh, "movspoiler3_6_2500", g1, h1, i1) setVehicleComponentPosition(TheVeh, "movspoiler2_-6_2500", g2, h2, i2) g1=g1-0.001 g2=g2+0.001 c=c-0.0011 d=d+0.70 end, 50, 20) end end if ID==(480) then --0.025263121724129 0.063263120502234 local a, b, c = getVehicleComponentPosition(TheVeh, "movspoiler_1.7_2500") -- movspoiler3_13_2000 -0.0747368782758711 if c<=-0.0727368782758711 then outputChatBox(c.."1") setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler_1.7_2500", a, b, c) c=c+0.002 end, 50, 20) end if c>=-0.039736879497766 then -- -0.036736879497766 setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler_1.7_2500", a, b, c) c=c-0.002 end, 50, 20) end --movspoiler_15.0_4000 end if ID==(518) then local a, b, c = getVehicleComponentPosition(TheVeh, "movspoiler_15.0_4000") local d, e, f = getVehicleComponentRotation(TheVeh, "movspoiler_15.0_4000") --outputChatBox(c) if c<=0.36347752809528 then setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler_15.0_4000", a, b, c) setVehicleComponentRotation(TheVeh, "movspoiler_15.0_4000", d, e, f) c=c+0.0023 b=b-0.001 d=d-0.2 end, 70, 20) end if c>=0.40717753767947 then --0.50717753767967 movspoiler setTimer(function() setVehicleComponentPosition(TheVeh, "movspoiler_15.0_4000", a, b, c) setVehicleComponentRotation(TheVeh, "movspoiler_15.0_4000", d, e, f) c=c-0.0023 b=b+0.001 d=d+0.2 end, 70, 20) end end if ID==(502) then local a, b, c = getVehicleComponentPosition(TheVeh, "movspoiler_15.0_1000") local a1, b1, c1 = getVehicleComponentRotation(TheVeh, "movspoiler_15.0_1000") if c<=0.45475019311905 then -- -1.7881393432617e-07 -1.8604836463928 0.45375019311905 and -1.7881393432617e-07 -1.9004836082458 0.46375018358231 setTimer(function() --outputChatBox("1") setVehicleComponentPosition(TheVeh, "movspoiler_15.0_1000", a, b, c) setVehicleComponentRotation(TheVeh, "movspoiler_15.0_1000", a1, b1, c1) b=b-0.002 c=c+0.0001 a1=a1-0.5 end, 70, 20) end if c>=0.45565016057823 then --0.45565018057823 setTimer(function() --outputChatBox("2") setVehicleComponentPosition(TheVeh, "movspoiler_15.0_1000", a, b, c) setVehicleComponentRotation(TheVeh, "movspoiler_15.0_1000", a1, b1, c1) b=b+0.002 c=c-0.0001 a1=a1+0.5 end, 70, 20) end end end end addEvent("igen", true) addEventHandler("igen", resourceRoot, igen) function serverside(veh, ID) if isTimer(timer2) then outputChatBox("#717171[#FFFFFFSpoiler#717171]#FFFFFFVárj 2 másodpercet#FF0000!", 62, 255, 0, true) else timer2 = setTimer(function() end, 2000, 1) local veh = getPedOccupiedVehicle(localPlayer) local ID = getElementModel(veh) triggerServerEvent("spoiler", resourceRoot, veh, ID) end end function automata() if isTimer(timer) then outputChatBox("#717171[#FFFFFFSpoiler#717171]#FFFFFFAnyádat nyomkáld#FF0000!", 62, 255, 0, true) else if x==0 then timer = setTimer(function() end, 4000, 1) outputChatBox("#717171[#FFFFFFSpoiler#717171]#FFFFFFAutomata spoiler: #3EFF00Be", 62, 255, 0, true) bindKey("p","down",serverside) x=1 return end if x==1 then timer = setTimer(function() end, 4000, 1) outputChatBox("#717171[#FFFFFFSpoiler#717171]#FFFFFFAutomata spoiler: #FF0000Ki", 62, 255, 0, true) unbindKey("p","down",serverside) x=0 return end end end bindKey("mouse4", "down", automata) --Server Side function spoiler(veh, ID) outputChatBox(ID) triggerClientEvent("igen", resourceRoot, veh, ID) end addEvent("spoiler", true) addEventHandler("spoiler", resourceRoot, spoiler) I have done it already. It did not work. Can you fix it? Or should it work? Edited July 23, 2019 by DNL291 Lua formatting for the code Link to comment
HassoN Posted July 23, 2019 Share Posted July 23, 2019 What's the issue? Nobody can see it? another error? Please use /debugscript 3 Link to comment
ElecrtiFy Posted July 23, 2019 Author Share Posted July 23, 2019 I have used, the problem is, the spoiler moved only on my display, on another players display no. So yes, the spoiler moved only for me Link to comment
JustinMTA Posted July 23, 2019 Share Posted July 23, 2019 (edited) Try changing: local TheVeh = veh if getPedOccupiedVehicleSeat(localPlayer)==0 then local veh = getPedOccupiedVehicle(localPlayer) To: theVeh = getPedOccupiedVehicle ( thePlayer ) if getPedOccupiedVehicleSeat(thePlayer)==0 then veh = getPedOccupiedVehicle ( thePlayer ) If it doesn't work start removing "Local" from the beginning of script lines also Edited July 24, 2019 by JustinMTA 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