mr.Extreme Posted February 7, 2014 Share Posted February 7, 2014 (edited) hello i have problem i cant control doors vehicle serverside: function openDoor(door, position) local theVehicle if ( getElementType(source) == "vehicle" ) then theVehicle = source end if ( getElementType(source) == "player" ) then theVehicle = getElementData ( source, "cl_ownedvehicle" ) end if ( theVehicle ) then local theVehicle = getPedOccupiedVehicle(source) if getPedOccupiedVehicleSeat(source) == 0 then if door == 0 then if position==0 then setVehicleDoorOpenRatio(theVehicle, 0, 0, 0.5) end if position==100 then setVehicleDoorOpenRatio(theVehicle, 0, 1, 0.5) end if position>0 and position<100 then setVehicleDoorOpenRatio(theVehicle, 0, position/100, 0.5) end end if door == 1 then if position==0 then setVehicleDoorOpenRatio(theVehicle, 1, 0, 0.5) end if position==100 then setVehicleDoorOpenRatio(theVehicle, 1, 1, 0.5) end if position>0 and position<100 then setVehicleDoorOpenRatio(theVehicle, 1, position/100, 0.5) end end if door == 2 then if position==0 then setVehicleDoorOpenRatio(theVehicle, 2, 0, 0.5) end if position==100 then setVehicleDoorOpenRatio(theVehicle, 2, 1, 0.5) end if position>0 and position<100 then setVehicleDoorOpenRatio(theVehicle, 2, position/100, 0.5) end end if door == 3 then if position==0 then setVehicleDoorOpenRatio(theVehicle, 3, 0, 0.5) end if position==100 then setVehicleDoorOpenRatio(theVehicle, 3, 1, 0.5) end if position>0 and position<100 then setVehicleDoorOpenRatio(theVehicle, 3, position/100, 0.5) end end if door == 4 then if position==0 then setVehicleDoorOpenRatio(theVehicle, 4, 0, 0.5) end if position==100 then setVehicleDoorOpenRatio(theVehicle, 4, 1, 0.5) end if position>0 and position<100 then setVehicleDoorOpenRatio(theVehicle, 4, position/100, 0.5) end end if door == 5 then if position==0 then setVehicleDoorOpenRatio(theVehicle, 5, 0, 0.5) end if position==100 then setVehicleDoorOpenRatio(theVehicle, 5, 1, 0.5) end if position>0 and position<100 then setVehicleDoorOpenRatio(theVehicle, 5, position/100, 0.5) end end end end end addEvent("openDoorOrClose", true) addEventHandler("openDoorOrClose", getRootElement(), openDoor) and thx for helping. Edited February 8, 2014 by Guest Link to comment
tosfera Posted February 7, 2014 Share Posted February 7, 2014 You filled theVehicle at line 3-8. Why are you getting it again at line 10? Link to comment
mr.Extreme Posted February 8, 2014 Author Share Posted February 8, 2014 no work i mean i cant control doors outside vehicles . . please help . Link to comment
Moderators IIYAMA Posted February 8, 2014 Moderators Share Posted February 8, 2014 try this: local allowedDoors = {[0]=true,[1]=true,[2]=true,[3]=true,[4]=true,[5]=true} local openDoor = function (door, position) door,position = tonumber(door), tonumber(position) if isElement(source) and door and position and allowedDoors[door] then if position>=0 and position<=100 then setVehicleDoorOpenRatio(source, door, position/100, 1000) end elseif isElement(client) then outputChatBox("something went wrong",client) end end addEvent("openDoorOrClose", true) addEventHandler("openDoorOrClose", root, openDoor) Link to comment
mr.Extreme Posted February 10, 2014 Author Share Posted February 10, 2014 try this: local allowedDoors = {[0]=true,[1]=true,[2]=true,[3]=true,[4]=true,[5]=true} local openDoor = function (door, position) door,position = tonumber(door), tonumber(position) if isElement(source) and door and position and allowedDoors[door] then if position>=0 and position<=100 then setVehicleDoorOpenRatio(source, door, position/100, 1000) end elseif isElement(client) then outputChatBox("something went wrong",client) end end addEvent("openDoorOrClose", true) addEventHandler("openDoorOrClose", root, openDoor) no Work and no there problem in debugscript 3 Link to comment
Moderators IIYAMA Posted February 10, 2014 Moderators Share Posted February 10, 2014 local allowedDoors = {[0]=true,[1]=true,[2]=true,[3]=true,[4]=true,[5]=true} local openDoor = function (door, position) outputChatBox(tostring(door) .. " " .. tostring(position)) -- debugging........ door,position = tonumber(door), tonumber(position) if isElement(source) and door and position and allowedDoors[door] then if position>=0 and position<=100 then setVehicleDoorOpenRatio(source, door, position/100, 1000) end elseif isElement(client) then outputChatBox("something went wrong",client) end end addEvent("openDoorOrClose", true) addEventHandler("openDoorOrClose", root, openDoor) How did you call it? If this doesn't output anything, then you are calling it wrong, if it does then you know what you are doing wrong with delivering the data. It should look like this: triggerServerEvent ("openDoorOrClose",vehicle,door, position) Also see line 4, that is the best way how you can debug your script. Use the tostring() function to prevent errors during the debugging. Know what kind of data is flowing through your system with: type() function. Strings, booleans, nils, number, tables, userdata's(vehicles/players/peds/objects), functions etc..... variable = true outputChatBox(tostring(variable)) -- true outputChatBox(type(variable))-- boolean (true or false) and pls no sad looking smilies, you can't expect code starts working at ones. Link to comment
mr.Extreme Posted February 10, 2014 Author Share Posted February 10, 2014 no work in debugscript WARNING: vehicle\vehicle.lua46: bad argument @ 'triggerServerEvent' [Ex[ected element at argument 2, got nil] line 46 = triggerServerEvent ("openDoorOrClose",vehicle,door, position) Link to comment
Moderators IIYAMA Posted February 10, 2014 Moderators Share Posted February 10, 2014 it seems the variable vehicle is not defined. How do you get this vehicle in the first place? (the vehicle that you want to change) Link to comment
mr.Extreme Posted February 10, 2014 Author Share Posted February 10, 2014 you can fix it i dont understand you client: setElementData(GUIEditor.scrollbar[1], "Type", 0) setElementData(GUIEditor.scrollbar[2], "Type", 2) setElementData(GUIEditor.scrollbar[3], "Type", 3) setElementData(GUIEditor.scrollbar[4], "Type", 4) setElementData(GUIEditor.scrollbar[5], "Type", 5) setElementData(GUIEditor.scrollbar[6], "Type", 1) function updateRatio(Scrolled) local position = guiScrollBarGetScrollPosition(Scrolled) local door = getElementData(Scrolled, "Type") triggerServerEvent ("openDoorOrClose",vehicle,door, position) end addEventHandler("onClientGUIScroll", getRootElement(), updateRatio) server: local allowedDoors = {[0]=true,[1]=true,[2]=true,[3]=true,[4]=true,[5]=true} local openDoor = function (door, position) outputChatBox(tostring(door) .. " " .. tostring(position)) -- debugging........ door,position = tonumber(door), tonumber(position) if isElement(source) and door and position and allowedDoors[door] then if position>=0 and position<=100 then setVehicleDoorOpenRatio(source, door, position/100, 1000) end elseif isElement(client) then outputChatBox("something went wrong",client) end end addEvent("openDoorOrClose", true) addEventHandler("openDoorOrClose", root, openDoor) Link to comment
Moderators IIYAMA Posted February 10, 2014 Moderators Share Posted February 10, 2014 local updateRatio = function (Scrolled) local position = guiScrollBarGetScrollPosition(Scrolled) local door = getElementData(Scrolled, "Type") local vehicle = getPedOccupiedVehicle ( localPlayer )-- get it's vehicle if vehicle and door and position then -- check if all the data is there. triggerServerEvent ("openDoorOrClose",vehicle,door, position) -- start sending. end end addEventHandler("onClientGUIScroll", root, updateRatio) Link to comment
mr.Extreme Posted February 10, 2014 Author Share Posted February 10, 2014 its working i can control doors in vehicle but i cant control doors if i am not in vehicle Link to comment
mr.Extreme Posted February 10, 2014 Author Share Posted February 10, 2014 please help Link to comment
Moderators IIYAMA Posted February 10, 2014 Moderators Share Posted February 10, 2014 its working i can control doors in vehiclebut i cant control doors if i am not in vehicle and how do you want to do it then? -_-" You can't expect it to change doors from a vehicle that is inside your head. Link to comment
manve1 Posted February 10, 2014 Share Posted February 10, 2014 You can actually control the doors while you're away from the vehicle, simply by using element data (not recommended), or a database like: sql, mysql, xml (recommended). You will need to use a timer or something to check the data then change on the vehicle. Link to comment
mr.Extreme Posted February 10, 2014 Author Share Posted February 10, 2014 i want control vehicle i am not vehicle like remote Photo http://im33.gulfup.com/bj2bg.png Link to comment
manve1 Posted February 10, 2014 Share Posted February 10, 2014 As I said: You can actually control the doors while you're away from the vehicle, simply by using element data (not recommended), or a database like: sql, mysql, xml (recommended). You will need to use a timer or something to check the data then change on the vehicle. If you don't understand, I am sorry, but it is not my problem, I just gave an example how to make it work while not in the vehicle. Link to comment
Moderators IIYAMA Posted February 10, 2014 Moderators Share Posted February 10, 2014 @manve1 or why don't call the lua variables(tables) instead... instead of those memory eaters. Loading every time a xml list of 1000+ players.... Sql and mysql for permanent saving. Tables for temporary. The rest have differed functionary's. XML: Saving settings for scripts serverside, saving cookies clientside. Elementdata: Usefull for sharing score with other players and server. Link to comment
mr.Extreme Posted February 11, 2014 Author Share Posted February 11, 2014 You can actually control the doors while you're away from the vehicle, simply by using element data (not recommended), or a database like: sql, mysql, xml (recommended). You will need to use a timer or something to check the data then change on the vehicle. Now I understand what you mean but how i can use SQL Link to comment
manve1 Posted February 11, 2014 Share Posted February 11, 2014 @manve1 or why don't call the lua variables(tables) instead... instead of those memory eaters. Loading every time a xml list of 1000+ players.... Sql and mysql for permanent saving. Tables for temporary. The rest have differed functionary's. XML: Saving settings for scripts serverside, saving cookies clientside. Elementdata: Usefull for sharing score with other players and server. I've proven a point that it can be made and to prove that it can be made, I gave a descriptive explanation on how it could be used, anything else from that point is what the person thinks is best for him. Link to comment
Moderators IIYAMA Posted February 11, 2014 Moderators Share Posted February 11, 2014 Yes you did, why you need to prove it? Is it a test or something? Any way very good, but don't recommend him to save everything in xml, that is just a very bad habbit. Link to comment
manve1 Posted February 11, 2014 Share Posted February 11, 2014 I know, I didn't have much of time to write it, but anyway, let this topic get back on-topic. Link to comment
mr.Extreme Posted February 12, 2014 Author Share Posted February 12, 2014 I know, I didn't have much of time to write it, but anyway, let this topic get back on-topic. you want i create a new topic? Link to comment
Moderators IIYAMA Posted February 12, 2014 Moderators Share Posted February 12, 2014 As far I know we talked about something that will be important after the remote control. No need to start a new topic when the subject skipped some steps. Just start with the remote control. AFAIK I was the one that was helping you in the first place, when he started talking about saving things permanently. So when you enter a vehicle, you can leave the vehicle and you still want to control it right? Link to comment
mr.Extreme Posted February 12, 2014 Author Share Posted February 12, 2014 As far I know we talked about something that will be important after the remote control.No need to start a new topic when the subject skipped some steps. Just start with the remote control. AFAIK I was the one that was helping you in the first place, when he started talking about saving things permanently. So when you enter a vehicle, you can leave the vehicle and you still want to control it right? yeah 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