Jump to content

one question


mjau

Recommended Posts

Now i have gotten a bit into scripting bur i still wonders how and what commands should i use to make a script wich you can lock cars to accounts? like in saes if you donate you get a car locked to your account if someone could tell me the comands i should use i will be happy becas many people in my server want a car LOL

Link to comment

Well, you could create a vehicle and then set an element data on it, like "Owner", "Solidsnake14", and then when he tryies to enter the vehicle, if the account name is equal to "Owner" data from the vehicle, he will able to drive it, else it will output some message.

functions required for this:

  
createVehicle 
setElementData 
getElementData 
getPlayerAccount 
getAccountName 
getAccountData 
cancelEvent() - Required to cancel the player from entering the vehicle. 

events required for this:

onVehicleStartEnter 

Good luck.

Link to comment

Ftw is wrong with this im still a noob LOL

function lockcar() 
    local x = -682.4951171875 
    local y = 952.8115234375 
    local z = 12.1328125     
    createVehicle(source, x, y, z) 
    setElementData(owner "kimmis9") 
    end  
addEventHandler("onClientResourceStart", getRootElement(), lockcar] 

Link to comment

Try this.

function lockcar ( ) 
    local x = -682.4951171875 
    local y = 952.8115234375 
    local z = 12.1328125   
    createVehicle ( 432, x, y, z ) 
    setElementData ( getLocalPlayer(), 'kimmis9' ) 
end 
addEventHandler ( 'onClientResourceStart', resourceRoot, lockcar ) 
  

Link to comment

Omg, proracer, i can't really understand how you did such thing...

function lockcar ( ) 
    local x = -682.4951171875 
    local y = 952.8115234375 
    local z = 12.1328125   
    myVehicle = createVehicle ( 432, x, y, z ) 
    setElementData ( myVehicle, "owner", 'kimmis9' ) 
end 
addEventHandler ( 'onClientResourceStart', getResourceRootElement(getThisResource()), lockcar ) 

Link to comment
function lockcar ( ) 
    local x = -682.4951171875 
    local y = 952.8115234375 
    local z = 12.1328125   
    myVehicle = createVehicle ( 432, x, y, z ) 
    setElementData ( myVehicle, "owner", 'kimmis9' ) 
end 
addEventHandler ( 'onClientResourceStart', getResourceRootElement(getThisResource()), lockcar ) 

function lockca2 (veh ) 
    if getElementData(veh, "owner") ~= getAccountName(getPlayerAccount(source)) then 
         cancelEvent() 
    end 
end 
addEventHandler ( 'onVehicleEnter', getRootElement(), lockca2 ) 
  

You could also just automatically lock the doors (client side)

Link to comment

Probably because you have to be at those co-ordinates, try this:

function lockcar ( ) 
    local x,y,z = getElementPosition(getLocalPlayer())  
    myVehicle = createVehicle ( 432, x, y+2, z ) 
    setElementData ( myVehicle, "owner", 'kimmis9' ) 
end 
addEventHandler ( 'onClientResourceStart', getResourceRootElement(getThisResource()), lockcar ) 

Link to comment
vehicle = createVehicle ( 411, -682.4951171875, 952.8115234375, 12.1328125   ) 
setElementData(vehicle, "owner", "kimmis9") 
  
function enterOwnedVehicle ( player, seat, jacked ) 
    if getElementData(source, "owner") and getElementData(source, "owner" ) ~= getPlayerName(player) then 
        outputChatBox ( "Vehicle owner: "..tostring(getElementData(source, "owner" )), player, 255, 0, 0 ) 
        cancelEvent() 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterOwnedVehicle ) 

This should work (not tested)

it is server-side btw.

Edited by Guest
Link to comment

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