-- RandomWeapon 1.01 -- Written by [SC]Nuggets -- If you have questions, comments, critiques, or evil plans to rule the world, contact [SC]Nuggets via phasor.proboards.com -- Enjoy! --[[ In this gametype, you spawn with assigned attributes based on random number generators. You may not pick up any other weapon other than what you have spawned with. --]] --[[ I have re-scripted my RandomWeapon script in order to make it more user-friendly. This version of the script is meant to make the probabilities of spawning with certain attributes easier to edit. If you're interested in how the code works, I have comments and such in the code below. If you just want this script to work and don't care how it actually works, then you can stop reading when you get to "function GetRequiredVersion". This is the first script I've written with intentions of others reading and trying to understand it, so let me know if I suck at it or not. --]] -- PROBABILITIES: --[[ Change these values to whatever you choose. The percentage of probability is based on the ratio of the value you enter for a specific field and the sum of all of the values of that category. For example, if the sum of all of the values of the "Primary" category is 100, and the assault_rifle is set to 25, there is a 25% chance a player will spawn with an assault rifle (25/100). If the sum of the "Primary" category is 500 and assault_rifle is set to 25, then there's a 5% chance a player will spawn with an assault rifle (25/500). It's obviously easiest to just let each section add up to 100 so the values you enter for each attribute will be a percent value, but if for some reason you don't it want to, I've given you that freedom. Enter the values to any precision you like. --]] -- Weapon probabilities: -- Primary: plasma_pistol = 19 assault_rifle = 22 needler = 14 plasma_rifle = 12 shotgun = 10 pistol = 11 sniper = 9 flamethrower = 1.5 rocket = 1 fuel_rod = 0.5 -- Secondary: no_weapon = 70 plasma_pistol_2 = 7 assault_rifle_2 = 7 needler_2 = 5 plasma_rifle_2 = 3 shotgun_2 = 3 pistol_2 = 2 sniper_2 = 1 flamethrower_2 = 1 rocket_2 = 0.75 fuel_rod_2 = 0.25 -- Grenade probabilities: no_grenades = 75 one_frag = 7 two_frags = 4 one_plasma = 7 two_plasmas = 4 two_of_each = 2 four_of_each = 1 -- Special probabilities: none = 95.5 invisible = 0.75 overshield = 0.75 extra_speed = 0.75 invis_overshield = 0.5 invis_speed = 0.5 overshield_speed = 0.5 all_special = 0.25 -- Ammo probabilities: normal_ammo = 75 double_ammo = 12 triple_ammo = 8 ammotacular = 4.75 infinite_ammo = 0.25 -- Server Messages: welcome_message = "Random attributes will be assigned to you on each spawn." death_message = "Choosing random attributes..." -- Other Editable Variables: speed = 2.0 -- Speed value of players who spawn with extra speed -- Weapon tables: Keeps track of what players have what weapon. 1 = yes, 0 = no. -- Don't mess with this unless you know what you're doing. AssaultRifle = {} Pistol = {} Needler = {} PlasmaRifle = {} PlasmaPistol = {} FuelRod = {} Rocket = {} Flamethrower = {} Shotgun = {} Sniper = {} function GetRequiredVersion() return 10057 end function OnScriptLoad(process) -- Create tables for each weapon and set every player's value to 0. for i = 1, 16 do AssaultRifle[i] = 0 Pistol[i] = 0 Needler[i] = 0 PlasmaRifle[i] = 0 PlasmaPistol[i] = 0 FuelRod[i] = 0 Rocket[i] = 0 Flamethrower[i] = 0 Shotgun[i] = 0 Sniper[i] = 0 end end function OnScriptUnload() end function OnNewGame(map) end function OnGameEnd(mode) end function OnServerChat(player, chattype, message) return 1 end function OnServerCommand(player, command) return 1 end function OnTeamDecision(cur_team) return cur_team end function OnPlayerJoin(player, team) privatesay(player, "Randomness:") privatesay(player, welcome_message) end function OnPlayerLeave(player, team) end function OnPlayerKill(killer, victim, mode) privatesay(victim, death_message) local victimId = resolveplayer(victim) -- Reset all weapon values of the victim to 0. AssaultRifle[victimId] = 0 Pistol[victimId] = 0 Needler[victimId] = 0 PlasmaRifle[victimId] = 0 PlasmaPistol[victimId] = 0 FuelRod[victimId] = 0 Rocket[victimId] = 0 Flamethrower[victimId] = 0 Shotgun[victimId] = 0 Sniper[victimId] = 0 end function OnKillMultiplier(player, multiplier) end function OnPlayerSpawn(player, m_objectId) end function OnPlayerSpawnEnd(player, m_objectId) if gethash(player) ~= nil then -- GRENADES -- Determine whether a player will spawn with grenades, and if so, what kind and how many. -- Sum up all of the values entered in the probabilities. local grenade_sum = no_grenades + one_frag + two_frags + one_plasma + two_plasmas + two_of_each + four_of_each -- Find the highest precision used out of all of the values entered. -- Create array local g = {no_grenades, one_frag, two_frags, one_plasma, two_plasmas, two_of_each, four_of_each} -- Find the highest precision out of all elements of the array. local g_precision = findHighestPrecision(g) -- Be lazy. local x = 10^g_precision -- Get a random number: 0 <= grenade < (grenade_sum * 10^precision) local grenade = getrandomnumber(0, (grenade_sum * x)) local m_Object = getobject(m_objectId) -- Determine what the random number will do. if m_Object ~= 0 then if grenade >= 0 and grenade < (no_grenades * x) then writebyte(m_Object, 0x31E, 0) -- set frag grenades to 0 writebyte(m_Object, 0x31F, 0) -- set plasmas to 0 elseif grenade >= (no_grenades * x) and grenade < (x * (no_grenades + one_frag)) then writebyte(m_Object, 0x31E, 1) -- set frags to 1 writebyte(m_Object, 0x31F, 0) -- plasmas to 0 privatesay(player, "A Frag Grenade.") -- tell the player what they spawned with elseif grenade >= (x * (no_grenades + one_frag)) and grenade < (x * (no_grenades + one_frag + one_plasma)) then writebyte(m_Object, 0x31E, 0) -- yadayadayada writebyte(m_Object, 0x31F, 1) -- yada. privatesay(player, "A Plasma Grenade.") elseif grenade >= (x * (no_grenades + one_frag + one_plasma)) and grenade < (x * (no_grenades + one_frag + one_plasma + two_frags)) then writebyte(m_Object, 0x31E, 2) writebyte(m_Object, 0x31F, 0) privatesay(player, "Two Frag Grenades.") elseif grenade >= (x * (no_grenades + one_frag + one_plasma + two_frags)) and grenade < (x * (no_grenades + one_frag + one_plasma + two_frags + two_plasmas)) then writebyte(m_Object, 0x31E, 0) writebyte(m_Object, 0x31F, 2) privatesay(player, "Two Plasma Grenades.") elseif grenade >= (x * (no_grenades + one_frag + one_plasma + two_frags + two_plasmas)) and grenade < (x * (no_grenades + one_frag + one_plasma + two_frags + two_plasmas + two_of_each)) then writebyte(m_Object, 0x31E, 2) writebyte(m_Object, 0x31F, 2) privatesay(player, "Two of each Grenade.") elseif grenade >= (x * (no_grenades + one_frag + one_plasma + two_frags + two_plasmas + two_of_each)) and grenade < (grenade_sum * x) then writebyte(m_Object, 0x31E, 4) writebyte(m_Object, 0x31F, 4) privatesay(player, "Four of each Grenade.") end end -- SPECIAL ATTRIBUTES -- Determine whether a player will spawn with camouflage, overshield, or extra speed. -- Sum up the values local special_sum = invisible + overshield + extra_speed + invis_overshield + invis_speed + overshield_speed + all_special + none -- Find the highest precision used (see the GRENADES section for info on what's going on here). local s = {invisible, overshield, extra_speed, invis_overshield, invis_speed, overshield_speed, all_special, none} local s_precision = findHighestPrecision(s) local y = 10^s_precision local gametype_base = 0x671340 local gametype_game = readbyte(gametype_base, 0x30) -- Make sure this isn't an Oddball or Race gametype where speed cannot be changed -- Determine whether this is a shields or no-shields gametype so players don't spawn with "overshield" in a no-shields gametype. local gametype_parameters = readbyte(gametype_base, 0x38) local binary = convertbase(10, 2, gametype_parameters) -- gametype_parameters is represented in binary... local obj_max_shields = 0 if string.sub(binary, -4, -4) == "0" then -- ... but we only care if this is a shields or no-shields gametype (which is represented by the fourth digit from the right) Shields on = 0; Shields off = 1 obj_max_shields = 1 end local special = getrandomnumber(0, (special_sum * y)) -- Put it all together and do magical stuff. if special >= 0 and special < (invisible * y) then applycamo(player, 0) setspeed(player, 1) privatesay(player, "You are invisible!") elseif special >= (invisible * y) and special < (y * (invisible + extra_speed)) then if gametype_game ~= 3 and gametype_game ~= 5 then -- make sure this isn't oddball or race setspeed(player, speed) privatesay(player, "You have increased speed!") end elseif special >= (y * (invisible + extra_speed)) and special < (y * (invisible + extra_speed + invis_speed)) then if gametype_game ~= 3 and gametype_game ~= 5 then applycamo(player, 0) setspeed(player, speed) privatesay(player, "You are invisible AND have increased speed!") end elseif special >= (y * (invisible + extra_speed + invis_speed)) and special < (y * (invisible + extra_speed + invis_speed + overshield)) then if obj_max_shields ~= 0 then -- make sure players have shields in this gametype applyos(player) setspeed(player, 1) privatesay(player, "You have overshield!") else setspeed(player, 1) end elseif special >= (y * (invisible + extra_speed + invis_speed + overshield)) and special < (y * (invisible + extra_speed + invis_speed + overshield + invis_overshield)) then if obj_max_shields ~= 0 then applyos(player) applycamo(player, 0) setspeed(player, 1) privatesay(player, "You are invisible AND have overshield!") else setspeed(player, 1) end elseif special >= (y * (invisible + extra_speed + invis_speed + overshield + invis_overshield)) and special < (y * (invisible + extra_speed + invis_speed + overshield + invis_overshield + overshield_speed)) then if obj_max_shields ~= 0 and gametype_game ~= 3 and gametype_game ~= 5 then applyos(player) setspeed(player, speed) privatesay(player, "You have overshield AND extra speed!") else setspeed(player, 1) end elseif special >= (y * (invisible + extra_speed + invis_speed + overshield+ invis_overshield + overshield_speed)) and special < (y * (invisible + extra_speed + invis_speed + overshield + invis_overshield + overshield_speed + all_special)) then if obj_max_shields ~= 0 and gametype_game ~= 3 and gametype_game ~= 5 then applyos(player) applycamo(player, 0) setspeed(player, speed) privatesay(player, "JACKPOT: All special attributes!") else setspeed(player, 1) end elseif special >= (y * (invisible + extra_speed + invis_speed + overshield + invis_overshield + overshield_speed + all_special)) and special < (y * special_sum) then setspeed(player, 1.0) end -- AMMO ATTRIBUTES -- Determine whether a player will spawn with extra ammo. local ammo_sum = normal_ammo + double_ammo + triple_ammo + ammotacular + infinite_ammo -- Find the highest precision used (see the GRENADES section for more info on how this works). local a = {normal_ammo, double_ammo, triple_ammo, ammotacular, infinite_ammo} local a_precision = findHighestPrecision(a) local z = 10^a_precision local ammo = getrandomnumber(0, (ammo_sum * z)) local m_player = getplayer(player) local ammo_multiplier = 1 -- Initialize an ammo multiplier -- Get a player's weapons..... if m_player ~= nil then local m_ObjId = readdword(m_player, 0x34) local m_object = getobject(m_ObjId) if m_object ~= nil then for i = 0, 3 do -- For primary, secondary, ternary, and quartary weapons do... local m_weaponId = readdword(m_object, 0x2F8 + (i*4)) -- Get the weapon ID of each weapon (incrementing by four bytes each time) if m_weaponId ~= nil then local m_weapon = getobject(m_weaponId) if m_weapon ~= nil then -- Make sure the player isn't getting "extra ammo" in his/her plasma weapon if PlasmaRifle[resolveplayer(player)] ~= 1 and PlasmaPistol[resolveplayer(player)] ~= 1 and FuelRod[resolveplayer(player)] ~= 1 then -- Do all the shmexy stuff. local weap_ammo = readword(m_weapon, 0x2B6) if ammo >= 0 and ammo < (double_ammo * z) then writeword(m_weapon, 0x2B6, weap_ammo * 2) ammo_multiplier = 2 elseif ammo >= (double_ammo * z) and ammo < (z * (double_ammo + triple_ammo)) then writeword(m_weapon, 0x2B6, weap_ammo * 3) ammo_multiplier = 3 elseif ammo >= (z * (double_ammo + triple_ammo)) and ammo < (z * (double_ammo + triple_ammo + ammotacular)) then writeword(m_weapon, 0x2B6, weap_ammo * 4) ammo_multiplier = 4 elseif ammo >= (z * (double_ammo + triple_ammo + ammotacular)) and ammo < (z * (double_ammo + triple_ammo + ammotacular + infinite_ammo)) then writeword(m_weapon, 0x2B6, 9999) writeword(m_weapon, 0x2B8, 9999) updateammo(m_weaponId) ammo_multiplier = 5 end end end end end end end -- Print the messages (if you print the messages in the loop above, the player will be spammed the same message for each weapon) if ammo_multiplier == 2 then privatesay(player, "Double Ammo!") elseif ammo_multiplier == 3 then privatesay(player, "Triple Ammo!") elseif ammo_multiplier == 4 then privatesay(player, "Ammotacular!") elseif ammo_multiplier == 5 then privatesay(player, "JACKPOT: INFINITE AMMO!") end end end function OnTeamChange(relevant, player, team, dest_team) return 1 end function OnObjectInteraction(player, m_ObjectId, tagType, tagName) -- Set values of "player" so they can be accessed in the weapon arrays (since there is no "0th" element of an array in Lua) local player = resolveplayer(player) -- Make sure players can always pick up the flag. if tagType == "weap" then if tagName == "weapons\\flag\\flag" then response = 1 -- Based on weapon values, determine what weapon(s) a player can interact with. elseif tagName == "weapons\\assault rifle\\assault rifle" then if AssaultRifle[player] == 1 then response = 1 else response = 0 end elseif tagName == "weapons\\pistol\\pistol" then if Pistol[player] == 1 then response = 1 else response = 0 end elseif tagName == "weapons\\plasma rifle\\plasma rifle" then if PlasmaRifle[player] == 1 then response = 1 else response = 0 end elseif tagName == "weapons\\plasma pistol\\plasma pistol" then if PlasmaPistol[player] == 1 then response = 1 else response = 0 end elseif tagName == "weapons\\needler\\mp_needler" then if Needler[player] == 1 then response = 1 else response = 0 end elseif tagName == "weapons\\flamethrower\\flamethrower" then if Flamethrower[player] == 1 then response = 1 else response = 0 end elseif tagName == "weapons\\plasma_cannon\\plasma_cannon" then if FuelRod[player] == 1 then response = 1 else response = 0 end elseif tagName == "weapons\\rocket launcher\\rocket launcher" then if Rocket[player] == 1 then response = 1 else response = 0 end elseif tagName == "weapons\\shotgun\\shotgun" then if Shotgun[player] == 1 then response = 1 else response = 0 end elseif tagName == "weapons\\sniper rifle\\sniper rifle" then if Sniper[player] == 1 then response = 1 else response = 0 end end elseif tagType == "eqip" then if tagName == "weapons\\frag grenade\\frag grenade" or tagName == "weapons\\plasma grenade\\plasma grenade" then -- Don't let players pick up grenades. response = 0 else -- Let players pick up overshield, camo, and health. response = 1 end end return response end function OnWeaponReload(player, weapon) return 1 end function OnVehicleEntry(relevant, player, vehicleId, vehicle_tag, seat) return 1 end function OnDamageLookup(receiving_obj, causing_obj, tagdata, tagname) end function OnWeaponAssignment(player, object, count, tag) -- Make sure the weapon is being assigned to a player, not a vehicle if player ~= 0xFFFFFFFF then -- Determine what weapon(s) a player will spawn with. -- Sum it up. local weap_sum = assault_rifle + pistol + needler + plasma_rifle + plasma_pistol + fuel_rod + rocket + flamethrower + shotgun + sniper local weap2_sum = no_weapon + assault_rifle_2 + pistol_2 + needler_2 + plasma_rifle_2 + plasma_pistol_2 + fuel_rod_2 + rocket_2 + flamethrower_2 + shotgun_2 + sniper_2 -- Find the highest precision used (see the GRENADES section for more info on how this works). local w = {assault_rifle, pistol, needler, plasma_rifle, plasma_pistol, fuel_rod, rocket, flamethrower, shotgun, sniper} local w2 = {no_weapon, assault_rifle_2, pistol_2, needler_2, plasma_rifle_2, plasma_pistol_2, fuel_rod_2, rocket_2, flamethrower_2, shotgun_2, sniper_2} local precision = findHighestPrecision(w) local precision_2 = findHighestPrecision(w2) local x = 10^precision local y = 10^precision_2 local weapon = getrandomnumber(0, (weap_sum * x)) local weapon2 = getrandomnumber(0, (weap2_sum * y)) -- Primary if count == 0 then if weapon >= 0 and weapon < (x * plasma_pistol) then actualWeapon = lookuptag("weap", "weapons\\plasma pistol\\plasma pistol") privatesay(player, "Plasma Pistol.") PlasmaPistol[resolveplayer(player)] = 1 elseif weapon >= (x * plasma_pistol) and weapon < (x * (plasma_pistol + assault_rifle)) then actualWeapon = lookuptag("weap", "weapons\\assault rifle\\assault rifle") privatesay(player, "Assault Rifle.") AssaultRifle[resolveplayer(player)] = 1 elseif weapon >= (x * (plasma_pistol + assault_rifle)) and weapon < (x * (plasma_pistol + assault_rifle + plasma_rifle)) then actualWeapon = lookuptag("weap", "weapons\\plasma rifle\\plasma rifle") privatesay(player, "Plasma Rifle.") PlasmaRifle[resolveplayer(player)] = 1 elseif weapon >= (x * (plasma_pistol + assault_rifle + plasma_rifle)) and weapon < (x * (plasma_pistol + assault_rifle + plasma_rifle + pistol)) then actualWeapon = lookuptag("weap", "weapons\\pistol\\pistol") privatesay(player, "Pistol.") Pistol[resolveplayer(player)] = 1 elseif weapon >= (x * (plasma_pistol + assault_rifle + plasma_rifle + pistol)) and weapon < (x * (plasma_pistol + assault_rifle + plasma_rifle + pistol + shotgun)) then actualWeapon = lookuptag("weap", "weapons\\shotgun\\shotgun") privatesay(player, "Shotgun.") Shotgun[resolveplayer(player)] = 1 elseif weapon >= (x * (plasma_pistol + assault_rifle + plasma_rifle + pistol + shotgun)) and weapon < (x * (plasma_pistol + assault_rifle + plasma_rifle + pistol + shotgun + needler)) then actualWeapon = lookuptag("weap", "weapons\\needler\\mp_needler") privatesay(player, "Needler.") Needler[resolveplayer(player)] = 1 elseif weapon >= (x * (plasma_pistol + assault_rifle + plasma_rifle + pistol + shotgun + needler)) and weapon < (x * (plasma_pistol + assault_rifle + plasma_rifle + pistol + shotgun + needler + sniper)) then actualWeapon = lookuptag("weap", "weapons\\sniper rifle\\sniper rifle") privatesay(player, "Sniper.") Sniper[resolveplayer(player)] = 1 elseif weapon >= (x * (plasma_pistol + assault_rifle + plasma_rifle + pistol + shotgun + needler + sniper)) and weapon < (x * (plasma_pistol + assault_rifle + plasma_rifle + pistol + shotgun + needler + sniper + flamethrower)) then actualWeapon = lookuptag("weap", "weapons\\flamethrower\\flamethrower") privatesay(player, "Flamethrower.") Flamethrower[resolveplayer(player)] = 1 elseif weapon >= (x * (plasma_pistol + assault_rifle + plasma_rifle + pistol + shotgun + needler + sniper + flamethrower)) and weapon < (x * (plasma_pistol + assault_rifle + plasma_rifle + pistol + shotgun + needler + sniper + flamethrower + rocket)) then actualWeapon = lookuptag("weap", "weapons\\rocket launcher\\rocket launcher") privatesay(player, "Rocket.") Rocket[resolveplayer(player)] = 1 elseif weapon >= (x * (plasma_pistol + assault_rifle + plasma_rifle + pistol + shotgun + needler + sniper + flamethrower + rocket)) and weapon < (x * weap_sum) then actualWeapon = lookuptag("weap", "weapons\\plasma_cannon\\plasma_cannon") privatesay(player, "Fuel Rod.") FuelRod[resolveplayer(player)] = 1 end -- Secondary elseif count == 1 then if weapon2 >= 0 and weapon2 < (y * plasma_pistol_2) then if PlasmaPistol[resolveplayer(player)] ~= 1 then -- Make sure player doesn't spawn with the same primary and secondary weapon actualWeapon = lookuptag("weap", "weapons\\plasma pistol\\plasma pistol") privatesay(player, "Secondary: Plasma Pistol") PlasmaPistol[resolveplayer(player)] = 1 end elseif weapon2 >= (y * plasma_pistol_2) and weapon2 < (y * (plasma_pistol_2 + assault_rifle_2)) then if AssaultRifle[resolveplayer(player)] ~= 1 then actualWeapon = lookuptag("weap", "weapons\\assault rifle\\assault rifle") privatesay(player, "Secondary: Assault Rifle") AssaultRifle[resolveplayer(player)] = 1 end elseif weapon2 >= (y * (plasma_pistol_2 + assault_rifle_2)) and weapon2 < (y * (plasma_pistol_2 + assault_rifle_2 + plasma_rifle_2)) then if PlasmaRifle[resolveplayer(player)] ~= 1 then actualWeapon = lookuptag("weap", "weapons\\plasma rifle\\plasma rifle") privatesay(player, "Secondary: Plasma Rifle") PlasmaRifle[resolveplayer(player)] = 1 end elseif weapon2 >= (y * (plasma_pistol_2 + assault_rifle_2 + plasma_rifle_2)) and weapon2 < (y * (plasma_pistol_2 + assault_rifle_2 + plasma_rifle_2 + needler_2)) then if Needler[resolveplayer(player)] ~= 1 then actualWeapon = lookuptag("weap", "weapons\\needler\\mp_needler") privatesay(player, "Secondary: Needler") Needler[resolveplayer(player)] = 1 end elseif weapon2 >= (y * (plasma_pistol_2 + assault_rifle_2 + plasma_rifle_2 + needler_2)) and weapon2 < (y * (plasma_pistol_2 + assault_rifle_2 + plasma_rifle_2 + needler_2 + pistol_2)) then if Pistol[resolveplayer(player)] ~= 1 then actualWeapon = lookuptag("weap", "weapons\\pistol\\pistol") privatesay(player, "Secondary: Pistol") Pistol[resolveplayer(player)] = 1 end elseif weapon2 >= (y * (plasma_pistol_2 + assault_rifle_2 + plasma_rifle_2 + needler_2 + pistol_2)) and weapon2 < (y * (plasma_pistol_2 + assault_rifle_2 + plasma_rifle_2 + needler_2 + pistol_2 + shotgun_2)) then if Shotgun[resolveplayer(player)] ~= 1 then actualWeapon = lookuptag("weap", "weapons\\shotgun\\shotgun") privatesay(player, "Secondary: Shotgun") Shotgun[resolveplayer(player)] = 1 end elseif weapon2 >= (y * (plasma_pistol_2 + assault_rifle_2 + plasma_rifle_2 + needler_2 + pistol_2 + shotgun_2)) and weapon2 < (y * (plasma_pistol_2 + assault_rifle_2 + plasma_rifle_2 + needler_2 + pistol_2 + shotgun_2 + sniper_2)) then if Sniper[resolveplayer(player)] ~= 1 then actualWeapon = lookuptag("weap", "weapons\\sniper rifle\\sniper rifle") privatesay(player, "Secondary: Sniper") Sniper[resolveplayer(player)] = 1 end elseif weapon2 >= (y * (plasma_pistol_2 + assault_rifle_2 + plasma_rifle_2 + needler_2 + pistol_2 + shotgun_2 + sniper_2)) and weapon2 < (y * (plasma_pistol_2 + assault_rifle_2 + plasma_rifle_2 + needler_2 + pistol_2 + shotgun_2 + sniper_2 + rocket_2)) then if Rocket[resolveplayer(player)] ~= 1 then actualWeapon = lookuptag("weap", "weapons\\rocket launcher\\rocket launcher") privatesay(player, "Secondary: Rocket Launcher") Rocket[resolveplayer(player)] = 1 end elseif weapon2 >= (y * (plasma_pistol_2 + assault_rifle_2 + plasma_rifle_2 + needler_2 + pistol_2 + shotgun_2 + sniper_2 + rocket_2)) and weapon2 < (y * (plasma_pistol_2 + assault_rifle_2 + plasma_rifle_2 + needler_2 + pistol_2 + shotgun_2 + sniper_2 + rocket_2 + flamethrower_2)) then if Flamethrower[resolveplayer(player)] ~= 1 then actualWeapon = lookuptag("weap", "weapons\\flamethrower\\flamethrower") privatesay(player, "Secondary: Flamethrower") Flamethrower[resolveplayer(player)] = 1 end elseif weapon2 >= (y * (plasma_pistol_2 + assault_rifle_2 + plasma_rifle_2 + needler_2 + pistol_2 + shotgun_2 + sniper_2 + rocket_2 + flamethrower_2)) and weapon2 < (y * (plasma_pistol_2 + assault_rifle_2 + plasma_rifle_2 + needler_2 + pistol_2 + shotgun_2 + sniper_2 + rocket_2 + flamethrower_2 + fuel_rod_2)) then if FuelRod[resolveplayer(player)] ~= 1 then actualWeapon = lookuptag("weap", "weapons\\plasma_cannon\\plasma_cannon") privatesay(player, "Secondary: Fuel Rod") FuelRod[resolveplayer(player)] = 1 end end end end return actualWeapon end function OnObjectCreation(m_objId, player_owner, tagName) end function OnClientUpdate(player, m_object) end function OnVehicleEject(player, forced) return 1 end function findHighestPrecision(array) local precision = 0 -- Initialize. for i = 1, #array do -- From the first element of the array to the last, do... local p = getPrecision(array[i]) -- Get the precision of each element. if p > precision then precision = p -- Set the highest value found to the variable "precision". end end return precision -- return it. end function getPrecision(number) local temp = math.ceil(number) -- Truncate digits after the decimal (could use math.floor here too; doesn't really matter). local count = 0 -- Initialize a count. while temp ~= number do -- If these are equal, our precision has been reached. number = number * 10 -- Move to the next decimal place. temp = math.ceil(number) -- Set temp to be the truncated version of this new number. count = count + 1 -- Increase the count. end return count -- Return the precision of the number. end function applyos(player) boolean = false -- Initialize local hash = gethash(player) if hash ~= nil then -- Make sure player exists local m_player = getplayer(player) if m_player ~= nil then local m_objId = readdword(m_player, 0x34) local m_object = getobject(m_objId) if m_object ~= nil then -- Make sure player is alive -- Get player's coordinates local x = readfloat(m_object, 0x5C) local y = readfloat(m_object, 0x60) local z = readfloat(m_object, 0x64) createobject("eqip", "powerups\\over shield", 0, 0, false, x, y, z) -- Create Overshield boolean = true -- The application was successful end end end return boolean -- Return success or failure of application end -- This function is courtesy of Smiley's awesomeness function convertbase(inputbase, outputbase, input) local power = 0 local answer = 0 local number = math.floor(input / (outputbase^power)) local check = true for word in string.gmatch(tostring(input), "%d") do if tonumber(word) >= inputbase then check = false break end end if check == false then answer = 0 else if input == 0 then answer = 0 else while number ~= 1 do power = power + 1 number = math.floor(input / (outputbase^power)) end while power >= 0 do number = math.floor(input / (outputbase^power)) input = input - (number * (outputbase^power)) answer = answer + (number * (inputbase^power)) power = power - 1 end end end return answer end --[[function HelpTimer(id, count, player) if count == 15 then privatesay(player, "FAQ: Why can't I pick up weapons?") elseif count == 18 then privatesay(player, "You spawn with a random weapon set and are stuck with it until you die.") return 0 end return 1 end function ScriptTimer(id, count) hprintf("Script: UniversalRandomWeapon") return 1 end--]]