Jump to content

Help with triggerServerEvent


xXMADEXx

Recommended Posts

Posted

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 
) 

Posted

Change:

triggerServerEvent("rog:modshop:color:setColor",localPlayer,getColor) 

to:

triggerServerEvent ( "rog:modshop:color:setColor", localPlayer, localPlayer, getColor ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Posted

getColor is a string? like this: "255, 0, 0"?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You must split it then, use:

split 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

split is a funciton, you aren't using it as a function, seriously, pay more attention to what you are doing.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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