Jump to content

Vehicle lower name


DarkByte

Recommended Posts

Hi i made this script but its not working.

function getVehicleModelFromName(vehId) 
    local vehiclen = getVehicleModelFromName(vehID) 
    if vehiclen then 
        return vehiclen 
    end 
    for _,vehiclen in ipairs(getElementsByType("vehicle")) do 
        if string.find(string.gsub(getVehicleModelFromName(vehId):lower(),"#%x%x%x%x%x%x", ""), getVehicleModelFromName:lower(), 1, true) then 
            return vehiclen 
        end 
    end 
return false 
end 
  

Link to comment
getVehicleNameFromModel_ = getVehicleNameFromModel 
  
function getVehicleNameFromModel(vehID) 
    local vehiclen = getVehicleNameFromModel_(vehID) 
    if vehiclen then 
        return vehiclen:lower() 
    end 
    return false 
end 

OR try to explain better.

Link to comment

I want to create vehicles by a lower name and get them from tables and then insert the script in this one.

function createVehicleCommand(cmd, ...) 
    local vehID 
    local vehiclesToCreate = {} 
    local elem = getPedOccupiedVehicle(g_Me) 
    local args = { ... } 
    for i,v in ipairs(args) do 
        vehID = tonumber(v) 
        if not vehID then 
            vehID = getVehicleModelFromName(v) 
        end 
        if elem then 
        errMsg('• Please leave the vehicle to create another one!') 
        return 
        end 
        if vehID then 
            table.insert(vehiclesToCreate, math.floor(vehID)) 
        end 
    end 
    server.giveMeVehicles(vehiclesToCreate) 
end 
addCommandHandler('createvehicle', createVehicleCommand) 
addCommandHandler('cv', createVehicleCommand) 

Link to comment

This?

function createVehicleCommand(cmd, ...) 
    local vehiclesToCreate = {} 
    local args = { ... } 
    local vehID = tonumber(args[1]) 
    if getPedOccupiedVehicle(g_Me) then 
        return errMsg('• Please leave the vehicle to create another one!') 
    end 
    if not vehID then 
        for i=400, 611 do 
            if getVehicleNameFromModel(i):lower():find(table.concat(args, ", "):lower(), 1, true) then 
                vehID = i 
                break 
            end 
        end 
    end 
    if vehID then 
        table.insert(vehiclesToCreate, math.floor(vehID)) 
    end 
    server.giveMeVehicles(vehiclesToCreate) 
end 
addCommandHandler('createvehicle', createVehicleCommand) 
addCommandHandler('cv', createVehicleCommand) 

Link to comment

How to make weapons lower name?

function giveWeaponCommand(cmd, weapon, amount) 
    weapon = tonumber(weapon) or getWeaponIDFromName(weapon) 
    if not weapon then 
        return 
    end 
    amount = amount and tonumber(amount) or 500 
    server.giveMeWeapon(math.floor(weapon), amount) 
end 
addCommandHandler('give', giveWeaponCommand) 
addCommandHandler('wp', giveWeaponCommand) 

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