Jump to content

[HELP]Private car


Chaos

Recommended Posts

hi

i have problem with this code i want to lock the car for group but event onvehiclestartenter not working i don't know why and can anyone enter to vehicle.

  
veh = {} 
function car(player, command, arg1) 
         local accName = getAccountName ( getPlayerAccount ( player ) ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Vip" ) ) then  
        local x, y, z = getElementPosition(player) 
        if veh[player] then 
            destroyElement(veh[player]) 
        end 
        veh[player] = createVehicle(597, x, y, z) 
            setVehicleDamageProof(veh[player], true) 
            addVehicleUpgrade ( veh[player], 1010 ) 
end 
end 
      
    addCommandHandler("mycar", car) 
  
function enterVehicle(enteringPlayer,seat) 
  
    if seat == 0 and  source == veh[player] then 
             
         local accName = getAccountName ( getPlayerAccount ( enteringPlayer ) ) 
         if not isObjectInACLGroup ("user."..accName, aclGetGroup ( "Vip" ) ) then  
  
                     
         cancelEvent() 
         outputChatBox("This is a private car you can't steal it !",enteringPlayer,255,0,0) 
         end 
end 
end 
  
    addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 
     

Link to comment
local veh = { } 
local vehicles = { } 
  
function car ( player, command, arg1 ) 
    local accName = getAccountName ( getPlayerAccount ( player ) ) 
     if isObjectInACLGroup ( "user.".. accName, aclGetGroup ( "Vip" ) ) then 
        local x, y, z = getElementPosition ( player ) 
        if veh [ player ] then 
            vehicles [ veh [ player ] ] = nil 
            destroyElement ( veh [ player ] ) 
        end 
        veh [ player ] = createVehicle ( 597, x, y, z ) 
        setVehicleDamageProof ( veh [ player ], true ) 
        addVehicleUpgrade ( veh [ player ], 1010 ) 
        vehicles [ veh [ player ] ] = accName 
    end 
end 
addCommandHandler ( "mycar", car ) 
  
function enterVehicle ( enteringPlayer, seat ) 
    if ( seat == 0 and vehicles [ source ] ) then 
        local accName = getAccountName ( getPlayerAccount ( enteringPlayer ) ) 
        if ( vehicles [ source ] == accName ) then 
            cancelEvent ( ) 
            outputChatBox ( "This is a private car you can't steal it !", enteringPlayer, 255, 0, 0 ) 
        end 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 

Is that what you meant?

Link to comment
local veh = { } 
local vehicles = { } 
  
function car ( player, command, arg1 ) 
    local accName = getAccountName ( getPlayerAccount ( player ) ) 
    if isObjectInACLGroup ( "user.".. accName, aclGetGroup ( "Vip" ) ) then 
        local x, y, z = getElementPosition ( player ) 
        if veh [ player ] then 
            vehicles [ veh [ player ] ] = nil 
            destroyElement ( veh [ player ] ) 
        end 
        veh [ player ] = createVehicle ( 597, x, y, z ) 
        setVehicleDamageProof ( veh [ player ], true ) 
        addVehicleUpgrade ( veh [ player ], 1010 ) 
        vehicles [ veh [ player ] ] = accName 
    end 
end 
addCommandHandler ( "mycar", car ) 
  
function enterVehicle ( enteringPlayer, seat ) 
    if ( seat == 0 and vehicles [ source ] ) then 
        local accName = getAccountName ( getPlayerAccount ( enteringPlayer ) ) 
        if ( not isObjectInACLGroup ( "user.".. accName, aclGetGroup ( "Vip" ) ) ) then 
            cancelEvent ( ) 
            outputChatBox ( "This is a private car you can't steal it !", enteringPlayer, 255, 0, 0 ) 
        end 
    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...