Jump to content

Script doest work


Newbie

Recommended Posts

As you see when i buy a car i should be a owner so nobody can drive car.

But when i test it with other acc's it fails. Looks like that script does't work as it should

No errors At DS3

function BuyTractor () 
    local money = getPlayerMoney(source) 
    if (money > 5000) then   
    takePlayerMoney(source,5000) 
    local vehicleModel = 411 
    local x,y,z = getElementPosition(source) 
    y = y + 5 
    local veh = createVehicle(tonumber(vehicleModel),x,y,z) 
    setElementData(veh, "owner", source) 
    else 
    outputChatBox ( "* Earn more OP (Oil Points) to buy this vehicle", source, 255, 255, 255, true ) 
end 
end 
addEvent("Car1",true) 
addEventHandler( "Car1", getRootElement(), BuyTractor ) 
  
function enterVehicle ( player, seat, jacked ) --when a player enters a vehicle 
    if ( getElementData(source, "owner")  and player ~= getElementData(source, "owner") ) then 
        cancelEvent() 
        outputChatBox ( "You don't have the keys for this vehicle", player ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 

Link to comment
  
function BuyTractor () 
    local money = getPlayerMoney(source) 
    if (money > 5000) then   
    takePlayerMoney(source,5000) 
    local vehicleModel = 411 
    local x,y,z = getElementPosition(source) 
    y = y + 5 
    local veh = createVehicle(tonumber(vehicleModel),x,y,z) 
    setElementData(veh, "owner", getPlayerName(source)) 
    else 
    outputChatBox ( "* Earn more OP (Oil Points) to buy this vehicle", source, 255, 255, 255, true ) 
end 
end 
addEvent("Car1",true) 
addEventHandler( "Car1", getRootElement(), BuyTractor ) 
  
function enterVehicle ( player, seat, jacked ) --when a player enters a vehicle 
    if ( getElementData(source, "owner")  and getPlayerName(player) ~= getElementData(source, "owner") ) then 
        cancelEvent() 
        outputChatBox ( "You don't have the keys for this vehicle", player ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 
  

Link to comment
  
function BuyTractor () 
    local money = getPlayerMoney(source) 
    if (money > 5000) then   
    takePlayerMoney(source,5000) 
    local vehicleModel = 411 
    local x,y,z = getElementPosition(source) 
    y = y + 5 
    local veh = createVehicle(tonumber(vehicleModel),x,y,z) 
    setElementData(veh, "owner", getPlayerName(source)) 
    else 
    outputChatBox ( "* Earn more OP (Oil Points) to buy this vehicle", source, 255, 255, 255, true ) 
end 
end 
addEvent("Car1",true) 
addEventHandler( "Car1", getRootElement(), BuyTractor ) 
  
function enterVehicle ( player, seat, jacked ) --when a player enters a vehicle 
    if ( getElementData(source, "owner")  and getPlayerName(player) ~= getElementData(source, "owner") ) then 
        cancelEvent() 
        outputChatBox ( "You don't have the keys for this vehicle", player ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 
  

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