Jump to content

one question


mjau

Recommended Posts

Posted

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

n-560x95_E60303_FFFFFF_030303_FF0303.png
Posted

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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] 

n-560x95_E60303_FFFFFF_030303_FF0303.png
Posted

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 ) 
  

Posted

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 ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Proracer, you ever say the same :roll:

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • MTA Team
Posted
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)

Posted

Qais, the point was to let him learn -_-.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 ) 

Posted (edited)
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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

My bad, i forgot something, try it now.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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