-.Paradox.- Posted October 14, 2013 Share Posted October 14, 2013 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
Castillo Posted October 14, 2013 Share Posted October 14, 2013 You are sending the GUI button element as the player, remove 'source' from triggerServerEvent and doLockVehicle function name. Link to comment
-.Paradox.- Posted October 14, 2013 Author Share Posted October 14, 2013 Like that? triggerServerEvent("lockCar", getLocalPlayer(), doLockVehicle) Link to comment
Castillo Posted October 14, 2013 Share Posted October 14, 2013 No, that has nothing to do with what I said. This: triggerServerEvent ( "lockCar", getLocalPlayer() ) And this: function doLockVehicle ( ) Link to comment
-.Paradox.- Posted October 14, 2013 Author Share Posted October 14, 2013 Working thanks a lot man, and im asking if i can play sound when locking and play sound when unlocking? what i can use? Link to comment
Castillo Posted October 14, 2013 Share Posted October 14, 2013 Play the sound depending on current door state. Link to comment
-.Paradox.- Posted October 14, 2013 Author Share Posted October 14, 2013 What about triggerClientEvent --because playSound is a client side function playSound triggerServerEvent --to trigger the lock and unlock event to to client side Link to comment
Castillo Posted October 14, 2013 Share Posted October 14, 2013 triggerClientEvent + playSound. Link to comment
-.Paradox.- Posted October 14, 2013 Author Share Posted October 14, 2013 okay gonna try Link to comment
-.Paradox.- Posted October 14, 2013 Author Share Posted October 14, 2013 like that? function sound () local sound = playSound("sounds/lock.mp3") setSoundVolume(sound, 0.5) end addEvent("lockSound", true) addEventHandler("lockSound", getRootElement(), sound) Link to comment
Castillo Posted October 14, 2013 Share Posted October 14, 2013 Yeah, that should work. Link to comment
-.Paradox.- Posted October 14, 2013 Author Share Posted October 14, 2013 okay thanks everything is working good Link to comment
-.Paradox.- Posted October 15, 2013 Author Share Posted October 15, 2013 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. Link to comment
isa_Khamdan Posted October 15, 2013 Share Posted October 15, 2013 that's because you used play sound on server side. Link to comment
-.Paradox.- Posted October 15, 2013 Author Share Posted October 15, 2013 no i used triggerClientEvent in serverside Link to comment
isa_Khamdan Posted October 15, 2013 Share Posted October 15, 2013 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 ). Link to comment
TAPL Posted October 15, 2013 Share Posted October 15, 2013 Check my reply here: https://forum.multitheftauto.com/viewtopic.php?f=91&t=65687 Link to comment
-.Paradox.- Posted October 15, 2013 Author Share Posted October 15, 2013 I don't know how to use it, can you do it to me please? Link to comment
TAPL Posted October 15, 2013 Share Posted October 15, 2013 triggerClientEvent(source, "lockSound", source) Link to comment
-.Paradox.- Posted October 15, 2013 Author Share Posted October 15, 2013 It works thanks. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now