Jump to content

Gui Ratio


#Paper

Recommended Posts

Posted (edited)

The event doesn't trigger:

  
--Client: 
  
function triggerFunc (theButton) 
if theButton == GUIEditor_Radio[1] then 
triggerServerEvent(getLocalPlayer(), "onColorSet", "Red", getLocalPlayer()) 
elseif theButton == GUIEditor_Radio[2] then 
triggerServerEvent(getLocalPlayer(), "onColorSet", "Yellow", getLocalPlayer()) 
elseif theButton == GUIEditor_Radio[3] then 
triggerServerEvent(getLocalPlayer(), "onColorSet", "Black", getLocalPlayer()) 
elseif theButton == GUIEditor_Radio[4] then 
triggerServerEvent(getLocalPlayer(), "onColorSet", "White", getLocalPlayer()) 
elseif theButton == GUIEditor_Radio[5] then 
triggerServerEvent(getLocalPlayer(), "onColorSet", "Purple", getLocalPlayer()) 
elseif theButton == GUIEditor_Radio[6] then 
triggerServerEvent(getLocalPlayer(), "onColorSet", "Orange", getLocalPlayer()) 
elseif theButton == GUIEditor_Radio[7] then 
triggerServerEvent(getLocalPlayer(), "onColorSet", "Blue", getLocalPlayer()) 
end 
end 
  
addEventHandler("onClientGUIClick", GUIEditor_Radio[1], triggerFunc) 
addEventHandler("onClientGUIClick", GUIEditor_Radio[2], triggerFunc) 
addEventHandler("onClientGUIClick", GUIEditor_Radio[3], triggerFunc) 
addEventHandler("onClientGUIClick", GUIEditor_Radio[4], triggerFunc) 
addEventHandler("onClientGUIClick", GUIEditor_Radio[5], triggerFunc) 
addEventHandler("onClientGUIClick", GUIEditor_Radio[6], triggerFunc) 
addEventHandler("onClientGUIClick", GUIEditor_Radio[7], triggerFunc) 
  
--Server: 
  
addEvent("onColorSet", true) 
function changeVehicleColor(theColor, thePlayer) 
local pVhe = getPedOccupiedVehicle(thePlayer) 
if pVhe then 
if theColor == "Red" then 
setVehicleHeadLightColor ( pVhe, 255, 0, 0 ) 
elseif theColor == "Yellow" then 
setVehicleHeadLightColor ( pVhe, 255, 255, 0 ) 
elseif theColor == "Black" then 
setVehicleHeadLightColor ( pVhe, 0, 0, 0 ) 
elseif theColor == "White" then 
setVehicleHeadLightColor ( pVhe, 255, 255, 255 ) 
elseif theColor == "Purple" then 
setVehicleHeadLightColor ( pVhe, 160, 32, 240 ) 
elseif theColor == "Orange" then 
setVehicleHeadLightColor ( pVhe, 255, 165, 0 ) 
elseif theColor == "Blue" then 
setVehicleHeadLightColor ( pVhe, 0, 0, 255 ) 
end 
end 
end 
addEventHandler("onColorSet", getRootElement(), changeVehicleColor) 

Edited by Guest
  • Discord Moderators
Posted

I think you might be confused by 'button' argument in onClientGUIClick >> https://wiki.multitheftauto.com/wiki/OnClientGUIClick

string button, string state, int absoluteX, int absoluteY 

[b]button[/b]: the name of the mouse button that the GUI element was clicked with, can be left, right, or middle. 

remove argument in parentheses at triggerFunc and use source as comparison

fx

if source == GUIEditor_Radio[1] then 

Posted
I think you might be confused by 'button' argument in onClientGUIClick >> https://wiki.multitheftauto.com/wiki/OnClientGUIClick
string button, string state, int absoluteX, int absoluteY 

[b]button[/b]: the name of the mouse button that the GUI element was clicked with, can be left, right, or middle. 

remove argument in parentheses at triggerFunc and use source as comparison

fx

if source == GUIEditor_Radio[1] then 

if i place source it works?

Posted

You are using it like triggerClientEvent, in triggerServerEvent must be like this:

triggerServerEvent("onColorSet", getLocalPlayer(), "Red") 

  • Discord Moderators
Posted
Yes it works

All the triggerServerEvent are bad arguments... <_<

well yes, that's because you haven't read the documentation for triggerServerEvent

it's event, element and arguments. Not element, event, arguments :)

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...