xXMADEXx Posted February 8, 2013 Share Posted February 8, 2013 Hey guys, i'm trying to make a triggerServerEvent, to set the players vehicle color. For some reason, it says that "getColor" is a nil value, on server side. Client: addEventHandler("onClientGUIClick",root, function () local getColor = guiGetText(rog_modshop_colors_edit_red) if source == rog_modshop_colors_btn_set then if (getColor=="") then outputChatBox("Modshop: You must enter a valid color.",255,0,0) else triggerServerEvent("rog:modshop:color:setColor",localPlayer,getColor) outputChatBox("Modshop: You're vehicle color has been set to: "..getColor,0,255,0) end end end ) server: addEvent("rog:modshop:color:setColor",true) addEventHandler("rog:modshop:color:setColor",root, function (player,getColor) local veh = getPedOccupiedVehicle(player) setVehicleColor(veh,getColor) outputChatBox("Vehicle color set to: "..getColor,source,getColor) end ) Link to comment
Castillo Posted February 8, 2013 Share Posted February 8, 2013 Change: triggerServerEvent("rog:modshop:color:setColor",localPlayer,getColor) to: triggerServerEvent ( "rog:modshop:color:setColor", localPlayer, localPlayer, getColor ) Link to comment
xXMADEXx Posted February 8, 2013 Author Share Posted February 8, 2013 Change: triggerServerEvent("rog:modshop:color:setColor",localPlayer,getColor) to: triggerServerEvent ( "rog:modshop:color:setColor", localPlayer, localPlayer, getColor ) Did that, but now says somthing is wrong here: (with "getColor") addEvent("rog:modshop:color:setColor",true) addEventHandler("rog:modshop:color:setColor",root, function (getColor) local veh = getPedOccupiedVehicle(source) setVehicleColor(veh,getColor) outputChatBox("Vehicle color set to: "..getColor,source,0,255,0) end ) Link to comment
Castillo Posted February 9, 2013 Share Posted February 9, 2013 getColor is a string? like this: "255, 0, 0"? Link to comment
xXMADEXx Posted February 9, 2013 Author Share Posted February 9, 2013 getColor is a string? like this: "255, 0, 0"? yes Link to comment
Castillo Posted February 9, 2013 Share Posted February 9, 2013 You must split it then, use: split Link to comment
xXMADEXx Posted February 9, 2013 Author Share Posted February 9, 2013 You must split it then, use: split I have tried local getColor = split tostring ( guiGetText ( rog_modshop_colors_edit_red ) ) but no luck Link to comment
Castillo Posted February 9, 2013 Share Posted February 9, 2013 split is a funciton, you aren't using it as a function, seriously, pay more attention to what you are doing. 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