Play3rPL Posted August 9, 2015 Share Posted August 9, 2015 Hello! Thanks for coming here. First at all, let me say that my English is not perfect, so it can be bad sometimes. Okay. I am asking You for help with two things: 1#: Unlocking locked vehicle outside it. Look: I made my own script for my RPG server; it allows You to enable lights using ; key, engine using K, enable Freeze-aka-handbrake using RCTRL, and lock vehicle using L key. Only driver can perform these things. So, there is my question: When car is locked, and You will exit that, You cannot unlock it anymore. I want to make script, that will allow You to unlock it, when ped is standing next to driver's doors using L key again. How can I script that? I have been thinking of making an INVISIBLE marker, next to driver's door. When ped will stay at it, he is able to unlock it using L key. Marker could be done by taking vehicle's x, y, z, and adding some numbers to x/y. But how can I do it invisible? VisibleTo function, or anything else? And how Can I cause unlock by using L? 2#: Turn signals. It's kinda important thing for RPG servers. Actually, I have no clue about making them. Using SetLightState probably, but I'm do not understand the use of them. -------------------------------- I am NOT asking for ready code; I'm asking for help and some clues about doing these things. Here's my actual code. I'm going to show it also to prove, that I actually did something: -------------------------------------- KONTROLKI - 8.0 local root = getRootElement () local thisResourceRoot = getResourceRootElement(getThisResource()) function thisResourceStart () local players = getElementsByType ( "player" ) for k,v in ipairs(players) do bindKey ( v, ";", "down", toggleVehicleLights, "Lights on/off" ) bindKey ( v, "k", "down", toggleVehicleEngine, "Engine on/off" ) bindKey ( v, "rctrl", "down", toggleVehicleHandbrake, "Handbrake on/off") bindKey ( v, "l", "down", toggleVehicleLock, "Doors locked/unlocked") end end function playerJoin () bindKey ( v, ";", "down", toggleVehicleLights, "Lights on/off" ) bindKey ( v, "k", "down", toggleVehicleEngine, "Engine on/off" ) bindKey ( v, "rctrl", "down", toggleVehicleHandbrake, "Handbrake on/off") bindKey ( v, "l", "down", toggleVehicleLock, "Doors locked/unlocked") end addEventHandler ( "onResourceStart", thisResourceRoot, thisResourceStart ) addEventHandler ( "onPlayerJoin", root, playerJoin ) -- Lampy function toggleVehicleLights ( player, key, state ) if ( getPedOccupiedVehicleSeat ( player ) == 0 ) then local veh = getPedOccupiedVehicle ( player ) if ( getVehicleOverrideLights ( veh ) ~= 2 ) then setVehicleOverrideLights ( veh, 2 ) outputChatBox ( "Światła Włączone!", player, 0, 255, 0 ) else setVehicleOverrideLights ( veh, 1 ) outputChatBox ( "Światła Wyłączone!", player, 255, 0, 0 ) end end end -- Silnik function toggleVehicleEngine ( player, key, state ) if ( getPedOccupiedVehicleSeat ( player ) == 0 ) then local veh = getPedOccupiedVehicle ( player ) if ( getVehicleEngineState ( veh ) == true ) then setVehicleEngineState ( veh, false ) outputChatBox ( "Silnik Wyłączony!", player, 255, 0, 0 ) else setVehicleEngineState ( veh, true ) outputChatBox ( "Silnik Włączony!", player, 0, 255, 0 ) end end end -- Ręczny function toggleVehicleHandbrake ( player, key, state ) if ( getPedOccupiedVehicleSeat ( player ) == 0 ) then local veh = getPedOccupiedVehicle ( player ) local speed = getElementVelocity ( veh ) if ( speed == 0 ) then if ( isElementFrozen ( veh ) == false ) then setElementFrozen ( veh, true ) outputChatBox ( "Ręczny Zaciągnięty!", player, 255, 0, 0 ) else setElementFrozen ( veh, false ) outputChatBox ( "Ręczny Spuszczony!", player, 0, 255, 0 ) end else setControlState( player, handbrake, true) end end end -- Zamek function toggleVehicleLock ( player, key, state ) if ( getPedOccupiedVehicleSeat ( player ) == 0 ) then local veh = getPedOccupiedVehicle ( player ) if ( isVehicleLocked( veh ) == false ) then setVehicleLocked ( veh, true ) outputChatBox ( "Pojazd Zamknięty!", player, 255, 0, 0 ) else setVehicleLocked ( veh, false ) outputChatBox ( "Pojazd Otwarty!", player, 0, 255, 0 ) end end end I'm sorry for Polish chat outputs and --s; script is done one hundred % by me. Thanks, again, for any help! Cheers, Play3rPL Link to comment
lolman Posted August 9, 2015 Share Posted August 9, 2015 This function : createMarker Has already an argument which contains the alpha of the marker with the letter : a. About signals, you can take a look at community.multitheftauto.com and search there and take a look into the code how it's done Link to comment
Play3rPL Posted August 9, 2015 Author Share Posted August 9, 2015 Ty for help! Oh, You are right! So, all that I have to do is a=0? Seems easy. Thank You! What about turn signals? Any help in this aspect? Cheerz Link to comment
lolman Posted August 9, 2015 Share Posted August 9, 2015 Youre welcome. About the signals, maybe you could attach small markers on every side of a vehicle and when you press a button the markers on a purposed side show up (have seen this idea on an another server) but the choice is up to you... Link to comment
Play3rPL Posted August 9, 2015 Author Share Posted August 9, 2015 Hi again, I have been thinking of using standard vehicle lights, that would be enabling and disabling continuouslyafter ppressing binded key. Any idea of making that? Link to comment
Dealman Posted August 9, 2015 Share Posted August 9, 2015 You can achieve turn signals by using shaders. Simply put you'd replace the lights using 2 textures, and of course you'd have to sync this between players. Quite the little project . As for replacing the textures, should be fairly straight forward - just search a little about shaders and you'll find what you need. Otherwise if you want to keep it easy, just look at the MTA Wiki vehicle functions and maybe you can spot something interesting. 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