User:Stryp: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "== Some useful functions (for me at least) == Deleting colorcodes from whatever (bigbig thanks for '''eeew''') <syntaxhighlight lang="lua">function noColors(input) return input:gsub("#%x%x%x%x%x%...")
 
Line 4: Line 4:
isVehicleLockable by me
isVehicleLockable by me
<syntaxhighlight lang="lua">function isVehicleLockable (vehicle)
<syntaxhighlight lang="lua">function isVehicleLockable (vehicle)
     local lockableVehicles = {594, 606, 607, 611, 584, 608, 435, 450, 591, 539, 441, 464, 501, 465, 564, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454, 581, 509, 481, 462, 521, 463, 510, 522, 461, 448, 468, 586, 425, 520}
     local notLockableVehicles = {594, 606, 607, 611, 584, 608, 435, 450, 591, 539, 441, 464, 501, 465, 564, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454, 581, 509, 481, 462, 521, 463, 510, 522, 461, 448, 468, 586, 425, 520}
     local itsLockable = false
    -- Table for lockable vehicles, 100% from me :D
     local myVehicle = getElementModel(vehicle)
    -- Maybe I missed some vehicles, feel free to edit it.
     for k, lockableVehicle in pairs(lockableVehicles) do
     local itsLockable = true -- At start, the vehicle is lockable.
         if myVehicle == lockableVehicle then
     local myVehicle = getElementModel(vehicle) -- Get the model ID of the vehicle to work with it.
             itsLockable = true
     for k, notLockableVehicle in pairs(notLockableVehicles) do -- Do for every notlockable vehicles
             return true
         if myVehicle == notLockableVehicle then -- If the vehicle inputted is a not lockable vehicle
             itsLockable = false -- Then its not lockable
             return false -- So return false, it isn't lockable
         end
         end
     end
     end
     if itsLockable == false then
     if itsLockable == true then -- If we didn't set it to false before, then its lockable,
         return false
         return true -- So return true.
     end
     end
    -- By Stryp
end</syntaxhighlight>
end</syntaxhighlight>
More will come...
More will come...

Revision as of 09:22, 22 April 2011

Some useful functions (for me at least)

Deleting colorcodes from whatever (bigbig thanks for eeew)

function noColors(input) return input:gsub("#%x%x%x%x%x%x","") end

isVehicleLockable by me

function isVehicleLockable (vehicle)
    local notLockableVehicles = {594, 606, 607, 611, 584, 608, 435, 450, 591, 539, 441, 464, 501, 465, 564, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454, 581, 509, 481, 462, 521, 463, 510, 522, 461, 448, 468, 586, 425, 520}
    -- Table for lockable vehicles, 100% from me :D
    -- Maybe I missed some vehicles, feel free to edit it.
    local itsLockable = true -- At start, the vehicle is lockable.
    local myVehicle = getElementModel(vehicle) -- Get the model ID of the vehicle to work with it.
    for k, notLockableVehicle in pairs(notLockableVehicles) do -- Do for every notlockable vehicles
        if myVehicle == notLockableVehicle then -- If the vehicle inputted is a not lockable vehicle
            itsLockable = false -- Then its not lockable
            return false -- So return false, it isn't lockable
        end
    end
    if itsLockable == true then -- If we didn't set it to false before, then its lockable,
        return true -- So return true.
    end
    -- By Stryp
end

More will come...