DeiwnEdits Posted May 23, 2019 Share Posted May 23, 2019 Hi guys I will ask question. I want if I am select gui combobox, do (client) functions and restart resource. But "restartResource" it is server function. How can I do? Please help me!! --Maybe you need --local wheelsModels = {0, 1025, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1096, 1097} -- --combo1 = guiCreateComboBox(0,0.1,1,0.3,"Wheels",true, tuning.window) --for i,wheel in pairs(wheelsModels) do -- guiComboBoxAddItem(combo1, wheel) --end function setWheels( comboBox ) if ( comboBox == combo1 ) then veh = getPedOccupiedVehicle(localPlayer) if not veh then return end local item = guiComboBoxGetSelected ( comboBox ) local text = tonumber(guiComboBoxGetItemText ( comboBox , item )) addVehicleUpgrade(veh, text) restartResource(getThisResource()) end end addEventHandler ( "onClientGUIComboBoxAccepted", guiRoot, setWheels) Link to comment
Scripting Moderators ds1-e Posted May 23, 2019 Scripting Moderators Share Posted May 23, 2019 59 minutes ago, Naruto Edits said: Hi guys I will ask question. I want if I am select gui combobox, do (client) functions and restart resource. But "restartResource" it is server function. How can I do? Please help me!! --Maybe you need --local wheelsModels = {0, 1025, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1096, 1097} -- --combo1 = guiCreateComboBox(0,0.1,1,0.3,"Wheels",true, tuning.window) --for i,wheel in pairs(wheelsModels) do -- guiComboBoxAddItem(combo1, wheel) --end function setWheels( comboBox ) if ( comboBox == combo1 ) then veh = getPedOccupiedVehicle(localPlayer) if not veh then return end local item = guiComboBoxGetSelected ( comboBox ) local text = tonumber(guiComboBoxGetItemText ( comboBox , item )) addVehicleUpgrade(veh, text) restartResource(getThisResource()) end end addEventHandler ( "onClientGUIComboBoxAccepted", guiRoot, setWheels) https://wiki.multitheftauto.com/wiki/TriggerServerEvent Link to comment
DeiwnEdits Posted May 23, 2019 Author Share Posted May 23, 2019 (edited) --Client Side function setWheels( comboBox ) if ( comboBox == combo1 ) then veh = getPedOccupiedVehicle(localPlayer) if not veh then return end local item = guiComboBoxGetSelected ( comboBox ) local text = tonumber(guiComboBoxGetItemText ( comboBox , item )) addVehicleUpgrade(veh, text) triggerServerEvent ( "onRestartWheels") end end addEventHandler ( "onClientGUIComboBoxAccepted", guiRoot, setWheels) --Server Side function restartHandler () restartResource(getThisResource()) end addEvent( "onRestartWheels", true ) addEventHandler( "onRestartWheels", resourceRoot, restartHandler ) What's false? @majqq Edited May 23, 2019 by Naruto Edits Link to comment
Scripting Moderators ds1-e Posted May 24, 2019 Scripting Moderators Share Posted May 24, 2019 (edited) 17 hours ago, Naruto Edits said: --Client Side function setWheels( comboBox ) if ( comboBox == combo1 ) then veh = getPedOccupiedVehicle(localPlayer) if not veh then return end local item = guiComboBoxGetSelected ( comboBox ) local text = tonumber(guiComboBoxGetItemText ( comboBox , item )) addVehicleUpgrade(veh, text) triggerServerEvent ( "onRestartWheels") end end addEventHandler ( "onClientGUIComboBoxAccepted", guiRoot, setWheels) --Server Side function restartHandler () restartResource(getThisResource()) end addEvent( "onRestartWheels", true ) addEventHandler( "onRestartWheels", resourceRoot, restartHandler ) What's false? @majqq Probably you forgot about: Quote theElement: The element that is the source of the event. In triggerServerEvent. triggerServerEvent("onRestartWheels", resourceRoot) Also add your resource to admin group in ACL: <object name="resource.resource_name"></object> Edited May 24, 2019 by majqq 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