Jump to content

triggerServerEvent


-.Paradox.-

Recommended Posts

Hello all i have a little problem im trying to create a gui when player click on lock it lock the vehicle but when i make it it wont work here is a simple part from the script

Client

function lockButton() 
triggerServerEvent("lockCar", getLocalPlayer(), source) 
end 
addEventHandler ( "onClientGUIClick", GUIEditor.button[1], lockButton, false ) 

i want when player press button it lock the vehicle so i tried triggerServerEvent but nothing

Server

function doLockVehicle ( source ) 
    local theVehicle , strout 
    if ( getElementType(source) == "vehicle" ) then 
        theVehicle = source 
    end 
    if ( getElementType(source) == "player" ) then 
        theVehicle = getElementData ( source, "cl_ownedvehicle" ) 
    end 
  
    if ( theVehicle ) then 
        local vehiclename = getVehicleName ( theVehicle ) 
        -- already locked 
        if ( getElementData ( theVehicle, "cl_vehiclelocked") == true ) then 
            strout = "Your " .. vehiclename .. " is already locked."  
            Err_Msg(strout, source) 
        else  
            setElementData ( theVehicle, "cl_vehiclelocked", true) 
            setVehicleLocked ( theVehicle, true )  
            Car_Msg( "Current vehicle " .. vehiclename .. " locked.", theVehicle) 
            Info_Msg ( "Locked vehicle " .. vehiclename .. ".", source ) 
            if ( getVehicleController ( theVehicle ) == false ) then 
                cl_FlashLights ( source ) 
            end 
        end 
    else 
        Err_Msg("You must have a vehicle to lock it.", source) 
    end 
end 
addEvent("lockCar", true) 
addEventHandler("lockCar", getRootElement(), doLockVehicle) 

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