- --[[
- Creators: AelitePrime, H® Shaft, and H® Bugz
- Script Name: Nitro Hogs Script
- Website: http://phasorscripts.wordpress.com/
- Xfire: eliteprime14789x, nervebooger2012, and hlnbugz
- Included Scripts: Nuggetz sendconsoletext overload, and Vehicle Speed
- Version: 1.0 Nitrous Oxide System (NOS)
- Note: *** Script is currently only compatible with Hog type vehicles.***
- ]]--
- -- Script tables
- emergency_brake = {} -- Do not touch
- default_speed = {} -- Do not touch
- nos_boost = {} -- Do not touch
- nos_deceleration_rate = {} -- Do not touch
- nos_duration = {} -- Do not touch
- nos_fuel = {} -- Do not touch
- nos_fuel_decrease_rate = {} -- Do not touch
- pause_time = {} -- Do not touch
- nos_acceleration_rate = {} -- Do not touch
- engine_protection_overide = {} -- Do not touch
- -- Player tables
- player_fuel = {} -- Do not touch
- count = {} -- Do not touch
- delay = {} -- Do not touch
- using = {} -- Do not touch
- nos = {} -- Do not touch
- --[[
- If you will be using this script for Halo CE you will need to add the name(s) of the map(s) you will be using to each of the tables you want to set values to.
- I made the script compatible with all maps but with no extra features which include: nos fuel, nos duration, pause time, emergency brake, nos deceleration rate, nos acceleration rate, and engine protection overide.
- The only features that are active is default speed, and nos boost. If you which to enable a feature for a map you will need to add it to the table like I said before. Here is an example:
- table_name_here. map_name_here = value_here -- This is a generic example
- nos_boost. coldsnap = 15 -- This will set the nos boost for coldsnap to 15
- I recommened you test out each map with this script and see how you like it. You will most likely need to do some teaky to the settings to your preference and game style that you want in yout server(s).
- Note: *** Script is currently only compatible with Hog type vehicles.***
- ]]--
- -- Modify -- Modify -- Modify -- Modify -- Modify -- Modify -- Modify -- Modify -- Modify -- Modify -- Modify -- Modify --
- -- If this is set to true then If the driver clicks their crouch button the vehicle will come to a complete stop.
- -- Map: Boolean:
- emergency_brake. beavercreek = nil -- battle creek
- emergency_brake. bloodgulch = true
- emergency_brake. boardingaction = nil
- emergency_brake. carousel = nil -- derelict
- emergency_brake. chillout = nil
- emergency_brake. damnation = nil
- emergency_brake. dangercanyon = true
- emergency_brake. deathisland = true
- emergency_brake. gephyrophobia = true
- emergency_brake. hangemhigh = nil
- emergency_brake. icefields = true
- emergency_brake. infinity = true
- emergency_brake. longest = nil
- emergency_brake. prisoner = nil
- emergency_brake. putput = nil -- chiron tl34
- emergency_brake. ratrace = nil
- emergency_brake. sidewinder = true
- emergency_brake. timberland = true
- emergency_brake. wizard = nil
- -- Default boost speed of players in a vehicle (0 = normal speed)
- -- Map: Speed:
- default_speed. beavercreek = 0 -- battle creek
- default_speed. bloodgulch = 0
- default_speed. boardingaction = 0
- default_speed. carousel = 0 -- derelict
- default_speed. chillout = 0
- default_speed. damnation = 0
- default_speed. dangercanyon = 0
- default_speed. deathisland = 0
- default_speed. gephyrophobia = 0
- default_speed. hangemhigh = 0
- default_speed. icefields = 0
- default_speed. infinity = 0
- default_speed. longest = 0
- default_speed. prisoner = 0
- default_speed. putput = 0 -- chiron tl34
- default_speed. ratrace = 0
- default_speed. sidewinder = 0
- default_speed. timberland = 0
- default_speed. wizard = 0
- --[[
- Maximum NOS Boost a player will receive.
- (0, 20) = Almost no Syncing issues
- (20, 35) = Some Syncing issues, but not too bad.
- (35, 50) = Syncing issues noticable but still drivable
- (50, 75) = Syncing issues are barely bearable
- >75 = Syncing issues are unbearable
- ]]--
- -- Map: Speed:
- nos_boost. beavercreek = 0 -- battle creek
- nos_boost. bloodgulch = 20
- nos_boost. boardingaction = 0
- nos_boost. carousel = 0 -- derelict
- nos_boost. chillout = 0
- nos_boost. damnation = 0
- nos_boost. dangercanyon = 13
- nos_boost. deathisland = 20
- nos_boost. gephyrophobia = 15
- nos_boost. hangemhigh = 0
- nos_boost. icefields = 12
- nos_boost. infinity = 20
- nos_boost. longest = 0
- nos_boost. prisoner = 0
- nos_boost. putput = 0 -- chiron tl34
- nos_boost. ratrace = 0
- nos_boost. sidewinder = 15
- nos_boost. timberland = 12
- nos_boost. wizard = 0
- -- Time NOS will last before it starts to decrease. To disable nos_duration make the time nil
- -- Map: Time:
- nos_duration. beavercreek = nil -- battle creek
- nos_duration. bloodgulch = 9
- nos_duration. boardingaction = nil
- nos_duration. carousel = nil -- derelict
- nos_duration. chillout = nil
- nos_duration. damnation = nil
- nos_duration. dangercanyon = 9
- nos_duration. deathisland = 9
- nos_duration. gephyrophobia = 9
- nos_duration. hangemhigh = nil
- nos_duration. icefields = 9
- nos_duration. infinity = 9
- nos_duration. longest = nil
- nos_duration. prisoner = nil
- nos_duration. putput = nil -- chiron tl34
- nos_duration. ratrace = nil
- nos_duration. sidewinder = 9
- nos_duration. timberland = 9
- nos_duration. wizard = nil
- -- Increments in which NOS will increase until the it reaches nos_boost or player stops it. If nil then player will go directly from default speed to nos boost.
- -- Map: Rate per second:
- nos_acceleration_rate. beavercreek = nil -- battle creek
- nos_acceleration_rate. bloodgulch = nil
- nos_acceleration_rate. boardingaction = nil
- nos_acceleration_rate. carousel = nil -- derelict
- nos_acceleration_rate. chillout = nil
- nos_acceleration_rate. damnation = nil
- nos_acceleration_rate. dangercanyon = 5
- nos_acceleration_rate. deathisland = 5
- nos_acceleration_rate. gephyrophobia = 5
- nos_acceleration_rate. hangemhigh = nil
- nos_acceleration_rate. icefields = 5
- nos_acceleration_rate. infinity = 5
- nos_acceleration_rate. longest = nil
- nos_acceleration_rate. prisoner = nil
- nos_acceleration_rate. putput = nil -- chiron tl34
- nos_acceleration_rate. ratrace = nil
- nos_acceleration_rate. sidewinder = 5
- nos_acceleration_rate. timberland = 5
- nos_acceleration_rate. wizard = nil
- -- Increments in which NOS will deplete. If set to nil then you will go directly from nos boost to default speed
- -- Map: Rate per second:
- nos_deceleration_rate. beavercreek = nil -- battle creek
- nos_deceleration_rate. bloodgulch = nil
- nos_deceleration_rate. boardingaction = nil
- nos_deceleration_rate. carousel = nil -- derelict
- nos_deceleration_rate. chillout = nil
- nos_deceleration_rate. damnation = nil
- nos_deceleration_rate. dangercanyon = nil
- nos_deceleration_rate. deathisland = nil
- nos_deceleration_rate. gephyrophobia = nil
- nos_deceleration_rate. hangemhigh = nil
- nos_deceleration_rate. icefields = nil
- nos_deceleration_rate. infinity = nil
- nos_deceleration_rate. longest = nil
- nos_deceleration_rate. prisoner = nil
- nos_deceleration_rate. putput = nil -- chiron tl34
- nos_deceleration_rate. ratrace = nil
- nos_deceleration_rate. sidewinder = nil
- nos_deceleration_rate. timberland = nil
- nos_deceleration_rate. wizard = nil
- --[[
- Amount of 'fuel' you have for NOS. Make nil to disable.
- The amount of fuel wasted per nos ~ (nos_duration + (nos_boost/nos_deceleration_rate))*nos_fuel_decrease_rate
- The equation will only work if each variable has an actual number and nos_deceleration ~= 0 and nos_fuel_decrease_rate ~= 0
- ]]--
- -- Map: Speed:
- nos_fuel. beavercreek = nil -- battle creek
- nos_fuel. bloodgulch = 100
- nos_fuel. boardingaction = nil
- nos_fuel. carousel = nil -- derelict
- nos_fuel. chillout = nil
- nos_fuel. damnation = nil
- nos_fuel. dangercanyon = 100
- nos_fuel. deathisland = 100
- nos_fuel. gephyrophobia = 100
- nos_fuel. hangemhigh = nil
- nos_fuel. icefields = 100
- nos_fuel. infinity = 100
- nos_fuel. longest = nil
- nos_fuel. prisoner = nil
- nos_fuel. putput = nil -- chiron tl34
- nos_fuel. ratrace = nil
- nos_fuel. sidewinder = 100
- nos_fuel. timberland = 100
- nos_fuel. wizard = nil
- --[[
- Increments in which the NOS fuel will deplete. If nos fuel decrease_rate is x, then it will deplete x times each second.
- If nos fuel is not nil, then you are required to set a value. If you do not a default value will be assigned when the script/game starts.
- ]]--
- -- Map: Speed:
- nos_fuel_decrease_rate. beavercreek = nil -- battle creek
- nos_fuel_decrease_rate. bloodgulch = 1
- nos_fuel_decrease_rate. boardingaction = nil
- nos_fuel_decrease_rate. carousel = nil -- derelict
- nos_fuel_decrease_rate. chillout = nil
- nos_fuel_decrease_rate. damnation = nil
- nos_fuel_decrease_rate. dangercanyon = 1
- nos_fuel_decrease_rate. deathisland = 1
- nos_fuel_decrease_rate. gephyrophobia = 1
- nos_fuel_decrease_rate. hangemhigh = nil
- nos_fuel_decrease_rate. icefields = 1
- nos_fuel_decrease_rate. infinity = 1
- nos_fuel_decrease_rate. longest = nil
- nos_fuel_decrease_rate. prisoner = nil
- nos_fuel_decrease_rate. putput = nil -- chiron tl34
- nos_fuel_decrease_rate. ratrace = nil
- nos_fuel_decrease_rate. sidewinder = 1
- nos_fuel_decrease_rate. timberland = 1
- nos_fuel_decrease_rate. wizard = nil
- --[[
- Amount of time before you are able to use NOS again after activating it. When you active NOS Boost this pause time will be assigned to a delay, and until the delay is out
- the player will not be able to re-enabled nos.
- ]]--
- -- Map: Time(In Seconds):
- pause_time. beavercreek = nil -- battle creek
- pause_time. bloodgulch = 10
- pause_time. boardingaction = nil
- pause_time. carousel = nil -- derelict
- pause_time. chillout = nil
- pause_time. damnation = nil
- pause_time. dangercanyon = 10
- pause_time. deathisland = 10
- pause_time. gephyrophobia = 10
- pause_time. hangemhigh = nil
- pause_time. icefields = 10
- pause_time. infinity = 10
- pause_time. longest = nil
- pause_time. prisoner = nil
- pause_time. putput = nil -- chiron tl34
- pause_time. ratrace = nil
- pause_time. sidewinder = 10
- pause_time. timberland = 10
- pause_time. wizard = nil
- --[[
- For every second you use NOS, another second is added to the amount of time you will need to wait until you are able to use NOS.
- This boolean will disable that feature if you want to.
- ]]--
- -- Map: Time(In Seconds):
- engine_protection_overide. beavercreek = nil -- battle creek
- engine_protection_overide. bloodgulch = true
- engine_protection_overide. boardingaction = nil
- engine_protection_overide. carousel = nil -- derelict
- engine_protection_overide. chillout = nil
- engine_protection_overide. damnation = nil
- engine_protection_overide. dangercanyon = true
- engine_protection_overide. deathisland = true
- engine_protection_overide. gephyrophobia = true
- engine_protection_overide. hangemhigh = nil
- engine_protection_overide. icefields = true
- engine_protection_overide. infinity = true
- engine_protection_overide. longest = nil
- engine_protection_overide. prisoner = nil
- engine_protection_overide. putput = nil -- chiron tl34
- engine_protection_overide. ratrace = nil
- engine_protection_overide. sidewinder = true
- engine_protection_overide. timberland = true
- engine_protection_overide. wizard = nil
- -- Do not modify -- Do not modify -- Do not modify -- Do not modify -- Do not modify -- Do not modify -- Do not modify --
- player_speed = {}
- velocity_multiplier = 0.00645 -- do not touch unless you know what it does
- turning_value = 0.999 -- do not touch unless you know what it does
- turning_value_increment = 0.005 -- do not touch unless you know what it does
- turn_multiplier = 0.99 -- do not touch unless you know what it does
- speed_accurary = 10000 -- do not touch unless you know what it does
- map_name = "nil"
- function GetRequiredVersion()
- return 200
- end
- function OnScriptLoad(process, game, persistent)
- -- retrieves map name
- if game == "PC" then
- map_name = readstring(0x698F21)
- else
- map_name = readstring(0x61D151)
- end
- -- Used when the map is not in the table
- if map_name then
- default_speed[map_name] = default_speed[map_name] or 0
- nos_boost[map_name] = nos_boost[map_name] or 5
- if nos_fuel[map_name] then
- nos_fuel_decrease_rate[map_name] = nos_fuel_decrease_rate[map_name] or 1
- end
- end
- -- Initialize the timers for the script
- vehicletimer = registertimer(0, "VehicleSpeedTimer")
- timer = registertimer(1000, "Timer")
- end
- function OnScriptUnload()
- -- Remove script timers
- removetimer(timer)
- removetimer(vehicletimer)
- end
- function OnNewGame(map)
- map_name = map
- -- Used when the map is not in the table
- default_speed[map_name] = default_speed[map_name] or 0
- nos_boost[map_name] = nos_boost[map_name] or 5
- if nos_fuel[map_name] then
- nos_fuel_decrease_rate[map_name] = nos_fuel_decrease_rate[map_name] or 1
- end
- end
- function OnClientUpdate(player)
- -- Detects when the player clicks their flashlight button (NOS Activator)
- local m_playerObjId = getplayerobjectid(player)
- if m_playerObjId and isinvehicle(player) then
- local m_vehicle = getobject(getvehicleobjectid(player))
- if getdriverplayer(m_vehicle) == player and readbit(getobject(m_playerObjId) + 0x208, 4) then
- OnNosBoost(player, m_vehicle)
- end
- end
- end
- function OnNosBoost(player, m_vehicle)
- if checkfuel(player) then -- Checks if the player has any fuel left
- if validvehicle(m_vehicle) then -- Checks if we are able to apply velocity to the vehicle
- -- Determines what the activation does
- if not nos[player] then
- if default_speed[map_name] == nos_boost[map_name] then
- sendconsoletext(player, "NOS is currently not available on this map.", 2, 3)
- elseif (delay[player] or 0) == 0 and getplayervehiclespeed(player) == default_speed[map_name] then
- nos[player] = true
- sendconsoletext(player, "NOS Boost!", 2, 3)
- sendconsoletext(getgunnerplayer(m_vehicle), "Driver has enabled NOS Boost!", 2, 4)
- if pause_time[map_name] then
- delay[player] = (pause_time[map_name])
- end
- elseif getplayervehiclespeed(player) ~= default_speed[map_name] then
- nos[player] = false
- sendconsoletext(player, "NOS Stopped!", 2, 8)
- sendconsoletext(getgunnerplayer(m_vehicle), "NOS Stopped!", 2, 9)
- setplayervehiclespeed(player, default_speed[map_name])
- count[player] = 0
- if engine_protection_overide[map_name] then
- delay[player] = (using[player])
- using[player] = 0
- end
- elseif (delay[player] or 0) > 0 then
- sendconsoletext(player, "Engine is about to overheat. NOS is not available.", 1, 5)
- if delay[player] > 1 then
- sendconsoletext(player, "Wait another " .. (delay[player] or 0) .. " seconds.", 1, 6)
- else
- sendconsoletext(player, "Wait 1 more second.", 1, 7)
- end
- end
- else
- nos[player] = false
- sendconsoletext(player, "NOS Stopped!", 2, 8)
- sendconsoletext(getgunnerplayer(m_vehicle), "NOS Stopped!", 2, 9)
- setplayervehiclespeed(player, default_speed[map_name])
- count[player] = 0
- if engine_protection_overide[map_name] then
- delay[player] = (using[player])
- using[player] = 0
- end
- end
- else
- sendconsoletext(player, "You are not in a valid vehicle. NOS is not available.", 1, 5)
- end
- else
- sendconsoletext(player, "You are out of fuel. NOS is not available.", 1, 6)
- end
- end
- function OnVehicleEntry(player, m_vehicleId, seat, mapId, relevant)
- -- Sends the messages to the driver of the vehicle if it is a valid vehicle
- if seat == 0 and validvehicle(getobject(m_vehicleId)) then
- privatesay(player, "Press Flashlight button to activate/stop Nitro!")
- privatesay(player, "Press Crouch Button for an emergency brake!")
- end
- return nil
- end
- function OnVehicleEject(player, relevant)
- local m_vehicle = getobject(getvehicleobjectid(player))
- if getdriverplayer(m_vehicle) == player then
- -- Disables NOS and stops all velocity
- nos[player] = false
- writefloat(m_vehicle + 0x68, 0)
- writefloat(m_vehicle + 0x6C, 0)
- end
- return nil
- end
- function Timer(id, c)
- for player=0,15 do
- if getplayer(player) then
- local player_speed = (getplayervehiclespeed(player) or 0)
- if isinvehicle(player) then
- if checkfuel(player) then
- local bool = false
- if nos[player] then
- bool = true
- -- Count used for delay
- if engine_protection_overide[map_name] then
- using[player] = (using[player] or 0) + 1
- end
- -- Determines if NOS is increasing or decreasing
- if nos_duration[map_name] and (count[player] or 0) >= nos_duration[map_name] then
- nos[player] = false
- else
- -- Determines how to apply the speed
- if nos_acceleration_rate[map_name] then
- local new_speed = player_speed+nos_acceleration_rate[map_name]
- if new_speed < nos_boost[map_name] then
- setplayervehiclespeed(player, new_speed)
- else
- setplayervehiclespeed(player, nos_boost[map_name])
- end
- else
- setplayervehiclespeed(player, nos_boost[map_name])
- end
- count[player] = (count[player] or 0) + 1
- end
- elseif not nos[player] and player_speed > default_speed[map_name] then
- bool = true
- nosDepleting(player)
- end
- if bool then
- -- Shows current fuel and boost
- if nos_fuel[map_name] then
- sendconsoletext(player, "Fuel: " .. (player_fuel[player] or nos_fuel[map_name]), nil, 2)
- end
- sendconsoletext(player, "Boost: " .. getplayervehiclespeed(player) - default_speed[map_name] .. "%", nil, 2)
- end
- end
- elseif player_speed ~= default_speed[map_name] or nos[player] then
- -- Stops all NOS properties when player is not in a vehicle
- nos[player] = false
- if engine_protection_overide[map_name] then
- delay[player] = (using[player])
- using[player] = 0
- end
- setplayervehiclespeed(player, default_speed[map_name])
- count[player] = 0
- end
- -- delay depletion
- if (delay[player] or 0) > 0 then delay[player] = delay[player] - 1 end
- else
- -- When the player slot is empty it sets everything back to default.
- if count[player] ~= 0 then
- count[player] = 0
- end
- if using[player] ~= 0 then
- using[player] = 0
- end
- if player_speed ~= default_speed[map_name] then
- setplayervehiclespeed(player, default_speed[map_name])
- end
- if nos[player] then
- nos[player] = false
- end
- end
- end
- return true
- end
- function VehicleSpeedTimer(id, count)
- for player=0,15 do
- if getplayer(player) then
- if isinvehicle(player) then
- local m_vehicleId = getvehicleobjectid(player)
- if m_vehicleId then
- local m_vehicle = getobject(m_vehicleId)
- if m_vehicle and getdriverplayer(m_vehicle) == player then
- if player_speed[player] == nil then player_speed[player] = (default_speed[map_name] or 0)/speed_accurary end
- local m_object = getobject(getplayerobjectid(player))
- if emergency_brake[map_name] and readbit(m_object + 0x208, 0) then -- Emergency brake, and crouch button
- -- Stops all velocity for x and y
- writefloat(m_vehicle + 0x68, 0)
- writefloat(m_vehicle + 0x6C, 0)
- elseif player_speed[player] ~= 0 then -- Only when player_speed is not 0
- writebit(m_vehicle + 0x10, 2, 0) -- Syncing issues
- writefloat(m_vehicle + 0x8C, readfloat(m_vehicle, 0x8C)*turn_multiplier) -- reduces pitch velocity for better handling
- writefloat(m_vehicle + 0x90, readfloat(m_vehicle, 0x90)*turn_multiplier) -- reduces yaw velocity for better handling
- writefloat(m_vehicle + 0x94, readfloat(m_vehicle, 0x94)*turn_multiplier) -- reduces roll velocity for better handling
- local obj_x_vel = readfloat(m_vehicle + 0x68)
- local obj_y_vel = readfloat(m_vehicle + 0x6C)
- -- Determines how to apply the velocity
- if readbit(m_object + 0x208, 1) then -- Space bar (brake)
- writefloat(m_vehicle + 0x68, obj_x_vel-(obj_x_vel*(velocity_multiplier+player_speed[player]))) -- Reduce the x velocity
- writefloat(m_vehicle + 0x6C, obj_y_vel-(obj_y_vel*(velocity_multiplier+player_speed[player]))) -- Reduce the y velocity
- else
- writefloat(m_vehicle + 0x68, obj_x_vel+(obj_x_vel*(velocity_multiplier+player_speed[player]))) -- Increase the x velocity
- writefloat(m_vehicle + 0x6C, obj_y_vel+(obj_y_vel*(velocity_multiplier+player_speed[player]))) -- Increase the y velocity
- end
- -- Reduce the pitch and roll when it is above a certain point(turning value).
- for i=0,2 do
- local offset = 0x74 + 4*i
- local value = readfloat(m_vehicle + offset)
- if value > turning_value then
- writefloat(m_vehicle + offset, value-turning_value_increment)
- elseif value < -turning_value then
- writefloat(m_vehicle + offset, value+turning_value_increment)
- end
- end
- end
- end
- end
- end
- else
- -- When the player slot is empty it sets everything back to default.
- if player_speed[player] ~= (default_speed[map_name] or 0) then
- player_speed[player] = (default_speed[map_name] or 0)
- end
- if nos_fuel[map_name] and player_fuel[player] ~= nos_fuel[map_name] then
- player_fuel[player] = nos_fuel[map_name]
- end
- end
- end
- return true
- end
- function checkfuel(player)
- -- Determines if the player has any fuel left.
- if (count[player] or 0) > 0 and nos_fuel[map_name] then
- if nos_fuel[map_name] and player_fuel[player] == nil then player_fuel[player] = nos_fuel[map_name] end
- if player_fuel[player] and player_fuel[player] > 0 then
- player_fuel[player] = player_fuel[player] - nos_fuel_decrease_rate[map_name]
- end
- if player_fuel[player] <= 0 then
- sendconsoletext(player, "You are out of NOS for the game!")
- setplayervehiclespeed(player, default_speed[map_name])
- count[player] = 0
- return false
- end
- end
- return true
- end
- function getdriverplayer(m_vehicle)
- -- Retrieves driver player
- local m_objectId = readdword(m_vehicle + 0x324)
- if m_objectId and m_objectId ~= 0xFFFFFFFF then
- return objectidtoplayer(m_objectId)
- end
- end
- function getgunnerplayer(m_vehicle)
- -- Retrieves gunner player
- local m_objectId = readdword(m_vehicle + 0x328)
- if m_objectId and m_objectId ~= 0xFFFFFFFF then
- return objectidtoplayer(m_objectId)
- end
- end
- function getplayerfuel(player)
- -- Retrieves fuel of player
- return (player_fuel[player] or nos_fuel[map_name])
- end
- function getplayervehiclespeed(player)
- -- Retrieves speed of player
- return (player_speed[player] or default_speed[map_name])*speed_accurary
- end
- function getvehicleobjectid(player)
- -- Retrieves player m_vehicleId
- local m_objectId = getplayerobjectid(player)
- if m_objectId then
- return readdword(getobject(m_objectId) + 0x11C)
- end
- end
- function nosDepleting(player)
- -- Determines NOS depletion
- sendconsoletext(player, "NOS depleting!")
- if nos_deceleration_rate[map_name] then -- Used if rate is not nil
- setplayervehiclespeed(player, getplayervehiclespeed(player) - (nos_deceleration_rate[map_name] or 0))
- else -- Sets the speed to default if rate is nil
- setplayervehiclespeed(player, default_speed[map_name])
- end
- if getplayervehiclespeed(player) <= default_speed[map_name] then
- sendconsoletext(player, "NOS depleted! You are back to normal speed", 2)
- sendconsoletext(getgunnerplayer(getobject(getvehicleobjectid(player))), "NOS depleted! You are back to normal speed", 2)
- setplayervehiclespeed(player, default_speed[map_name])
- count[player] = 0
- if engine_protection_overide[map_name] then
- delay[player] = (using[player])
- using[player] = 0
- end
- end
- end
- function setplayefuel(player, fuel)
- -- Sets player fuel
- if tonumber(fuel) then
- player_fuel[player] = tonumber(fuel)
- end
- end
- function setplayervehiclespeed(player, speed)
- -- Sets player speed
- if tonumber(speed) then
- player_speed[player] = tonumber(speed)/speed_accurary
- end
- end
- function round(input, precision) -- rounds the number to the specified decimal place
- return math.floor((input * 10^(tonumber(precision) or 0) + 0.5)) / (10^(tonumber(precision) or 0))
- end
- function validvehicle(m_vehicle)
- -- Checks if it's a valid vehicle by checking if the name has 'hog' or 'puma' in the tag name.
- -- It is a really stupid way to determinig it, but it is compatible with most CE maps this way.
- local name = gettaginfo(readdword(m_vehicle))
- if string.find(name, "hog") or string.find(name, "puma") then
- return true
- end
- return false
- end
- -- Start sendconsoletext overloaded
- console = {}
- console.__index = console
- registertimer(100, "ConsoleTimer")
- phasor_sendconsoletext = sendconsoletext
- function sendconsoletext(player, message, time, order, align, height, func)
- if player then
- console[player] = console[player] or {}
- local temp = {}
- temp.player = player
- temp.id = nextid(player, order)
- temp.message = message or ""
- temp.time = time or 0.7
- temp.remain = temp.time
- temp.align = align or "left"
- temp.height = height or 0
- if type(func) == "function" then
- temp.func = func
- elseif type(func) == "string" then
- temp.func = _G[func]
- end
- console[player][temp.id] = temp
- setmetatable(console[player][temp.id], console)
- return console[player][temp.id]
- end
- end
- function nextid(player, order)
- if not order then
- local x = 0
- for k,v in pairs(console[player]) do
- if k > x + 1 then
- return x + 1
- end
- x = x + 1
- end
- return x + 1
- else
- local original = order
- while console[player][order] do
- order = order + 0.001
- if order == original + 0.999 then break end
- end
- return order
- end
- end
- function getmessage(player, order)
- if console[player] then
- if order then
- return console[player][order]
- end
- end
- end
- function getmessages(player)
- return console[player]
- end
- function getmessageblock(player, order)
- local temp = {}
- for k,v in opairs(console[player]) do
- if k >= order and k < order + 1 then
- table.insert(temp, console[player][k])
- end
- end
- return temp
- end
- function console:getmessage()
- return self.message
- end
- function console:append(message, reset)
- if console[self.player] then
- if console[self.player][self.id] then
- if getplayer(self.player) then
- if reset then
- if reset == true then
- console[self.player][self.id].remain = console[self.player][self.id].time
- elseif tonumber(reset) then
- console[self.player][self.id].time = tonumber(reset)
- console[self.player][self.id].remain = tonumber(reset)
- end
- end
- console[self.player][self.id].message = message or ""
- return true
- end
- end
- end
- end
- function console:shift(order)
- local temp = console[self.player][self.id]
- console[self.player][self.id] = console[self.player][order]
- console[self.player][order] = temp
- end
- function console:pause(time)
- console[self.player][self.id].pausetime = time or 5
- end
- function console:delete()
- console[self.player][self.id] = nil
- end
- function ConsoleTimer(id, count)
- for i,_ in opairs(console) do
- if tonumber(i) then
- if getplayer(i) then
- for k,v in opairs(console[i]) do
- if console[i][k].pausetime then
- console[i][k].pausetime = console[i][k].pausetime - 0.1
- if console[i][k].pausetime <= 0 then
- console[i][k].pausetime = nil
- end
- else
- if console[i][k].func then
- if not console[i][k].func(i) then
- console[i][k] = nil
- end
- end
- if console[i][k] then
- console[i][k].remain = console[i][k].remain - 0.1
- if console[i][k].remain <= 0 then
- console[i][k] = nil
- end
- end
- end
- end
- if table.len(console[i]) > 0 then
- local paused = 0
- for k,v in pairs(console[i]) do
- if console[i][k].pausetime then
- paused = paused + 1
- end
- end
- if paused < table.len(console[i]) then
- local str = ""
- for i = 0,30 do
- str = str .. " \n"
- end
- phasor_sendconsoletext(i, str)
- for k,v in opairs(console[i]) do
- if not console[i][k].pausetime then
- if console[i][k].align == "right" or console[i][k].align == "center" then
- phasor_sendconsoletext(i, consolecenter(string.sub(console[i][k].message, 1, 78)))
- else
- phasor_sendconsoletext(i, string.sub(console[i][k].message, 1, 78))
- end
- end
- end
- end
- end
- else
- console[i] = nil
- end
- end
- end
- return true
- end
- function consolecenter(text)
- if text then
- local len = string.len(text)
- for i = len + 1, 78 do
- text = " " .. text
- end
- return text
- end
- end
- function opairs(t)
- local keys = {}
- for k,v in pairs(t) do
- table.insert(keys, k)
- end
- table.sort(keys,
- function(a,b)
- if type(a) == "number" and type(b) == "number" then
- return a < b
- end
- an = string.lower(tostring(a))
- bn = string.lower(tostring(b))
- if an ~= bn then
- return an < bn
- else
- return tostring(a) < tostring(b)
- end
- end)
- local count = 1
- return function()
- if table.unpack(keys) then
- local key = keys[count]
- local value = t[key]
- count = count + 1
- return key,value
- end
- end
- end
- function table.len(t)
- local count = 0
- for k,v in pairs(t) do
- count = count + 1
- end
- return count
- end
- -- Stop sendconsoletext overloaded
Recent Pastes