mr.Extreme Posted November 15, 2013 Share Posted November 15, 2013 اسلام عليكم شبااب انا عندي مشكلة انا سويت لوحة في زر تفتح باب سيارة او اغلاقة بس مو راضي يشتغل دايما يجيلي هذا رسالة You must have a vehicle to unlock it. client: GUIEditor.button[3] = guiCreateButton(201, 185, 77, 28, "Unlock", false, GUIEditor.window[1]) function unlockVehicles () triggerServerEvent( "undoLockVehiclee", root) end addEventHandler("onClientGUIClick", GUIEditor.button[3], unlockVehicles,false) server : addEvent("undoLockVehiclee", true) addEventHandler("undoLockVehiclee", root, function ( 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 ) if ( getElementData ( theVehicle, "cl_vehiclelocked") == false ) then strout = "Your " .. vehiclename .. " is already unlocked." Err_Msg(strout, source) else setElementData ( theVehicle, "cl_vehiclelocked", false) setVehicleLocked ( theVehicle, false ) Car_Msg( "current vehicle " .. vehiclename .. " unlocked.", theVehicle ) Info_Msg ( "unlocked vehicle " .. vehiclename .. ".", source ) if ( getVehicleController ( theVehicle ) == false ) then cl_FlashOnce ( source ) end end else Err_Msg("You must have a vehicle to unlock it.") end end ) بدي حل . . . . وشكرا Link to comment
AboShanab Posted November 15, 2013 Share Posted November 15, 2013 الكود مبين عليه انه منسوخ ,, لفتح قفل سيارة استخدم ,, setVehicleLocked Link to comment
mr.Extreme Posted November 15, 2013 Author Share Posted November 15, 2013 شوف وش الحل مو راضي يشتغل client: GUIEditor = { button = {}, window = {}, scrollbar = {}, label = {} } GUIEditor.window[1] = guiCreateWindow(313, 249, 384, 228, "", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(10, 185, 77, 28, "Engine", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(105, 185, 77, 28, "Lock", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(201, 185, 77, 28, "Unlock", false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(297, 185, 77, 28, "Light", false, GUIEditor.window[1]) GUIEditor.scrollbar[1] = guiCreateScrollBar(9, 27, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[2] = guiCreateScrollBar(9, 52, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[3] = guiCreateScrollBar(9, 77, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[4] = guiCreateScrollBar(9, 102, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[5] = guiCreateScrollBar(10, 127, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[6] = guiCreateScrollBar(10, 152, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(215, 26, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[2] = guiCreateLabel(215, 51, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[3] = guiCreateLabel(215, 76, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[4] = guiCreateLabel(215, 101, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[5] = guiCreateLabel(215, 126, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[6] = guiCreateLabel(215, 152, 159, 16, "", false, GUIEditor.window[1]) ---- open window "l" function openCloseWindow(player) if guiGetVisible(GUIEditor.window[1]) then guiSetVisible(GUIEditor.window[1], false) showCursor(false) else guiSetVisible(GUIEditor.window[1], true) showCursor(true) end end bindKey("l", "down", openCloseWindow) function onResourcestart() guiSetVisible(GUIEditor.window[1], false) showCursor(false) end addEventHandler("onClientResourceStart", getRootElement(), onResourcestart) ------- lock Vehicles --------- --[[ addEventHandler("onClientGUIClick", getRootElement(), function () if ( source == GUIEditor.button[2] ) then triggerServerEvent( "doLockVehiclee", getRootElement()) end end )]] function lockVehicles () triggerServerEvent( "doLockVehiclee", root) end addEventHandler("onClientGUIClick", GUIEditor.button[2], lockVehicles,false) --- unlock vehcles ------- function unlockVehicles () triggerServerEvent( "undoLockVehiclee", root) end addEventHandler("onClientGUIClick", GUIEditor.button[3], unlockVehicles,false) ---- Engine function unlockVehicles () triggerServerEvent( "doToggleEngine", root) end addEventHandler("onClientGUIClick", GUIEditor.button[1], unlockVehicles,false) -- Car Locks ( client ) -- local player localPlayer = getLocalPlayer ( ) -- playSoundNearElement addEvent ( "onPlaySoundNearElement", true ) function playSoundNearElement ( theElement, sound ) -- local sound = 5 local maxdist = 15.0 -- valid element if ( theElement ) then local x,y,z = getElementPosition ( theElement ) local x2,y2,z2 = getElementPosition ( localPlayer ) local dist = getDistanceBetweenPoints3D ( x, y, z, x2, y2, z2 ) -- distance is less than parameter maxdist if ( dist < maxdist ) then -- play parameter sound playSoundFrontEnd ( 5 ) -- outputChatBox ( "sound should play" ) else -- outputChatBox ( "not in range" ) end else -- outputChatBox ( "invalid element" ) end end addEventHandler ( "onPlaySoundNearElement", getRootElement(), playSoundNearElement ) server: -- ================= -- Car Locks ( server ) -- by vick. -- ================= -- player element data -- -- cl_ownedvehicle -- vehicle element data -- -- cl_vehicleowner -- cl_vehiclelocked -- cl_enginestate -- resource starts - ends function initCarLocks () -- Initilize Player Element Data local players = getElementsByType ( "player" ) for k,p in ipairs(players) do removeElementData ( p, "cl_ownedvehicle" ) bindKey ( p, "j", "down", doToggleLocked ) end -- Initilize Vehicle Element Data local vehicles = getElementsByType ( "vehicle" ) for k,v in ipairs(vehicles) do removeElementData ( v, "cl_vehicleowner" ) removeElementData ( v, "cl_vehiclelocked" ) removeElementData ( v, "cl_enginestate" ) setVehicleLocked ( v, false ) setVehicleOverrideLights ( v, 0 ) end end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), initCarLocks ) addEventHandler ( "onResourceStop", getResourceRootElement ( getThisResource () ), initCarLocks ) -- player joins function cl_PlayerJoin ( ) bindKey ( source, "k", "down", doToggleLocked ) end addEventHandler ( "onPlayerJoin", getRootElement(), cl_PlayerJoin ) -- player quits function cl_PlayerQuit ( ) -- check for owned car local ownedVehicle = getElementData ( source, "cl_ownedvehicle" ) if (ownedVehicle ~= false) then cl_RemoveVehicleOwner ( ownedVehicle ) end end addEventHandler ( "onPlayerQuit", getRootElement(), cl_PlayerQuit ) -- player dies function cl_PlayerWasted ( ) -- check for owned car local ownedVehicle = getElementData ( source, "cl_ownedvehicle" ) if (ownedVehicle ~= false) then cl_RemoveVehicleOwner ( ownedVehicle ) end end addEventHandler ( "onPlayerWasted", getRootElement(), cl_PlayerWasted ) -- player tries to enter vehicle function cl_VehicleStartEnter ( enteringPlayer, seat, jacked ) local theVehicle = source local theOwner -- locked and not owner entering if ( getElementData ( theVehicle, "cl_vehiclelocked" ) == true ) then theOwner = getElementData ( theVehicle, "cl_vehicleowner" ) if theOwner ~= false and theOwner ~= enteringPlayer then -- make sure they dont enter --cancelEvent(); end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), cl_VehicleStartEnter ) -- player enters a vehicle function cl_PlayerDriveVehicle ( player, seat, jacked ) -- Driver Enter if ( seat == 0 ) then oldVehicle = getElementData ( player, "cl_ownedvehicle" ) -- not entering player's own owned vehicle if ( (cl_VehicleLocked(source) == true) and (cl_VehicleOwner(source) ~= player) ) then removePlayerFromVehicle( player ) Err_Msg("this vehicle is locked.", player) return false end -- set element data for vehicle and owner cl_SetVehicleOwner ( source, player ) end return true end addEventHandler ( "onVehicleEnter", getRootElement(), cl_PlayerDriveVehicle ) -- vehicle respawns function cl_VehicleRespawn ( exploded ) cl_RemoveVehicleOwner ( source ) end addEventHandler ( "OnVehicleRespawn", getRootElement(), cl_VehicleRespawn ) -- vehicle explosion function cl_VehicleExplode ( ) local theOwner = getElementData ( source, "cl_vehicleowner" ) if ( theOwner ~= false ) then cl_RemoveVehicleOwner ( source ) end end addEventHandler ( "onVehicleExplode", getRootElement(), cl_VehicleExplode ) -- set vehicle owner function cl_SetVehicleOwner ( theVehicle, thePlayer ) local oldVehicle = getElementData ( thePlayer, "cl_ownedvehicle" ) if ( oldVehicle ~= false ) then -- unlock old car removeElementData ( oldVehicle, "cl_vehicleowner" ) removeElementData ( oldVehicle, "cl_vehiclelocked" ) removeElementData ( oldVehicle, "cl_enginestate" ) setVehicleLocked ( oldVehicle, false ) -- set vars for new car end setElementData ( theVehicle, "cl_vehicleowner", thePlayer ) setElementData ( theVehicle, "cl_vehiclelocked", false ) setElementData ( thePlayer, "cl_ownedvehicle", theVehicle ) setElementData( theVehicle, "cl_enginestate", true ) end function cl_RemoveVehicleOwner ( theVehicle ) local theOwner = getElementData ( theVehicle, "cl_vehicleowner" ) if ( theOwner ~= false ) then removeElementData ( theOwner, "cl_ownedvehicle" ) removeElementData ( theVehicle, "cl_vehicleowner" ) removeElementData ( theVehicle, "cl_vehiclelocked" ) removeElementData ( owned, "cl_enginestate" ) end setVehicleLocked ( theVehicle, false ) end -- flash the lights twice function cl_FlashLights ( thePlayer ) setTimer ( doToggleLights, 300, 4, thePlayer, true ) end -- flash once function cl_FlashOnce ( thePlayer ) setTimer ( doToggleLights, 300, 2, thePlayer, true ) end -- get vehicle owner ( according to vehicle's element data ) function cl_VehicleOwner ( theVehicle ) return getElementData( theVehicle, "cl_vehicleowner" ) end -- is vehicle locked ( according to vehicle's element data ) function cl_VehicleLocked ( theVehicle ) return getElementData( theVehicle, "cl_vehiclelocked" ) end -- messaging functions -- send red error message function Err_Msg ( strout, thePlayer ) outputChatBox ( strout, thePlayer, 200, 0, 10 ) end -- send message to all occupants of vehicle function Car_Msg ( strout, theVehicle ) numseats = getVehicleMaxPassengers ( theVehicle ) for s = 0, numseats do local targetPlayer = getVehicleOccupant ( theVehicle, s ) if targetPlayer ~= false then outputChatBox ( strout, targetPlayer, 30, 144, 255 ) end end end -- send aquamarine message to player function Info_Msg ( strout, thePlayer ) outputChatBox ( strout, thePlayer, 102, 205, 170 ) end -- commands function doToggleLocked ( 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 doUnlockVehicle ( source ) else doLockVehicle ( source ) end else Err_Msg("You must have a vehicle to lock or unlock it.", source) end end addEvent("doLockVehiclee", true) addEventHandler("doLockVehiclee", root, function( 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("undoLockVehiclee", true) addEventHandler("undoLockVehiclee", root, function ( 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 ) if ( getElementData ( theVehicle, "cl_vehiclelocked") == false ) then strout = "Your " .. vehiclename .. " is already unlocked." Err_Msg(strout, source) else Link to comment
AboShanab Posted November 15, 2013 Share Posted November 15, 2013 ابي اعرف انا الى متى النسخ والصق .. ؟ وقسسم بايات الله يوم انا كنت مبتدا مثلك كنت احاول شوي ع الاقل .. !! -- # Client Side ! GUIEditor = { button = {}, window = {}, scrollbar = {}, label = {} } GUIEditor.window[1] = guiCreateWindow(313, 249, 384, 228, "", false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1], false) showCursor(false) GUIEditor.button[1] = guiCreateButton(10, 185, 77, 28, "Engine", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(105, 185, 77, 28, "Lock", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(201, 185, 77, 28, "Unlock", false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(297, 185, 77, 28, "Light", false, GUIEditor.window[1]) GUIEditor.scrollbar[1] = guiCreateScrollBar(9, 27, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[2] = guiCreateScrollBar(9, 52, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[3] = guiCreateScrollBar(9, 77, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[4] = guiCreateScrollBar(9, 102, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[5] = guiCreateScrollBar(10, 127, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[6] = guiCreateScrollBar(10, 152, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(215, 26, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[2] = guiCreateLabel(215, 51, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[3] = guiCreateLabel(215, 76, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[4] = guiCreateLabel(215, 101, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[5] = guiCreateLabel(215, 126, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[6] = guiCreateLabel(215, 152, 159, 16, "", false, GUIEditor.window[1]) function openCloseWindow(player) if guiGetVisible(GUIEditor.window[1]) then guiSetVisible(GUIEditor.window[1], false) showCursor(false) else guiSetVisible(GUIEditor.window[1], true) showCursor(true) end end bindKey("l", "down", openCloseWindow) addEventHandler("onClientGUIClick",root,function() if ( source == GUIEditor.button[3] ) then triggerServerEvent("Unlock",localPlayer) end end) -- # Server Side ! addEvent("Unlock",true) addEventHandler("Unlock",root,function() if ( isPedInVehicle(source) ) then if ( isVehicleLocked(getPedOccupiedVehicle(source)) ) then setVehicleLocked(getPedOccupiedVehicle(source) , false) end end end) Link to comment
mr.Extreme Posted January 17, 2014 Author Share Posted January 17, 2014 شوف وش الحل مو راضي يشتغلclient: GUIEditor = { button = {}, window = {}, scrollbar = {}, label = {} } GUIEditor.window[1] = guiCreateWindow(313, 249, 384, 228, "", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(10, 185, 77, 28, "Engine", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(105, 185, 77, 28, "Lock", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(201, 185, 77, 28, "Unlock", false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(297, 185, 77, 28, "Light", false, GUIEditor.window[1]) GUIEditor.scrollbar[1] = guiCreateScrollBar(9, 27, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[2] = guiCreateScrollBar(9, 52, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[3] = guiCreateScrollBar(9, 77, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[4] = guiCreateScrollBar(9, 102, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[5] = guiCreateScrollBar(10, 127, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[6] = guiCreateScrollBar(10, 152, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(215, 26, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[2] = guiCreateLabel(215, 51, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[3] = guiCreateLabel(215, 76, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[4] = guiCreateLabel(215, 101, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[5] = guiCreateLabel(215, 126, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[6] = guiCreateLabel(215, 152, 159, 16, "", false, GUIEditor.window[1]) ---- open window "l" function openCloseWindow(player) if guiGetVisible(GUIEditor.window[1]) then guiSetVisible(GUIEditor.window[1], false) showCursor(false) else guiSetVisible(GUIEditor.window[1], true) showCursor(true) end end bindKey("l", "down", openCloseWindow) function onResourcestart() guiSetVisible(GUIEditor.window[1], false) showCursor(false) end addEventHandler("onClientResourceStart", getRootElement(), onResourcestart) ------- lock Vehicles --------- --[[ addEventHandler("onClientGUIClick", getRootElement(), function () if ( source == GUIEditor.button[2] ) then triggerServerEvent( "doLockVehiclee", getRootElement()) end end )]] function lockVehicles () triggerServerEvent( "doLockVehiclee", root) end addEventHandler("onClientGUIClick", GUIEditor.button[2], lockVehicles,false) --- unlock vehcles ------- function unlockVehicles () triggerServerEvent( "undoLockVehiclee", root) end addEventHandler("onClientGUIClick", GUIEditor.button[3], unlockVehicles,false) ---- Engine function unlockVehicles () triggerServerEvent( "doToggleEngine", root) end addEventHandler("onClientGUIClick", GUIEditor.button[1], unlockVehicles,false) -- Car Locks ( client ) -- local player localPlayer = getLocalPlayer ( ) -- playSoundNearElement addEvent ( "onPlaySoundNearElement", true ) function playSoundNearElement ( theElement, sound ) -- local sound = 5 local maxdist = 15.0 -- valid element if ( theElement ) then local x,y,z = getElementPosition ( theElement ) local x2,y2,z2 = getElementPosition ( localPlayer ) local dist = getDistanceBetweenPoints3D ( x, y, z, x2, y2, z2 ) -- distance is less than parameter maxdist if ( dist < maxdist ) then -- play parameter sound playSoundFrontEnd ( 5 ) -- outputChatBox ( "sound should play" ) else -- outputChatBox ( "not in range" ) end else -- outputChatBox ( "invalid element" ) end end addEventHandler ( "onPlaySoundNearElement", getRootElement(), playSoundNearElement ) server: -- ================= -- Car Locks ( server ) -- by vick. -- ================= -- player element data -- -- cl_ownedvehicle -- vehicle element data -- -- cl_vehicleowner -- cl_vehiclelocked -- cl_enginestate -- resource starts - ends function initCarLocks () -- Initilize Player Element Data local players = getElementsByType ( "player" ) for k,p in ipairs(players) do removeElementData ( p, "cl_ownedvehicle" ) bindKey ( p, "j", "down", doToggleLocked ) end -- Initilize Vehicle Element Data local vehicles = getElementsByType ( "vehicle" ) for k,v in ipairs(vehicles) do removeElementData ( v, "cl_vehicleowner" ) removeElementData ( v, "cl_vehiclelocked" ) removeElementData ( v, "cl_enginestate" ) setVehicleLocked ( v, false ) setVehicleOverrideLights ( v, 0 ) end end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), initCarLocks ) addEventHandler ( "onResourceStop", getResourceRootElement ( getThisResource () ), initCarLocks ) -- player joins function cl_PlayerJoin ( ) bindKey ( source, "k", "down", doToggleLocked ) end addEventHandler ( "onPlayerJoin", getRootElement(), cl_PlayerJoin ) -- player quits function cl_PlayerQuit ( ) -- check for owned car local ownedVehicle = getElementData ( source, "cl_ownedvehicle" ) if (ownedVehicle ~= false) then cl_RemoveVehicleOwner ( ownedVehicle ) end end addEventHandler ( "onPlayerQuit", getRootElement(), cl_PlayerQuit ) -- player dies function cl_PlayerWasted ( ) -- check for owned car local ownedVehicle = getElementData ( source, "cl_ownedvehicle" ) if (ownedVehicle ~= false) then cl_RemoveVehicleOwner ( ownedVehicle ) end end addEventHandler ( "onPlayerWasted", getRootElement(), cl_PlayerWasted ) -- player tries to enter vehicle function cl_VehicleStartEnter ( enteringPlayer, seat, jacked ) local theVehicle = source local theOwner -- locked and not owner entering if ( getElementData ( theVehicle, "cl_vehiclelocked" ) == true ) then theOwner = getElementData ( theVehicle, "cl_vehicleowner" ) if theOwner ~= false and theOwner ~= enteringPlayer then -- make sure they dont enter --cancelEvent(); end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), cl_VehicleStartEnter ) -- player enters a vehicle function cl_PlayerDriveVehicle ( player, seat, jacked ) -- Driver Enter if ( seat == 0 ) then oldVehicle = getElementData ( player, "cl_ownedvehicle" ) -- not entering player's own owned vehicle if ( (cl_VehicleLocked(source) == true) and (cl_VehicleOwner(source) ~= player) ) then removePlayerFromVehicle( player ) Err_Msg("this vehicle is locked.", player) return false end -- set element data for vehicle and owner cl_SetVehicleOwner ( source, player ) end return true end addEventHandler ( "onVehicleEnter", getRootElement(), cl_PlayerDriveVehicle ) -- vehicle respawns function cl_VehicleRespawn ( exploded ) cl_RemoveVehicleOwner ( source ) end addEventHandler ( "OnVehicleRespawn", getRootElement(), cl_VehicleRespawn ) -- vehicle explosion function cl_VehicleExplode ( ) local theOwner = getElementData ( source, "cl_vehicleowner" ) if ( theOwner ~= false ) then cl_RemoveVehicleOwner ( source ) end end addEventHandler ( "onVehicleExplode", getRootElement(), cl_VehicleExplode ) -- set vehicle owner function cl_SetVehicleOwner ( theVehicle, thePlayer ) local oldVehicle = getElementData ( thePlayer, "cl_ownedvehicle" ) if ( oldVehicle ~= false ) then -- unlock old car removeElementData ( oldVehicle, "cl_vehicleowner" ) removeElementData ( oldVehicle, "cl_vehiclelocked" ) removeElementData ( oldVehicle, "cl_enginestate" ) setVehicleLocked ( oldVehicle, false ) -- set vars for new car end setElementData ( theVehicle, "cl_vehicleowner", thePlayer ) setElementData ( theVehicle, "cl_vehiclelocked", false ) setElementData ( thePlayer, "cl_ownedvehicle", theVehicle ) setElementData( theVehicle, "cl_enginestate", true ) end function cl_RemoveVehicleOwner ( theVehicle ) local theOwner = getElementData ( theVehicle, "cl_vehicleowner" ) if ( theOwner ~= false ) then removeElementData ( theOwner, "cl_ownedvehicle" ) removeElementData ( theVehicle, "cl_vehicleowner" ) removeElementData ( theVehicle, "cl_vehiclelocked" ) removeElementData ( owned, "cl_enginestate" ) end setVehicleLocked ( theVehicle, false ) end -- flash the lights twice function cl_FlashLights ( thePlayer ) setTimer ( doToggleLights, 300, 4, thePlayer, true ) end -- flash once function cl_FlashOnce ( thePlayer ) setTimer ( doToggleLights, 300, 2, thePlayer, true ) end -- get vehicle owner ( according to vehicle's element data ) function cl_VehicleOwner ( theVehicle ) return getElementData( theVehicle, "cl_vehicleowner" ) end -- is vehicle locked ( according to vehicle's element data ) function cl_VehicleLocked ( theVehicle ) return getElementData( theVehicle, "cl_vehiclelocked" ) end -- messaging functions -- send red error message function Err_Msg ( strout, thePlayer ) outputChatBox ( strout, thePlayer, 200, 0, 10 ) end -- send message to all occupants of vehicle function Car_Msg ( strout, theVehicle ) numseats = getVehicleMaxPassengers ( theVehicle ) for s = 0, numseats do local targetPlayer = getVehicleOccupant ( theVehicle, s ) if targetPlayer ~= false then outputChatBox ( strout, targetPlayer, 30, 144, 255 ) end end end -- send aquamarine message to player function Info_Msg ( strout, thePlayer ) outputChatBox ( strout, thePlayer, 102, 205, 170 ) end -- commands function doToggleLocked ( 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 doUnlockVehicle ( source ) else doLockVehicle ( source ) end else Err_Msg("You must have a vehicle to lock or unlock it.", source) end end addEvent("doLockVehiclee", true) addEventHandler("doLockVehiclee", root, function( 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("undoLockVehiclee", true) addEventHandler("undoLockVehiclee", root, function ( 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 ) if ( getElementData ( theVehicle, "cl_vehiclelocked") == false ) then strout = "Your " .. vehiclename .. " is already unlocked." Err_Msg Link to comment
mr.Extreme Posted January 17, 2014 Author Share Posted January 17, 2014 شوف وش الحل مو راضي يشتغلclient: GUIEditor = { button = {}, window = {}, scrollbar = {}, label = {} } GUIEditor.window[1] = guiCreateWindow(313, 249, 384, 228, "", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(10, 185, 77, 28, "Engine", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(105, 185, 77, 28, "Lock", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(201, 185, 77, 28, "Unlock", false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(297, 185, 77, 28, "Light", false, GUIEditor.window[1]) GUIEditor.scrollbar[1] = guiCreateScrollBar(9, 27, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[2] = guiCreateScrollBar(9, 52, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[3] = guiCreateScrollBar(9, 77, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[4] = guiCreateScrollBar(9, 102, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[5] = guiCreateScrollBar(10, 127, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[6] = guiCreateScrollBar(10, 152, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(215, 26, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[2] = guiCreateLabel(215, 51, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[3] = guiCreateLabel(215, 76, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[4] = guiCreateLabel(215, 101, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[5] = guiCreateLabel(215, 126, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[6] = guiCreateLabel(215, 152, 159, 16, "", false, GUIEditor.window[1]) ---- open window "l" function openCloseWindow(player) if guiGetVisible(GUIEditor.window[1]) then guiSetVisible(GUIEditor.window[1], false) showCursor(false) else guiSetVisible(GUIEditor.window[1], true) showCursor(true) end end bindKey("l", "down", openCloseWindow) function onResourcestart() guiSetVisible(GUIEditor.window[1], false) showCursor(false) end addEventHandler("onClientResourceStart", getRootElement(), onResourcestart) ------- lock Vehicles --------- --[[ addEventHandler("onClientGUIClick", getRootElement(), function () if ( source == GUIEditor.button[2] ) then triggerServerEvent( "doLockVehiclee", getRootElement()) end end )]] function lockVehicles () triggerServerEvent( "doLockVehiclee", root) end addEventHandler("onClientGUIClick", GUIEditor.button[2], lockVehicles,false) --- unlock vehcles ------- function unlockVehicles () triggerServerEvent( "undoLockVehiclee", root) end addEventHandler("onClientGUIClick", GUIEditor.button[3], unlockVehicles,false) ---- Engine function unlockVehicles () triggerServerEvent( "doToggleEngine", root) end addEventHandler("onClientGUIClick", GUIEditor.button[1], unlockVehicles,false) -- Car Locks ( client ) -- local player localPlayer = getLocalPlayer ( ) -- playSoundNearElement addEvent ( "onPlaySoundNearElement", true ) function playSoundNearElement ( theElement, sound ) -- local sound = 5 local maxdist = 15.0 -- valid element if ( theElement ) then local x,y,z = getElementPosition ( theElement ) local x2,y2,z2 = getElementPosition ( localPlayer ) local dist = getDistanceBetweenPoints3D ( x, y, z, x2, y2, z2 ) -- distance is less than parameter maxdist if ( dist < maxdist ) then -- play parameter sound playSoundFrontEnd ( 5 ) -- outputChatBox ( "sound should play" ) else -- outputChatBox ( "not in range" ) end else -- outputChatBox ( "invalid element" ) end end addEventHandler ( "onPlaySoundNearElement", getRootElement(), playSoundNearElement ) server: -- ================= -- Car Locks ( server ) -- by vick. -- ================= -- player element data -- -- cl_ownedvehicle -- vehicle element data -- -- cl_vehicleowner -- cl_vehiclelocked -- cl_enginestate -- resource starts - ends function initCarLocks () -- Initilize Player Element Data local players = getElementsByType ( "player" ) for k,p in ipairs(players) do removeElementData ( p, "cl_ownedvehicle" ) bindKey ( p, "j", "down", doToggleLocked ) end -- Initilize Vehicle Element Data local vehicles = getElementsByType ( "vehicle" ) for k,v in ipairs(vehicles) do removeElementData ( v, "cl_vehicleowner" ) removeElementData ( v, "cl_vehiclelocked" ) removeElementData ( v, "cl_enginestate" ) setVehicleLocked ( v, false ) setVehicleOverrideLights ( v, 0 ) end end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), initCarLocks ) addEventHandler ( "onResourceStop", getResourceRootElement ( getThisResource () ), initCarLocks ) -- player joins function cl_PlayerJoin ( ) bindKey ( source, "k", "down", doToggleLocked ) end addEventHandler ( "onPlayerJoin", getRootElement(), cl_PlayerJoin ) -- player quits function cl_PlayerQuit ( ) -- check for owned car local ownedVehicle = getElementData ( source, "cl_ownedvehicle" ) if (ownedVehicle ~= false) then cl_RemoveVehicleOwner ( ownedVehicle ) end end addEventHandler ( "onPlayerQuit", getRootElement(), cl_PlayerQuit ) -- player dies function cl_PlayerWasted ( ) -- check for owned car local ownedVehicle = getElementData ( source, "cl_ownedvehicle" ) if (ownedVehicle ~= false) then cl_RemoveVehicleOwner ( ownedVehicle ) end end addEventHandler ( "onPlayerWasted", getRootElement(), cl_PlayerWasted ) -- player tries to enter vehicle function cl_VehicleStartEnter ( enteringPlayer, seat, jacked ) local theVehicle = source local theOwner -- locked and not owner entering if ( getElementData ( theVehicle, "cl_vehiclelocked" ) == true ) then theOwner = getElementData ( theVehicle, "cl_vehicleowner" ) if theOwner ~= false and theOwner ~= enteringPlayer then -- make sure they dont enter --cancelEvent(); end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), cl_VehicleStartEnter ) -- player enters a vehicle function cl_PlayerDriveVehicle ( player, seat, jacked ) -- Driver Enter if ( seat == 0 ) then oldVehicle = getElementData ( player, "cl_ownedvehicle" ) -- not entering player's own owned vehicle if ( (cl_VehicleLocked(source) == true) and (cl_VehicleOwner(source) ~= player) ) then removePlayerFromVehicle( player ) Err_Msg("this vehicle is locked.", player) return false end -- set element data for vehicle and owner cl_SetVehicleOwner ( source, player ) end return true end addEventHandler ( "onVehicleEnter", getRootElement(), cl_PlayerDriveVehicle ) -- vehicle respawns function cl_VehicleRespawn ( exploded ) cl_RemoveVehicleOwner ( source ) end addEventHandler ( "OnVehicleRespawn", getRootElement(), cl_VehicleRespawn ) -- vehicle explosion function cl_VehicleExplode ( ) local theOwner = getElementData ( source, "cl_vehicleowner" ) if ( theOwner ~= false ) then cl_RemoveVehicleOwner ( source ) end end addEventHandler ( "onVehicleExplode", getRootElement(), cl_VehicleExplode ) -- set vehicle owner function cl_SetVehicleOwner ( theVehicle, thePlayer ) local oldVehicle = getElementData ( thePlayer, "cl_ownedvehicle" ) if ( oldVehicle ~= false ) then -- unlock old car removeElementData ( oldVehicle, "cl_vehicleowner" ) removeElementData ( oldVehicle, "cl_vehiclelocked" ) removeElementData ( oldVehicle, "cl_enginestate" ) setVehicleLocked ( oldVehicle, false ) -- set vars for new car end setElementData ( theVehicle, "cl_vehicleowner", thePlayer ) setElementData ( theVehicle, "cl_vehiclelocked", false ) setElementData ( thePlayer, "cl_ownedvehicle", theVehicle ) setElementData( theVehicle, "cl_enginestate", true ) end function cl_RemoveVehicleOwner ( theVehicle ) local theOwner = getElementData ( theVehicle, "cl_vehicleowner" ) if ( theOwner ~= false ) then removeElementData ( theOwner, "cl_ownedvehicle" ) removeElementData ( theVehicle, "cl_vehicleowner" ) removeElementData ( theVehicle, "cl_vehiclelocked" ) removeElementData ( owned, "cl_enginestate" ) end setVehicleLocked ( theVehicle, false ) end -- flash the lights twice function cl_FlashLights ( thePlayer ) setTimer ( doToggleLights, 300, 4, thePlayer, true ) end -- flash once function cl_FlashOnce ( thePlayer ) setTimer ( doToggleLights, 300, 2, thePlayer, true ) end -- get vehicle owner ( according to vehicle's element data ) function cl_VehicleOwner ( theVehicle ) return getElementData( theVehicle, "cl_vehicleowner" ) end -- is vehicle locked ( according to vehicle's element data ) function cl_VehicleLocked ( theVehicle ) return getElementData( theVehicle, "cl_vehiclelocked" ) end -- messaging functions -- send red error message function Err_Msg ( strout, thePlayer ) outputChatBox ( strout, thePlayer, 200, 0, 10 ) end -- send message to all occupants of vehicle function Car_Msg ( strout, theVehicle ) numseats = getVehicleMaxPassengers ( theVehicle ) for s = 0, numseats do local targetPlayer = getVehicleOccupant ( theVehicle, s ) if targetPlayer ~= false then outputChatBox ( strout, targetPlayer, 30, 144, 255 ) end end end -- send aquamarine message to player function Info_Msg ( strout, thePlayer ) outputChatBox ( strout, thePlayer, 102, 205, 170 ) end -- commands function doToggleLocked ( 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 doUnlockVehicle ( source ) else doLockVehicle ( source ) end else Err_Msg("You must have a vehicle to lock or unlock it.", source) end end addEvent("doLockVehiclee", true) addEventHandler("doLockVehiclee", root, function( 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("undoLockVehiclee", true) addEventHandler("undoLockVehiclee", root, function ( 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 Link to comment
#Al-Ha[J]aRii Posted January 17, 2014 Share Posted January 17, 2014 شوف وش الحل مو راضي يشتغلclient: GUIEditor = { button = {}, window = {}, scrollbar = {}, label = {} } GUIEditor.window[1] = guiCreateWindow(313, 249, 384, 228, "", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(10, 185, 77, 28, "Engine", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(105, 185, 77, 28, "Lock", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(201, 185, 77, 28, "Unlock", false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(297, 185, 77, 28, "Light", false, GUIEditor.window[1]) GUIEditor.scrollbar[1] = guiCreateScrollBar(9, 27, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[2] = guiCreateScrollBar(9, 52, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[3] = guiCreateScrollBar(9, 77, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[4] = guiCreateScrollBar(9, 102, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[5] = guiCreateScrollBar(10, 127, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.scrollbar[6] = guiCreateScrollBar(10, 152, 201, 15, true, false, GUIEditor.window[1]) GUIEditor.label[1] = guiCreateLabel(215, 26, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[2] = guiCreateLabel(215, 51, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[3] = guiCreateLabel(215, 76, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[4] = guiCreateLabel(215, 101, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[5] = guiCreateLabel(215, 126, 159, 16, "", false, GUIEditor.window[1]) GUIEditor.label[6] = guiCreateLabel(215, 152, 159, 16, "", false, GUIEditor.window[1]) ---- open window "l" function openCloseWindow(player) if guiGetVisible(GUIEditor.window[1]) then guiSetVisible(GUIEditor.window[1], false) showCursor(false) else guiSetVisible(GUIEditor.window[1], true) showCursor(true) end end bindKey("l", "down", openCloseWindow) function onResourcestart() guiSetVisible(GUIEditor.window[1], false) showCursor(false) end addEventHandler("onClientResourceStart", getRootElement(), onResourcestart) ------- lock Vehicles --------- --[[ addEventHandler("onClientGUIClick", getRootElement(), function () if ( source == GUIEditor.button[2] ) then triggerServerEvent( "doLockVehiclee", getRootElement()) end end )]] function lockVehicles () triggerServerEvent( "doLockVehiclee", root) end addEventHandler("onClientGUIClick", GUIEditor.button[2], lockVehicles,false) --- unlock vehcles ------- function unlockVehicles () triggerServerEvent( "undoLockVehiclee", root) end addEventHandler("onClientGUIClick", GUIEditor.button[3], unlockVehicles,false) ---- Engine function unlockVehicles () triggerServerEvent( "doToggleEngine", root) end addEventHandler("onClientGUIClick", GUIEditor.button[1], unlockVehicles,false) -- Car Locks ( client ) -- local player localPlayer = getLocalPlayer ( ) -- playSoundNearElement addEvent ( "onPlaySoundNearElement", true ) function playSoundNearElement ( theElement, sound ) -- local sound = 5 local maxdist = 15.0 -- valid element if ( theElement ) then local x,y,z = getElementPosition ( theElement ) local x2,y2,z2 = getElementPosition ( localPlayer ) local dist = getDistanceBetweenPoints3D ( x, y, z, x2, y2, z2 ) -- distance is less than parameter maxdist if ( dist < maxdist ) then -- play parameter sound playSoundFrontEnd ( 5 ) -- outputChatBox ( "sound should play" ) else -- outputChatBox ( "not in range" ) end else -- outputChatBox ( "invalid element" ) end end addEventHandler ( "onPlaySoundNearElement", getRootElement(), playSoundNearElement ) server: -- ================= -- Car Locks ( server ) -- by vick. -- ================= -- player element data -- -- cl_ownedvehicle -- vehicle element data -- -- cl_vehicleowner -- cl_vehiclelocked -- cl_enginestate -- resource starts - ends function initCarLocks () -- Initilize Player Element Data local players = getElementsByType ( "player" ) for k,p in ipairs(players) do removeElementData ( p, "cl_ownedvehicle" ) bindKey ( p, "j", "down", doToggleLocked ) end -- Initilize Vehicle Element Data local vehicles = getElementsByType ( "vehicle" ) for k,v in ipairs(vehicles) do removeElementData ( v, "cl_vehicleowner" ) removeElementData ( v, "cl_vehiclelocked" ) removeElementData ( v, "cl_enginestate" ) setVehicleLocked ( v, false ) setVehicleOverrideLights ( v, 0 ) end end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource () ), initCarLocks ) addEventHandler ( "onResourceStop", getResourceRootElement ( getThisResource () ), initCarLocks ) -- player joins function cl_PlayerJoin ( ) bindKey ( source, "k", "down", doToggleLocked ) end addEventHandler ( "onPlayerJoin", getRootElement(), cl_PlayerJoin ) -- player quits function cl_PlayerQuit ( ) -- check for owned car local ownedVehicle = getElementData ( source, "cl_ownedvehicle" ) if (ownedVehicle ~= false) then cl_RemoveVehicleOwner ( ownedVehicle ) end end addEventHandler ( "onPlayerQuit", getRootElement(), cl_PlayerQuit ) -- player dies function cl_PlayerWasted ( ) -- check for owned car local ownedVehicle = getElementData ( source, "cl_ownedvehicle" ) if (ownedVehicle ~= false) then cl_RemoveVehicleOwner ( ownedVehicle ) end end addEventHandler ( "onPlayerWasted", getRootElement(), cl_PlayerWasted ) -- player tries to enter vehicle function cl_VehicleStartEnter ( enteringPlayer, seat, jacked ) local theVehicle = source local theOwner -- locked and not owner entering if ( getElementData ( theVehicle, "cl_vehiclelocked" ) == true ) then theOwner = getElementData ( theVehicle, "cl_vehicleowner" ) if theOwner ~= false and theOwner ~= enteringPlayer then -- make sure they dont enter --cancelEvent(); end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), cl_VehicleStartEnter ) -- player enters a vehicle function cl_PlayerDriveVehicle ( player, seat, jacked ) -- Driver Enter if ( seat == 0 ) then oldVehicle = getElementData ( player, "cl_ownedvehicle" ) -- not entering player's own owned vehicle if ( (cl_VehicleLocked(source) == true) and (cl_VehicleOwner(source) ~= player) ) then removePlayerFromVehicle( player ) Err_Msg("this vehicle is locked.", player) return false end -- set element data for vehicle and owner cl_SetVehicleOwner ( source, player ) end return true end addEventHandler ( "onVehicleEnter", getRootElement(), cl_PlayerDriveVehicle ) -- vehicle respawns function cl_VehicleRespawn ( exploded ) cl_RemoveVehicleOwner ( source ) end addEventHandler ( "OnVehicleRespawn", getRootElement(), cl_VehicleRespawn ) -- vehicle explosion function cl_VehicleExplode ( ) local theOwner = getElementData ( source, "cl_vehicleowner" ) if ( theOwner ~= false ) then cl_RemoveVehicleOwner ( source ) end end addEventHandler ( "onVehicleExplode", getRootElement(), cl_VehicleExplode ) -- set vehicle owner function cl_SetVehicleOwner ( theVehicle, thePlayer ) local oldVehicle = getElementData ( thePlayer, "cl_ownedvehicle" ) if ( oldVehicle ~= false ) then -- unlock old car removeElementData ( oldVehicle, "cl_vehicleowner" ) removeElementData ( oldVehicle, "cl_vehiclelocked" ) removeElementData ( oldVehicle, "cl_enginestate" ) setVehicleLocked ( oldVehicle, false ) -- set vars for new car end setElementData ( theVehicle, "cl_vehicleowner", thePlayer ) setElementData ( theVehicle, "cl_vehiclelocked", false ) setElementData ( thePlayer, "cl_ownedvehicle", theVehicle ) setElementData( theVehicle, "cl_enginestate", true ) end function cl_RemoveVehicleOwner ( theVehicle ) local theOwner = getElementData ( theVehicle, "cl_vehicleowner" ) if ( theOwner ~= false ) then removeElementData ( theOwner, "cl_ownedvehicle" ) removeElementData ( theVehicle, "cl_vehicleowner" ) removeElementData ( theVehicle, "cl_vehiclelocked" ) removeElementData ( owned, "cl_enginestate" ) end setVehicleLocked ( theVehicle, false ) end -- flash the lights twice function cl_FlashLights ( thePlayer ) setTimer ( doToggleLights, 300, 4, thePlayer, true ) end -- flash once function cl_FlashOnce ( thePlayer ) setTimer ( doToggleLights, 300, 2, thePlayer, true ) end -- get vehicle owner ( according to vehicle's element data ) function cl_VehicleOwner ( theVehicle ) return getElementData( theVehicle, "cl_vehicleowner" ) end -- is vehicle locked ( according to vehicle's element data ) function cl_VehicleLocked ( theVehicle ) return getElementData( theVehicle, "cl_vehiclelocked" ) end -- messaging functions -- send red error message function Err_Msg ( strout, thePlayer ) outputChatBox ( strout, thePlayer, 200, 0, 10 ) end -- send message to all occupants of vehicle function Car_Msg ( strout, theVehicle ) numseats = getVehicleMaxPassengers ( theVehicle ) for s = 0, numseats do local targetPlayer = getVehicleOccupant ( theVehicle, s ) if targetPlayer ~= false then outputChatBox ( strout, targetPlayer, 30, 144, 255 ) end end end -- send aquamarine message to player function Info_Msg ( strout, thePlayer ) outputChatBox ( strout, thePlayer, 102, 205, 170 ) end -- commands function doToggleLocked ( 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 doUnlockVehicle ( source ) else doLockVehicle ( source ) end else Err_Msg("You must have a vehicle to lock or unlock it.", source) end end addEvent("doLockVehiclee", true) addEventHandler("doLockVehiclee", root, function( 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("undoLockVehiclee", true) addEventHandler("undoLockVehiclee", root, function ( source ) local theVehicle, strout if ( getElementType(source) == "vehicle" ) then theVehicle = source end if ( getElementType(source) == "player" ) then theVehicle = getElementData ( source, "cl_ownedvehicle" ) end 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