Jump to content

triggerServerEvent


-.Paradox.-

Recommended Posts

Posted

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) 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

You are sending the GUI button element as the player, remove 'source' from triggerServerEvent and doLockVehicle function name.

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

Like that?

triggerServerEvent("lockCar", getLocalPlayer(), doLockVehicle) 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

No, that has nothing to do with what I said.

This:

triggerServerEvent ( "lockCar", getLocalPlayer() ) 

And this:

function doLockVehicle ( ) 

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

Working thanks a lot man, and im asking if i can play sound when locking and play sound when unlocking? what i can use?

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Play the sound depending on current door state.

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

What about

  
triggerClientEvent --because playSound is a client side function 
playSound 
triggerServerEvent --to trigger the lock and unlock event to to client side 
  

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

triggerClientEvent + playSound.

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

okay gonna try

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

like that?

function sound ()  
    local sound = playSound("sounds/lock.mp3") 
    setSoundVolume(sound, 0.5) 
end 
addEvent("lockSound", true) 
addEventHandler("lockSound", getRootElement(), sound) 

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Yeah, that should work.

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

okay thanks everything is working good

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

You're welcome.

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

Got a little problem, when player lock the vehicle it play the locking sound but everybody can hear, and i want only the player who lock the vehicle can hear it.

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

no i used triggerClientEvent in serverside

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
no i used triggerClientEvent in serverside

Then maybe you triggered the event for all clients , you should trigger it for the player who locked/unlocked his vehicle only ( source ).

350x20_FFFFFF_FFFFFF_000000_000000.png
Posted

I don't know how to use it, can you do it to me please?

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

It works thanks. :)

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

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