Jump to content

TriggerServerEvent


xXMADEXx

Recommended Posts

Posted

I made this code, to set a vehicle's color with an edit. No luck..

Client:

        local r = tonumber (guiGetText(rog_modshop_colors_edit_r)) 
        local g = tonumber (guiGetText(rog_modshop_colors_edit_r)) 
        local b = tonumber (guiGetText(rog_modshop_colors_edit_b)) 
triggerServerEvent ( "rog:modshop:color:setColor", localPlayer, localPlayer, r, g, b ) 

Server

addEvent("rog:modshop:color:setColor",true) 
addEventHandler("rog:modshop:color:setColor",root, 
    function (r,g,b) 
        local veh = getPedOccupiedVehicle(source) 
        setVehicleColor(veh,r,g,b) 
    end 
) 

Posted
triggerServerEvent ( "rog:modshop:color:setColor", localPlayer, localPlayer, r, g, b ) 

Should be

triggerServerEvent ( "rog:modshop:color:setColor", localPlayer, r, g, b ) 

Posted

You had 2 times getLocalPlayer within triggerServerEvent

bool triggerServerEvent ( string event, element theElement, [arguments...] ) 

  
local r = tonumber (guiGetText(rog_modshop_colors_edit_r)) 
        local g = tonumber (guiGetText(rog_modshop_colors_edit_r)) 
        local b = tonumber (guiGetText(rog_modshop_colors_edit_b)) 
player = getLocalPlayer() 
triggerServerEvent ( "rog:modshop:color:setColor", player, player, r, g, b ) 
  

addEvent("rog:modshop:color:setColor",true) 
addEventHandler("rog:modshop:color:setColor",root, 
    function (player,r,g,b) 
        local veh = getPedOccupiedVehicle(player) 
        setVehicleColor(veh,r,g,b) 
    end 
) 

Posted

Just so you know, you can use client "hidden variable" in custom server side events triggered by clients to get the player who triggered the event.

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