Jump to content

Help with triggerServerEvent


xXMADEXx

Recommended Posts

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

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