Jump to content

[HELP]Wheels


Recommended Posts

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
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
--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 by Naruto Edits
Link to comment
  • Scripting Moderators
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 by majqq
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...