User:Stryp: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
== Deleting colorcodes from whatever (thanks for '''eeew''') ==
== Deleting colorcodes from whatever (thanks for '''eeew''') ==
<syntaxhighlight lang="lua">function noColors(input) return input:gsub("#%x%x%x%x%x%x","") end</syntaxhighlight>
<syntaxhighlight lang="lua">function noColors(input)return input:gsub("#%x%x%x%x%x%x","")end</syntaxhighlight>
== isVehicleLockable by me ==
== isVehicleLockable by me ==
<syntaxhighlight lang="lua">function isVehicleLockable (vehicle)
<syntaxhighlight lang="lua">function isVehicleLockable (vehicle)
Line 6: Line 6:
     -- Table for lockable vehicles, 100% from me :D
     -- Table for lockable vehicles, 100% from me :D
     -- Maybe I missed some vehicles, feel free to edit it.
     -- 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.
     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
     for k, notLockableVehicle in pairs(notLockableVehicles) do -- Do for every notlockable vehicle
         if myVehicle == notLockableVehicle then -- If the vehicle inputted is a not lockable vehicle
         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
             return false -- So return false, it isn't lockable
         end
         end
     end
     end
     if itsLockable == true then -- If we didn't set it to false before, then its lockable,
     return true -- If we didn't return false before, then it's lockable so return true.
        return true -- So return true.
     end
     end
     -- By Stryp
     -- By Stryp
Line 39: Line 36:
<syntaxhighlight lang="lua"> notValidSkins = {1,2,3,4,5,6,8,42,65,74,86,119,149,208,217,265,266,267,268,269,270,271,272,273} </syntaxhighlight>
<syntaxhighlight lang="lua"> notValidSkins = {1,2,3,4,5,6,8,42,65,74,86,119,149,208,217,265,266,267,268,269,270,271,272,273} </syntaxhighlight>


== Clientsided position getting with /pos in chat or pos in console ==
== Serversided /pos command to show player position ==
<syntaxhighlight lang="lua">addCommandHandler("pos",function() local x,y,z = getElementPosition(getLocalPlayer())
<syntaxhighlight lang="lua">addCommandHandler("pos",function(p)local x,y,z=getElementPosition(p)outputChatBox(tonumber(("%.5f"):format(x))..", #00FF00"..tonumber(("%.5f"):format(y))..", #00FFFF"..tonumber(("%.5f"):format(z)),p,255,0,0,true)end)</syntaxhighlight>
outputChatBox("#ff0000"..x.." #ffff00"..y.." #00ff00"..z,0,255,0,true) end,false)</syntaxhighlight>
 
== Serversided command to give admins an NRG-500 or Infernus ==
<syntaxhighlight lang="lua">for k,v in ipairs(getElementsByType("player"))do setElementData(v,"s_c",nil)end
addCommandHandler("anrg",function(p)if not hasObjectPermissionTo(p,"command.kick",false)then return end local x,y,z=getElementPosition(p)if not getElementData(p,"s_c")then local v=createVehicle(522,x,y,z)setElementData(p,"s_c",v)warpPedIntoVehicle(p,v)else local v=getElementData(p,"s_c")fixVehicle(v)setElementModel(v,522)setElementPosition(v,x,y,z)warpPedIntoVehicle(p,v)end end)
addCommandHandler("acar",function(p)if not hasObjectPermissionTo(p,"command.kick",false)then return end local x,y,z=getElementPosition(p)if not getElementData(p,"s_c")then local v=createVehicle(411,x,y,z)setElementData(p,"s_c",v)warpPedIntoVehicle(p,v)else local v=getElementData(p,"s_c")fixVehicle(v)setElementModel(v,411)setElementPosition(v,x,y,z)warpPedIntoVehicle(p,v)end end)</syntaxhighlight>
Add all 3 lines for the script to work. If you spawn an NRG, then you leave it, you can later type /anrg to get your original NRG-500 fixed to you. If you had an NRG and now want an Infernus, just simply type in /acar and it will convert the NRG to an Infernus for you.
The script has a built-in check so you don't need to worry about giving everyone free NRG's and Infernuses.

Latest revision as of 13:10, 16 August 2014

Deleting colorcodes from whatever (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 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 vehicle
        if myVehicle == notLockableVehicle then -- If the vehicle inputted is a not lockable vehicle
            return false -- So return false, it isn't lockable
        end
    end
    return true -- If we didn't return false before, then it's lockable so return true.
    end
    -- By Stryp
end

Some announce-like function to write to every players screen

function showTextDisplay(player,command,...)
local display = textCreateDisplay()
local ann = table.concat(arg," ")
for k,v in ipairs(getElementsByType("player")) do
textDisplayAddObserver(display,v)
end
txt = textCreateTextItem(ann,0.01,0.95,"low",0,255,0,255,3)
textDisplayAddText(display,txt)
setTimer(textDisplayRemoveText,10000,1,display,txt)
setTimer(textDestroyDisplay,10000,1,display)
end
addCommandHandler("ann",showTextDisplay,true,false)

Server-side, can be used without command handler Need to add right to ACL to get it working

Not valid skin-ids

 notValidSkins = {1,2,3,4,5,6,8,42,65,74,86,119,149,208,217,265,266,267,268,269,270,271,272,273} 

Serversided /pos command to show player position

addCommandHandler("pos",function(p)local x,y,z=getElementPosition(p)outputChatBox(tonumber(("%.5f"):format(x))..", #00FF00"..tonumber(("%.5f"):format(y))..", #00FFFF"..tonumber(("%.5f"):format(z)),p,255,0,0,true)end)

Serversided command to give admins an NRG-500 or Infernus

for k,v in ipairs(getElementsByType("player"))do setElementData(v,"s_c",nil)end
addCommandHandler("anrg",function(p)if not hasObjectPermissionTo(p,"command.kick",false)then return end local x,y,z=getElementPosition(p)if not getElementData(p,"s_c")then local v=createVehicle(522,x,y,z)setElementData(p,"s_c",v)warpPedIntoVehicle(p,v)else local v=getElementData(p,"s_c")fixVehicle(v)setElementModel(v,522)setElementPosition(v,x,y,z)warpPedIntoVehicle(p,v)end end)
addCommandHandler("acar",function(p)if not hasObjectPermissionTo(p,"command.kick",false)then return end local x,y,z=getElementPosition(p)if not getElementData(p,"s_c")then local v=createVehicle(411,x,y,z)setElementData(p,"s_c",v)warpPedIntoVehicle(p,v)else local v=getElementData(p,"s_c")fixVehicle(v)setElementModel(v,411)setElementPosition(v,x,y,z)warpPedIntoVehicle(p,v)end end)

Add all 3 lines for the script to work. If you spawn an NRG, then you leave it, you can later type /anrg to get your original NRG-500 fixed to you. If you had an NRG and now want an Infernus, just simply type in /acar and it will convert the NRG to an Infernus for you. The script has a built-in check so you don't need to worry about giving everyone free NRG's and Infernuses.