johhnhd Posted March 3, 2013 Share Posted March 3, 2013 I'm stuck on finding a script to lock cars to players(usernames). I'm hoping someone can point me in the right direction cheers:) Link to comment
iPrestege Posted March 3, 2013 Share Posted March 3, 2013 What? With User Name ? Not Available. But You Can Edit One# Link to comment
johhnhd Posted March 3, 2013 Author Share Posted March 3, 2013 What? With User Name ? Not Available.But You Can Edit One# All I want to do is lock or edit a car that only the person who can use it is the one who is locked/edited to it. Link to comment
Ab-47 Posted March 3, 2013 Share Posted March 3, 2013 function lockTheVeh ( thePlayer ) local player = getPlayerFromName(Username) playervehicle = getPlayerOccupiedVehicle ( thePlayer ) if ( playervehicle ) then if (Username) then if not isVehicleLocked ( playervehicle ) then setVehicleLocked ( playervehicle, true ) end end end end addCommandHandler ( "lock", lockTheVeh ) Not tested Link to comment
PaiN^ Posted March 3, 2013 Share Posted March 3, 2013 function lockTheVeh ( thePlayer ) local player = getPlayerFromName(Username) playervehicle = getPlayerOccupiedVehicle ( thePlayer ) if ( playervehicle ) then if (Username) then if not isVehicleLocked ( playervehicle ) then setVehicleLocked ( playervehicle, true ) end end end end addCommandHandler ( "lock", lockTheVeh ) Not tested getPlayerFromName gets a player by his name, Not his username .. you should use getPlayerAccount and getAccountName .. Link to comment
johhnhd Posted March 3, 2013 Author Share Posted March 3, 2013 function lockTheVeh ( thePlayer ) local player = getPlayerFromName(Username) playervehicle = getPlayerOccupiedVehicle ( thePlayer ) if ( playervehicle ) then if (Username) then if not isVehicleLocked ( playervehicle ) then setVehicleLocked ( playervehicle, true ) end end end end addCommandHandler ( "lock", lockTheVeh ) Not tested Is this /lock or like when you spawn and go up to it you can only enter if youre that user Link to comment
Ab-47 Posted March 4, 2013 Share Posted March 4, 2013 function lockTheVeh ( thePlayer ) local player = getPlayerFromName(Username) playervehicle = getPlayerOccupiedVehicle ( thePlayer ) if ( playervehicle ) then if (Username) then if not isVehicleLocked ( playervehicle ) then setVehicleLocked ( playervehicle, true ) end end end end addCommandHandler ( "lock", lockTheVeh ) Not tested Is this /lock or like when you spawn and go up to it you can only enter if youre that user If there's a guy called: "Username" and you type /lock the car he's in will be locked. Link to comment
Ab-47 Posted March 4, 2013 Share Posted March 4, 2013 function lockTheVeh ( thePlayer ) local player = getPlayerFromName(Username) playervehicle = getPlayerOccupiedVehicle ( thePlayer ) if ( playervehicle ) then if (Username) then if not isVehicleLocked ( playervehicle ) then setVehicleLocked ( playervehicle, true ) end end end end addCommandHandler ( "lock", lockTheVeh ) Not tested Is this /lock or like when you spawn and go up to it you can only enter if youre that user If there's a guy called: "Username" and you type /lock the car he's in will be locked. You can also add people's usernames and get the data. Like setElementData ( thePlayer, "Username", "TheUsername" ) or local TheUsername = etc.. setElementData ( thePlayer, "Username", ..TheUsername When the player logs in from the login panel his data will be set, make sure you define: TheUsername or enter the players username.. then for the locker script you could use: function lockTheVeh ( thePlayer ) local player = getPlayerFromName(Username) playervehicle = getPlayerOccupiedVehicle ( thePlayer ) if ( playervehicle ) then if (getElementData (thePlayer, "Username") == "TheUsername" ) then if not isVehicleLocked ( playervehicle ) then setVehicleLocked ( playervehicle, true ) end end end end addCommandHandler ( "lock", lockTheVeh ) Link to comment
johhnhd Posted March 4, 2013 Author Share Posted March 4, 2013 Ok thanks I will test now 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