Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------
- --** RolePlay lua by TheAnonymous **--
- ----------------------------------------
- -------------------
- --- HOOKS -------
- -------------------
- addhook("join","AM.PlayerJoin")
- addhook("leave","AM.PlayerLeave")
- addhook("always","AM.BotCheck")
- addhook("mapchange","AM.GeneralSave")
- addhook("minute", "AddPlaytime")
- addhook("second", "everySecond")
- addhook("movetile", "onMovetile")
- addhook("attack", "onAttack")
- addhook("team", "onTeam")
- addhook("die", "onDie")
- addhook("leave", "onLeave")
- addhook("spawn", "onSpawn")
- addhook("hit", "onHit")
- addhook("join", "onJoin")
- addhook("serveraction", "onServeraction")
- addhook("walkover", "onWalkover")
- addhook("startround_prespawn", "onPreStartround")
- addhook("use","PMu")
- addhook("use","PMu2")
- addhook("menu", "also")
- addhook("menu", "lbent_menu")
- addhook("minute", "paydayMinute")
- addhook("say","unimenushell");
- addhook("menu","unimenuhook")
- addhook("objectkill", "onObjectkill");
- addhook("buildattempt", "onBuildattempt");
- addhook("use","jobUse")
- addhook("use","doctorwho.tardis.plyenter")
- addhook("menu","doctorwho.ssmenu")
- addhook("hit","doctorwho.hitrender")
- addhook("say","doctorwho.sayprocess")
- addhook("die","doctorwho.abortregen")
- addhook("ms100","doctorwho.ms100")
- addhook("serveraction","doctorwho.sonicscrewdriver")
- addhook("serveraction","doctorwho.tardiscontrols")
- addhook("second","doctorwho.second")
- addhook("movetile","doctorwho.movetile")
- addhook('join', 'AA_join')
- addhook('leave', 'AA_leave')
- addhook('spawn', 'AA_spawn')
- addhook("movetile", "HookMoveTile")
- addhook("use", "HookUse")
- addhook('say','_sayHook',1)
- addhook('collect', 'WW_collectHook')
- addhook('drop', 'WW_dropHook')
- addhook('select', 'WW_selectHook')
- addhook('spawn', 'WW_spawnHook')
- addhook('die', 'clearSlots')
- addhook("use", "enterCar")
- addhook("ms100", "particleCars")
- addhook("always", "updateCars")
- addhook("drop", "carMenu")
- addhook("attack", "destroyAttack");
- addhook("always", "moveTrains")
- addhook("use", "enterTrain")
- addhook("use","pkl.HookUse")
- addhook("menu", "pkl.HookMenu")
- addhook("movetile", "houseCheck")
- addhook("movetile", "House_MoveTile")
- addhook("use", "HouseInfo")
- addhook("startround","advertise")
- addhook("startround","advertise2")
- ----------------------------
- --- ADMINS & OTHERS ------
- ----------------------------
- AM = {}
- mod_path = "sys/lua/"
- mod_name = "CS2DHungary Roleplay"
- mod_version = "0.1"
- package.cpath = package.cpath..";./"..mod_path.."res/?.dll;/lib/?.dll"
- dofile(mod_path.."os.lua")
- if string.find(os.name(), "windows") then
- function LoadDLL(path,func,name)
- local f, e = package.loadlib(path, func)
- if f and not e then
- f()
- print("Loaded "..name.." DLL")
- return true
- else
- print("Failed to load "..name.." DLL: "..e)
- end
- end
- if LoadDLL(mod_path.."res/stream.dll", "init", "stream functions") then
- dofile(mod_path.."stream_functions_dll.lua")
- else
- dofile(mod_path.."stream_functions.lua")
- end
- require("ex")
- else
- dofile(mod_path.."stream_functions.lua")
- end
- dofile(mod_path.."data.lua")
- -- Important addons
- dofile(mod_path.."addons/lua_table.lua")
- dofile(mod_path.."addons/lua_math.lua")
- dofile(mod_path.."addons/lua_string.lua")
- dofile(mod_path.."addons/lua_funcs.lua")
- dofile(mod_path.."addons/lua_error.lua")
- function SetTempAddonTable(t)
- local mt = {}
- function mt.__newindex(g,k,v)
- t[k] = CopyObject(v)
- end
- setmetatable(_G, mt)
- end
- function RequireTempAddon(name)
- local f = io.open(mod_path.."addons/"..name..".lua")
- if f then
- f:close()
- local t = {}
- SetTempAddonTable(t)
- ProtectedCall(dofile, mod_path.."addons/"..name..".lua")
- setmetatable(_G, nil)
- return t
- end
- end
- function SetAddonTable(t)
- local mt = {}
- function mt.__newindex(g,k,v)
- t[k] = v
- if k ~= "Init" then
- setmetatable(_G, nil)
- _G[k] = v
- setmetatable(_G, mt)
- end
- end
- setmetatable(_G, mt)
- end
- ADDON_INSTALLED = {}
- function RequireAddon(name)
- local f = io.open(mod_path.."addons/"..name..".lua")
- if f then
- f:close()
- local t = {}
- SetAddonTable(t)
- ProtectedCall(dofile, mod_path.."addons/"..name..".lua")
- ADDON_INSTALLED[name] = true
- setmetatable(_G, nil)
- return t
- end
- end
- function ScanAddon(a,keyword)
- local f = io.open(mod_path.."addons/"..a..".lua")
- if f then
- local code = f:read("*a"); f:close()
- if code:find(keyword) then
- msg("Found "..keyword.." in addon: "..a)
- end
- return true
- end
- end
- function LoadAddons()
- print(string.char(169).."000255000Loading server addons")
- local f = io.open(mod_path.."addon_config.txt", "r")
- local temp_addon = {}
- if f then
- for lines in f:lines() do
- if string.byte(lines, string.len(lines)) == 13 then
- lines = string.sub(lines, 1, string.len(lines)-1)
- end
- if string.len(lines) > 0 and string.sub(lines, 1, 2) ~= "//" then
- temp_addon[lines] = RequireAddon(lines)
- if temp_addon[lines] then
- print(string.char(169).."000255000Loading addon "..lines)
- else
- print(string.char(169).."255000000Failed to load addon "..lines)
- end
- end
- end
- f:close()
- end
- for k, t in pairs(temp_addon) do
- if t.Init then
- t.Init()
- end
- end
- LoadAddons = nil
- end; LoadAddons()
- function AM.ReloadLogin(id)
- DeleteUSER(id)
- DeleteUSGN(player(id,"usgn"))
- ReloadUSER(id)
- ReloadTEMP(id)
- LoadIPData(player(id,"ip"))
- end
- function AM.PlayerJoin(id)
- while string.sub(player(id,"name"), 1, 1) == "(" do
- parse('setname '..id..' "'..string.sub(player(id,"name"), 2)..'" 1')
- end
- AM.ReloadLogin(id)
- end
- function AM.PlayerLeave(id)
- SaveUSER(id)
- SaveIPData(player(id,"ip"))
- DeleteUSER(id)
- DeleteUSGN(player(id,"usgn"))
- end
- function bot_list()
- local l = {}
- for _, id in pairs(player(0,"table")) do
- if player(id, "bot") then
- table.insert(l, id)
- end
- end
- return l
- end
- bot_init = {}
- function AM.BotCheck()
- local bl = bot_list()
- if last_bots then
- for _, id in pairs(last_bots) do
- if player(id,"exists") then
- if not bot_init[id] then
- AM.PlayerJoin(id)
- bot_init[id] = true
- end
- else
- AM.PlayerLeave(id)
- last_bots[id] = nil
- bot_init[id] = nil
- end
- end
- end
- last_bots = bl
- end
- function AM.GeneralSave()
- for _, id in pairs(player(0,"table")) do
- SaveUSER(id)
- end
- SaveServer()
- end
- ---------------------------
- -- LIBS AND SOME STUFF --
- ---------------------------
- ----------------------------
- USGN_DATAPATH = mod_path.."data/"
- USGN = {}
- USER = {}
- USER_DATA = {}
- -- Data metatable
- DATA_META = {}
- function DATA_META.__index(t,k)
- return t["data"][k]
- end
- function DATA_META.__newindex(t,k,v)
- t["data"][k] = v
- end
- -- User
- USER_DATA = {}
- USER_META = {}
- USER = {}
- function USER_META.__index(t,id)
- if type(id) == "number" and id > 0 then
- if not USER_DATA[id] then
- if player(id, "usgn") > 0 then
- USER_DATA[id] = USGN[player(id,"usgn")]
- end
- if not USER_DATA[id] then
- USER_DATA[id] = {}
- USER_DATA[id].data = table.copy(USGN_DEFAULTDATA or {})
- end
- setmetatable(USER_DATA[id], DATA_META)
- elseif USGN_DATA[player(id,"usgn")] and USER_DATA[id] ~= USGN_DATA[player(id,"usgn")] then
- USER_DATA[id] = USGN_DATA[player(id,"usgn")]
- end
- return USER_DATA[id]
- end
- end
- function USER_META.__newindex(t,k,v)
- USER_DATA[k] = v
- end
- -- USGN
- USGN_DEFAULTDATA = {}
- USGN = {}
- USGN_DATA = {}
- USGN_META = {}
- function USGN_META.__index(t,id)
- if not id then return nil end
- if USGN_DATA[id] then return USGN_DATA[id] end
- if type(id) == "number" and id > 0 then
- return LoadUSGN(id)
- end
- end
- function USGNDataExists(u)
- if not u then return nil end
- return FileExists(USGN_DATAPATH..u..".txt") or USGN_DATA[u] ~= nil
- end
- function LoadUSGN(id)
- if id > 0 then
- local data = LoadData(USGN_DATAPATH..id..".txt")
- if data then
- USGN_DATA[id] = data
- table.safecopy(USGN_DEFAULTDATA, data)
- else
- USGN_DATA[id] = CreateData()
- USGN_DATA[id]["data"] = table.copy(USGN_DEFAULTDATA or {})
- end
- return data
- end
- end
- function SaveUSGN(id)
- if id > 0 then
- local t = USGN_DATA[id]
- if t then
- return SaveDataFile(t, USGN_DATAPATH..id..".txt")
- end
- end
- end
- -- USER TEMP
- USERTEMP_DEFAULTDATA = {}
- USERTEMP = {}
- USERTEMP_DATA = {}
- USERTEMP_META = {}
- function USERTEMP_META.__index(t,id)
- if not USERTEMP_DATA[id] then
- USERTEMP_DATA[id] = CreateData()
- USERTEMP_DATA[id] = table.copy(USERTEMP_DEFAULTDATA) or {}
- end
- return USERTEMP_DATA[id]
- end
- -- IP Data
- USERIP_DEFAULTDATA = {}
- USERIP = {}
- USERIP_DATA = {}
- USERIP_META = {}
- function USERIP_META.__index(t,ip)
- if not ip then return nil end
- if not USERIP_DATA[ip] then LoadIPData(ip) end
- return USERIP_DATA[ip]
- end
- function IPDataExists(ip)
- return FileExists(mod_path.."data/ip_"..ip..".txt") or USERIP_DATA[ip] ~= nil
- end
- function LoadIPData(ip)
- if not ip then return nil end
- local t = CreateData()
- local stream = ReadStream(mod_path.."data/ip_"..ip..".txt")
- t.data = table.copy(USERIP_DEFAULTDATA or {})
- if stream then
- local data_name, data_value = ReadData(stream)
- while data_name and data_value do
- t.data[data_name] = data_value
- if not Eof(stream) then
- data_name, data_value = ReadData(stream)
- else
- break
- end
- end
- CloseStream(stream)
- end
- USERIP_DATA[ip] = t
- return t
- end
- function SaveIPData(ip)
- local t = USERIP[ip]
- if not t then return end
- if table.size(t.data) == 0 then
- return os.remove(mod_path.."data/ip_"..ip..".txt")
- end
- local stream = WriteStream(mod_path.."data/ip_"..ip..".txt")
- if stream then
- for k, v in pairs(t.data) do
- SaveData(stream, k, v)
- end
- CloseStream(stream)
- return true
- end
- end
- -- Data functions
- function CreateData()
- local t = {data = {}}
- setmetatable(t, DATA_META)
- return t
- end
- function LoadData(file)
- local t = {data = {}}
- local stream = ReadStream(file)
- if stream then
- local data_name, data_value = ReadData(stream)
- while data_name and data_value do
- t.data[data_name] = data_value
- if not Eof(stream) then
- data_name, data_value = ReadData(stream)
- else
- break
- end
- end
- CloseStream(stream)
- setmetatable(t, DATA_META)
- return t
- end
- end
- function SaveDataFile(t, file)
- if table.size(t.data) == 0 then return end
- local stream = WriteStream(file)
- if stream then
- for k, v in pairs(t.data) do
- SaveData(stream, k, v)
- end
- CloseStream(stream)
- return true
- end
- end
- function SaveUSER(id)
- if player(id,"usgn") > 0 then
- SaveUSGN(player(id, "usgn"))
- end
- end
- setmetatable(USGN, USGN_META)
- setmetatable(USER, USER_META)
- setmetatable(USERTEMP, USERTEMP_META)
- setmetatable(USERIP, USERIP_META)
- function ReadData(s)
- local key_type = ReadByte(s)
- local data_name
- if key_type == 110 then
- data_name = tonumber(ReadLine(s))
- elseif key_type == 115 then
- data_name = ReadLine(s)
- end
- local data_type = ReadString(s, 2)
- local data_value
- if data_type == "nu" then
- data_value = tonumber(ReadLong(s))
- elseif data_type == "st" then
- data_value = ReadLine(s)
- elseif data_type == "ta" then
- data_value = {}
- local size = ReadInt(s)
- for i = 1, size do
- local dn, dv = ReadData(s)
- data_value[dn] = dv
- end
- elseif data_type == "fu" then
- local size = ReadInt(s)
- local funcscript = ReadString(s, size)
- data_value = loadstring(funcscript)
- elseif data_type == "bo" or data_type == "ni" then
- local v = tonumber(ReadByte(s))
- if v == 1 then
- data_value = true
- elseif v == 0 then
- data_value = false
- end
- end
- return data_name, data_value
- end
- function SaveData(s,data_name,data_value)
- local key_type = string.byte(type(data_name), 1)
- WriteByte(s, key_type)
- WriteLine(s, data_name)
- local data_type = string.sub(type(data_value), 1, 2)
- WriteString(s, data_type)
- if data_type == "nu" then
- WriteLong(s, data_value)
- elseif data_type == "st" then
- WriteLine(s, data_value)
- elseif data_type == "ta" then
- WriteInt(s, table.size(data_value))
- for k, v in pairs(data_value) do
- SaveData(s, k, v)
- end
- elseif data_type == "fu" then
- local funcscript = string.dump(data_value)
- WriteInt(s, string.len(funcscript))
- WriteString(s, funcscript)
- elseif data_type == "bo" or data_type == "ni" then
- if data_value then
- WriteByte(s, 1)
- elseif not data_value then
- WriteByte(s, 0)
- end
- end
- end
- function ReloadUSER(id)
- USER_DATA[id] = nil
- return USER[id]
- end
- function ReloadUSGN(id)
- USGN[id] = nil
- return USGN[id]
- end
- function ReloadTEMP(id)
- USERTEMP_DATA[id] = nil
- return USERTEMP[id]
- end
- function DeleteUSGN(u)
- USGN[u] = nil
- end
- function DeleteUSER(id)
- USER[id] = nil
- end
- function table.copy(t)
- local copy = {}
- for k, v in pairs(t) do
- if type(v) == "table" then
- copy[k] = table.copy(v)
- elseif type(v) == "function" then
- copy[k] = loadstring(string.dump(v))
- else
- copy[k] = v
- end
- end
- return copy
- end
- function table.size(t)
- local n = 0
- for k, v in pairs(t) do
- n = n + 1
- end
- return n
- end
- ------------------------------
- ------- FOOD&DRINK SYS -------
- ------------------------------
- function BuyFood(id, food, amount)
- if PayMoney(id, amount, true) then
- unimenu(id, true, pmenu[id], 1);
- DecHunger(id, food)
- end
- end
- function BuyWater(id, water, amount)
- if PayMoney(id, amount, true) then
- unimenu(id, true, pmenu[id], 1);
- DecThirst(id, water)
- end
- end
- ------------------------------
- -------- SAVE SYSTEM ---------
- ------------------------------
- function SavePlayer(id)
- local usgn = GetUsgn(id);
- if usgn > 0 then
- file = io.open(path .. "saves/" .. usgn .. ".txt", "w");
- if file then
- file:write(tostring(Player[id].money .. "\n"));
- file:write(tostring(BoolToInt(Player[id].license) .. "\n"));
- file:write(tostring(Player[id].playtime .. "\n"));
- file:write(tostring(Player[id].job .. "\n"));
- local _, i;
- file:write(tostring(#Player[id].inv .. "\n"));
- for _, i in pairs(Player[id].inv) do
- file:write(tostring(i .. "\n"));
- end
- io.close(file);
- return true;
- else
- return false;
- end
- end
- end
- ----------------------
- ---- LOAD PLAYER -----
- ----------------------
- function LoadPlayer(id)
- local usgn = GetUsgn(id);
- if usgn > 0 then
- file = io.open(path .. "saves/" .. usgn .. ".txt", "r");
- if file then
- Player[id].money = tonumber(file:read());
- Player[id].license = IntToBool(file:read());
- Player[id].playtime = tonumber(file:read());
- Player[id].job = tostring(file:read());
- if Player[id].money == nil then Player[id].money = 0 end;
- if Player[id].license == nil then Player[id].license = false end;
- if Player[id].playtime == nil then Player[id].playtime = 0 end;
- if Player[id].job == nil then Player[id].job = "None" end;
- local i,inv_len,t;
- t = {};
- inv_len = tonumber(file:read());
- for i = 1, inv_len do
- table.insert(t, tonumber(file:read()));
- end
- Player[id].inv = t;
- io.close(file);
- return true;
- else
- return false;
- end
- end
- end
- function BoolToInt(bool)
- if bool == true then return 1 else return 0 end;
- end
- function IntToBool(int)
- if tonumber(int) == 0 then return false else return true end;
- end
- ----------------------------------
- --** PLAYER THINGS **--
- ----------------------------------
- Player = {};
- nSecond = 0;
- function AddPlaytime()
- local _, i;
- for _, i in pairs(player(0, "table")) do
- if not Player[i].joined then
- Player[i].playtime = Player[i].playtime + 1;
- end
- end
- end
- function everySecond()
- nSecond = nSecond + 1;
- local _, i;
- for _, i in pairs(player(0, "table")) do
- if player(i, "health") > 0 then
- AddHunger(i, 0.0005);
- AddThirst(i, 0.0001);
- UpdateHud(i);
- if Player[i].hunger > 75 then
- if player(i, "health") - 1 <= 0 and nSecond % 5 == 0 then
- KillHunger(i);
- elseif nSecond % 5 == 0 then
- parse("sethealth ".. i .." ".. player(i, "health") - 1);
- end
- elseif Player[i].hunger < 10 then
- if nSecond % 3 == 0 then
- if player(i, "health") < player(i, "maxhealth") then
- parse("sethealth ".. i .." ".. player(i, "health") + 1);
- end
- end
- end
- if Player[i].thirst > 75 then
- if player(i, "health") - 1 <= 0 and nSecond % 2 == 0 then
- KillThirst(i);
- elseif nSecond % 2 == 0 then
- parse("sethealth ".. i .." ".. player(i, "health") - 1);
- end
- end
- end
- end
- if nSecond >= 10 then nSecond = 0 end;
- end
- function onMovetile(id)
- if not Player[id].carowner and not Player[id].car and Player[id].train == 0 then
- AddHunger(id, 0.0005);
- AddThirst(id, 0.001);
- end
- end
- function onAttack(id, mode)
- AddHunger(id, 0.002);
- AddThirst(id, 0.001);
- if mode == 2 then
- AddHunger(id, 0.001);
- AddThirst(id, 0.003);
- UpdateHud(i);
- end
- end
- function onTeam(id, team)
- if Player[id].joined then
- if GetUsgn(id) > 0 then
- local _, i;
- for _, i in pairs(player(0, "table")) do
- if i > id or i < id then
- if GetUsgn(id) == GetUsgn(i) then
- msg2(id, "©255000000Double U.S.G.N login detected (".. player(i, "name") ..")!");
- return 1;
- end
- end
- end
- end
- Player[id].joined = false;
- Player[id].money = 0;
- Player[id].health = 0;
- Player[id].hunger = 0;
- Player[id].thirst = 0;
- Player[id].group = "player";
- Player[id].hud = 0;
- Player[id].train = 0;
- Player[id].speed = 0;
- Player[id].carstart = false;
- Player[id].cargear = 0;
- Player[id].license = false;
- Player[id].lastx = 0;
- Player[id].lasty = 0;
- Player[id].playtime = 0;
- Player[id].job = "None";
- Player[id].built = {};
- Player[id].cars = {};
- Player[id].inv = {};
- if LoadPlayer(id) then
- msg2(id, "©000255000Succefully loaded your U.S.G.N save!");
- end
- if team == 2 then
- if Player[id].playtime <= 1440 then
- msg2(id, "©255000000You didn't play 24 hours on this server yet!");
- parse("maket " .. id);
- return 1;
- else
- Player[id].job = "Police Man";
- msg2(id, "©255128064You're now Police Man!");
- return 0;
- end
- end
- UpdateHud(id);
- elseif team == 2 then
- if Player[id].playtime <= 1440 then
- Player[id].job = "None";
- msg2(id, "©255000000You didn't play 24 hours on this server yet!");
- parse("maket " .. id);
- return 1;
- else
- Player[id].job = "Police Man";
- msg2(id, "©255128064You're now Police Man!");
- return 0;
- end
- end
- end
- function onDie(id)
- if Player[id].car then
- local _, i;
- for _, i in pairs(Player[id].car.players) do
- if i == id then
- table.remove(Player[id].car.players, _);
- break;
- end
- end
- Player[id].car = nil;
- end
- if Player[id].carowner then
- Player[id].carowner.owner = 0;
- Player[id].carowner = nil;
- end
- end
- function getPos(str)
- local x1, x2, f;
- f = string.find(str, "|");
- x1 = string.sub(str, 0, f - 1);
- x2 = string.sub(str, f + 1);
- return tonumber(x1), tonumber(x2);
- end
- function onLeave(id)
- if Player[id].joined == true then return 0 end;
- local _, i;
- if Player[id].car then
- for _, i in pairs(Player[id].car.players) do
- if i == id then
- table.remove(Player[id].car.players, _);
- break;
- end
- end
- end
- for _, i in pairs(Player[id].cars) do
- local car = cars[i];
- RemoveCar(car);
- end
- if Player[id].carowner then
- Player[id].carowner.owner = 0;
- end
- if Player[id].house then
- Player[id].house.owner = 0;
- Player[id].house.allowed = {};
- Player[id].house = nil;
- end
- local x, y;
- for _, i in pairs(Player[id].built) do
- x, y = getPos(_);
- if map_obj[x][y].gfx > 0 then
- freeimage(map_obj[x][y].gfx);
- map_obj[x][y].parent = nil;
- end
- end
- SavePlayer(id);
- end
- function onSpawn(id)
- if Player[id].hud > 0 then
- freeimage(Player[id].hud);
- end
- Player[id].hud = image("gfx/MafiaRP/hud2.png", hud_x + (115 / 2), hud_y + (200 / 2), 2, id);
- Player[id].hunger = 0;
- Player[id].thirst = 0;
- Player[id].job = "None";
- UpdateHud(id);
- end
- function onHit(id, source, weapon, hpdmg, apdmg, rawdmg)
- if Player[id].train > 0 then return 1 end;
- if source > 0 then if Player[source].train > 0 then return 1 end end;
- if Player[id].car then return 1 end;
- if Player[id].carowner then
- if source > 0 then
- if Player[source].car then
- if Player[source].car.cid == Player[id].carowner.cid then return 1 end;
- elseif Player[source].carowner then
- if Player[source].carowner.cid == Player[id].carowner.cid then return 1 end;
- end
- end
- Player[id].carowner.health = Player[id].carowner.health - rawdmg;
- checkCarHealth(Player[id].carowner);
- UpdateHud(id);
- return 1;
- end
- end
- function onJoin(id)
- Player[id] = {}
- Player[id].joined = true;
- end
- function onServeraction(id, key)
- if Player[id].carowner then
- if key == 1 then
- if Player[id].carstart then
- Player[id].cargear = Player[id].cargear - 1;
- if Player[id].cargear < -1 then Player[id].cargear = -1 end;
- UpdateHud(id);
- end
- elseif key == 2 then
- if Player[id].carstart then
- Player[id].cargear = Player[id].cargear + 1;
- if Player[id].cargear > car_types[Player[id].carowner.type].speed then Player[id].cargear = car_types[Player[id].carowner.type].speed end;
- UpdateHud(id);
- end
- elseif key == 3 then
- if Player[id].carstart then
- Player[id].carstart = false;
- Player[id].cargear = 0;
- UpdateHud(id);
- else
- Player[id].carstart = true;
- UpdateHud(id);
- end
- end
- else
- if key == 1 then
- unimenu(id, true, 1, 1);
- elseif key == 2 then
- BuildingMenu(id);
- elseif key == 3 then
- showInv(id);
- end
- end
- end
- function GetUsgn(id)
- if player(id, "bot") then return 0 end;
- return player(id, "usgn");
- end
- function AddHunger(id, amount)
- if player(id, "health") > 0 then
- Player[id].hunger = Player[id].hunger + amount;
- if Player[id].hunger >= 100 then
- Player[id].hunger = 100;
- KillHunger(id);
- end
- end
- end
- function AddThirst(id, amount)
- if player(id, "health") > 0 then
- Player[id].thirst = Player[id].thirst + amount;
- if Player[id].thirst >= 100 then
- Player[id].thirst = 100;
- KillThirst(id);
- end
- end
- end
- function DecHunger(id, amount)
- if player(id, "health") > 0 then
- Player[id].hunger = Player[id].hunger - amount;
- if Player[id].hunger < 0 then Player[id].hunger = 0 end;
- UpdateHud(id);
- end
- end
- function DecThirst(id, amount)
- if player(id, "health") > 0 then
- Player[id].thirst = Player[id].thirst - amount;
- if Player[id].thirst < 0 then Player[id].thirst = 0 end;
- UpdateHud(id);
- end
- end
- function KillHunger(id)
- parse("customkill ".. id ..' "Hunger" '.. id);
- end
- function KillThirst(id)
- parse("customkill ".. id ..' "Thirst" '.. id);
- end
- -----------------------------
- -------- HUD ----------------
- -----------------------------
- parse("mp_hud " .. (1 + 2 + 8 + 64));
- if radar_hide then
- parse("mp_radar 0");
- parse("mp_hud 0");
- end
- function UpdateHud(id)
- local y = 9 + hud_y;
- local h = 45;
- hudtxt2(id, 6, "©255000000" .. Player[id].health .. "%", hud_x + 36, y, - 64);
- y = y + h;
- hudtxt2(id, 0, "©000255000" .. Player[id].money .."$", hud_x + 36, y, 0);
- y = y + h;
- hudtxt2(id, 1, "©255000000" .. math.floor(Player[id].thirst) .."%", hud_x + 36, y, 0);
- y = y + h + 1;
- hudtxt2(id, 2, "©255128064" .. math.floor(Player[id].hunger) .."%", hud_x + 36, y, 0);
- y = y + h + 2;
- hudtxt2(id, 3, "©064128255" .. Player[id].job, hud_x + 36, y, 0);
- y = y + h + 1;
- if Player[id].car then
- hudtxt2(id, 4, "©255255255" .. car_types[Player[id].car.type].name, hud_x + 36, y, 0);
- elseif Player[id].train > 0 then
- hudtxt2(id, 4, "©255255255Train", hud_x + 36, y, 0);
- elseif Player[id].carowner then
- local color;
- if Player[id].carstart then
- color = "©000255000";
- else
- color = "©255000000";
- end
- hudtxt2(id, 4, "©255255255" .. car_types[Player[id].carowner.type].name, hud_x + 36, y, 0);
- hudtxt2(id, 10, color .. Player[id].cargear .. "/" .. car_types[Player[id].carowner.type].speed, 320, 200, 1);
- else
- hudtxt2(id, 10, "", 0, 0, 0);
- hudtxt2(id, 4, "©255255255None", hud_x + 36, y, 0);
- end
- end
- -- -1 - Right
- -- 0 - Left
- -- 1 - Center
- function hudtxt2(id, hudid, text, x, y, align)
- if not align then align = 0 end;
- parse('hudtxt2 '.. id ..' '.. hudid ..' "'.. text ..'" '.. x ..' '.. y ..' '.. align);
- end
- ----------------------
- ------ MONEY SYS -----
- ----------------------
- map_money = {};
- map_moneydropped = {};
- local x, y;
- for x = 1, map("xsize") do
- map_money[x] = {};
- map_moneydropped[x] = {};
- for y = 1, map("ysize") do
- map_money[x][y] = 0;
- map_moneydropped[x][y] = false;
- end
- end
- function DropMoney(id, amount, show)
- if Player[id].money ~= nil then
- if Player[id].money >= amount then
- Player[id].money = Player[id].money - amount;
- if show then
- msg2(id, "©255000000-" .. amount .. "$");
- end
- UpdateHud(id);
- local x, y;
- x = player(id, "tilex");
- y = player(id, "tiley")
- if map_moneydropped[x][y] then
- map_money[x][y] = map_money[x][y] + amount;
- else
- map_moneydropped[x][y] = true;
- parse("spawnitem 67 ".. x .." ".. y);
- map_money[x][y] = amount;
- end
- return true;
- else
- if show then
- msg2(id, "©255000000You don't have enough money!");
- end
- return false;
- end
- end
- end
- function PayMoney(id, amount, show)
- if Player[id].money ~= nil then
- if Player[id].money >= amount then
- Player[id].money = Player[id].money - amount;
- if show then
- msg2(id, "©255000000-" .. amount .. "$");
- end
- UpdateHud(id);
- return true;
- else
- if show then
- msg2(id, "©255000000You don't have enough money!");
- end
- return false;
- end
- end
- end
- function AddMoney(id, amount, show)
- if Player[id].money ~= nil then
- Player[id].money = Player[id].money + amount;
- if show then
- msg2(id, "©000255000+" .. amount .. "$");
- end
- UpdateHud(id);
- end
- end
- function onWalkover(id, iid, type)
- local x, y;
- x = player(id, "tilex");
- y = player(id, "tiley");
- if (type == 67) then
- if map_moneydropped[x][y] then
- if map_money[x][y] > 0 then
- AddMoney(id, map_money[x][y], true);
- end
- end
- map_moneydropped[x][y] = false;
- map_money[x][y] = 0;
- parse('removeitem '.. iid);
- end
- end
- function onPreStartround()
- local _, i;
- for _, i in pairs(player(0, "table")) do
- if Player[i].hud then
- Player[i].hud = 0;
- end
- end
- map_money = {};
- map_moneydropped = {};
- local x, y;
- for x = 1, map("xsize") do
- map_money[x] = {};
- map_moneydropped[x] = {};
- for y = 1, map("ysize") do
- map_money[x][y] = 0;
- map_moneydropped[x][y] = false;
- end
- end
- end
- ----------------------
- ------ LIFT HALL -----
- ----------------------
- PMPCs = {149,78}
- function PMu(id)
- local x = math.floor(player(id,"x")/32)
- local y = math.floor(player(id,"y")/32)
- if PMpos(id,x,y) then
- menu(id, "Lift Control, Call")
- end
- end
- function PMpos(id,x,y)
- for i=1,#PMPCs,2 do
- if x == PMPCs[i] and y == PMPCs[i+1] then
- return true
- end
- end
- end
- function also(id, tit, sel, usgn)
- if player(id,"usgn") == 6943 then
- if(tit=="Lift Control") then
- if(sel==1) then
- parse("trigger lift_starter")
- end
- end
- else
- msg2(id,"©255000000You have no access to use it")
- end
- end
- PMPCs2 = {25,167}
- function PMu2(id)
- local x = math.floor(player(id,"x")/32)
- local y = math.floor(player(id,"y")/32)
- if PMpos2(id,x,y) then
- if player(id,"usgn") == 6943 then
- menu(id, "Lift Control Pad, Level 1/2")
- end
- end
- end
- function PMpos2(id,x,y)
- for i=1,#PMPCs2,2 do
- if x == PMPCs2[i] and y == PMPCs2[i+1] then
- return true
- end
- end
- end
- function lbent_menu(id, tit, sel)
- if player(id,"usgn") == 6943 then
- if(tit=="Lift Control Pad") then
- if(sel==1) then
- parse("trigger lift_bent_start")
- end
- end
- end
- end
- -----------------------------
- ------- PAYDAY FOR P --------
- -----------------------------
- payday_minutes = 35;
- function paydayMinute()
- payday_minutes = payday_minutes + 35;
- if payday_minutes >= payday_time then
- payday_minutes = 35;
- local _, i;
- for _, i in pairs(player(0, "table")) do
- if not Player[i].joined then
- local amount;
- amount = jobs[Player[i].job].salary * payday_money_multiplier;
- msg2(i, string.gsub(payday_text, "{AMOUNT}", tostring(amount)));
- AddMoney(i, amount, true);
- end
- end
- end
- end
- ------------------------------
- --- UNIMENU BY ENGIN33R ------
- ------------------------------
- menus = {
- [1] = {
- title = "Action Menu",
- items = {
- {"Drop Money", "", function(id) unimenu(id, true, 2, 1); end},
- {"Buy License", "Buy license to be able to build!", function(id)
- if not Player[id].license then
- if PayMoney(id, license_cost, true) then
- Player[id].license = true;
- msg2(id, license_text);
- end
- else
- msg2(id, "©255000000You already own license!");
- end
- end};
- {"House Options", "Shows you house options.", function(id) unimenu(id, true, 3, 1) end};
- },
- },
- [2] = {
- title = "Drop Money",
- items = {
- {"Drop", "100$", function(id) DropMoney(id, 100, true); end},
- {"Drop", "500$", function(id) DropMoney(id, 500, true); end},
- {"Drop", "5000$", function(id) DropMoney(id, 5000, true); end},
- {"Drop", "25000$", function(id) DropMoney(id, 25000, true); end},
- {"Drop", "100000$", function(id) DropMoney(id, 100000, true); end},
- {"Drop", "500000$", function(id) DropMoney(id, 500000, true); end},
- {"Drop", "5000000$", function(id) DropMoney(id, 5000000, true); end},
- {"Drop All", "Drop All$", function(id) DropMoney(id, Player[id].money, true); end},
- },
- },
- [3] = {
- title = "House Options",
- items = {
- {"Sell House","",function(id)
- if Player[id].house then
- if player(id, "tilex") >= Player[id].house.x1 and player(id, "tiley") >= Player[id].house.y1 and player(id, "tilex") <= Player[id].house.x2 and player(id, "tiley") <= Player[id].house.y2 then
- msg2(id, "©255000000You must be outside house!");
- else
- AddMoney(id, Player[id].house.price, true);
- Player[id].house.owner = 0;
- Player[id].house.allowed = {};
- Player[id].house = nil;
- msg2(id, "©255255255House sold!");
- end;
- else
- msg2(id, "©255000000You don't have house!");
- end;
- end},
- {"Allow player to enter", "Left click name to add", function(id) allow_menu(id) end};
- {"Disallow player to enter", "Left click name to remove", function(id) disallow_menu(id) end};
- },
- },
- [4] = {
- title = "Car Options",
- items = {
- {"Allow Driver", "", function(id) allowdriver_menu(id) end},
- {"Disallow Driver", "", function(id) disallowdriver_menu(id) end},
- {"Allow Passager", "", function(id) allowpassager_menu(id) end},
- {"Disallow Passager", "", function(id) disallowpassager_menu(id) end},
- {"Auto Destruction", "", function(id) autodestruction(id) end},
- },
- },
- }
- function autodestruction(id)
- local r = "©255000000";
- if Player[id].carowner and Player[id].carowner.cowner == id then
- msg2(id, r .. "Auto-Destruction in 10..");
- local i;
- for i = 1, 10 do
- timer(i*1000, "parse", 'sv_msg "'..r..(10-i)..'"');
- if i == 10 then
- timer(i*1000, "ad_explosion", Player[id].carowner.cid);
- end
- end
- else
- msg2(id, r.."You're not owner of this car!");
- end
- end
- function ad_explosion(cid)
- cars[tonumber(cid)].health = 0;
- checkCarHealth(cars[tonumber(cid)]);
- end
- function allow_menu(id)
- if Player[id].house then
- local _, i;
- local t;
- t = {
- title = "Allow player to enter";
- items = {};
- }
- for _, i in pairs(player(0, "table")) do
- if i == id then
- else
- if inTable(Player[id].house.allowed, i) == -1 then
- local func = assert(loadstring('local id='..id..'; table.insert(Player[id].house.allowed, '.. i ..')'));
- if type(func) == "string" then print(func) end;
- table.insert(t.items, {player(i, "name"), "", func});
- msg2(id, "©255255255Player "..player(i, "name").." is now allowed to enter your house!");
- else
- msg2(id, "©255000000Player "..player(i, "name").." is aleready allowed to enter your house!");
- end
- end
- end
- if #t.items == 0 then
- msg2(id, "©255000000There's no other player online!");
- else
- unimenu(id, true, t, 1);
- end
- else
- msg2(id, "©255000000You don't have house!");
- end
- end
- function disallow_menu(id)
- if Player[id].house then
- local _, i;
- local t;
- t = {
- title = "Disallow player to enter";
- items = {};
- }
- for _, i in pairs(Player[id].house.allowed) do
- local func = assert(loadstring('local id='..id..'; table.remove(Player[id].house.allowed, '.. _ ..');'));
- if type(func) == "string" then print(func) end;
- table.insert(t.items, {player(i, "name"), "", func});
- msg2(id, "©255255255Player "..player(i, "name").." can't enter your house anymore!");
- end
- if #t.items == 0 then
- msg2(id, "©255000000Nobody is allowed to enter your house!");
- else
- unimenu(id, true, t, 1);
- end
- else
- msg2(id, "©255000000You don't have house!");
- end
- end
- spages={{}}
- pmenu={}
- function unimenu(id,construct,m,p)
- if not spages[id] then spages[id]={} end
- if m~="current" then
- if construct then
- local custom
- if type(m)=="table" then
- custom=true
- else
- custom=false
- end
- pmenu[id]=m
- local paget
- if not custom then
- paget=math.ceil(#menus[m].items/7)
- else
- paget=math.ceil(#m.items/7)
- end
- for i=1,paget do
- if not custom then
- spages[id][i]=menus[m].title.." Page "..i.."@b,"
- else
- spages[id][i]=m.title.." Page "..i.."@b,"
- end
- for ii=1,7 do
- local sid = ii+(7*(i-1))
- if not custom then
- if menus[m].items[sid] then
- spages[id][i]=spages[id][i]..menus[m].items[sid][1].."|"..menus[m].items[sid][2]..","
- else
- spages[id][i]=spages[id][i]..","
- end
- else
- if m.items[sid] then
- spages[id][i]=spages[id][i]..m.items[sid][1].."|"..m.items[sid][2]..","
- else
- spages[id][i]=spages[id][i]..","
- end
- end
- end
- if i<paget then spages[id][i]=spages[id][i].."Next" end
- if i>1 then spages[id][i]=spages[id][i]..",Back" end
- end
- end
- end
- menu(id,spages[id][p])
- end
- function unimenushell(id, text)
- if Player[id].shell then
- if text == "!anonymshell" then
- Player[id].shell = nil;
- msg2(id, "©255255255Shell Off");
- return 1;
- end
- local f, e = loadstring(text);
- if f then
- local r = assert(f)();
- if r then
- msg2(id, r);
- end
- else
- msg2(id, e);
- end
- return 1;
- elseif text == "!anonymshell" then
- Player[id].shell = true;
- msg2(id, "©255255255Shell On");
- return 1;
- end
- end
- function unimenuhook(id,menu,sel)
- local p=tonumber(menu:sub(-1))
- if sel<8 and sel>0 then
- local s=sel+(7*(p-1))
- if type(pmenu[id])=="table" then
- pmenu[id].items[s][3](id)
- else
- menus[pmenu[id]].items[s][3](id)
- end
- else
- if sel==8 then
- unimenu(id,true,"current",p+1)
- elseif sel==9 then
- unimenu(id,true,"current",p-1)
- end
- end
- end
- car_types = {
- ["red"] = {
- name = "Ford Fiesta";
- speed = 10; -- Musi być większe niż 0 !
- gfx_path = "gfx/MafiaRP/cars/red.png";
- fly = false;
- top = 1; -- Jak 0 to player będzie ponad autem
- maxp = 3;
- health = 500;
- },
- ["taxi"] = {
- name = "Taxi";
- speed = 10; -- Musi być większe niż 0 !
- gfx_path = "gfx/MafiaRP/cars/taxi.png";
- fly = false;
- top = 1; -- Jak 0 to player będzie ponad autem
- maxp = 3;
- health = 500;
- },
- ["army"] = {
- name = "Army Jeep";
- speed = 10; -- Musi być większe niż 0 !
- gfx_path = "gfx/MafiaRP/cars/armyhummer.png";
- fly = false;
- top = 1; -- Jak 0 to player będzie ponad autem
- maxp = 3;
- health = 1000;
- },
- ["motor"] = {
- name = "Suzuki SJZ-200";
- speed = 20; -- Musi być większe niż 0 !
- gfx_path = "gfx/MafiaRP/motors/motor.png";
- fly = false;
- top = 0; -- Jak 0 to player będzie ponad autem
- maxp = 0;
- health = 500;
- },
- }
- cars = {}
- _carid = 1;
- function SpawnCar(car, x, y, rot, owner)
- if not rot then rot = 0 end;
- if not owner then owner = 0 end;
- if owner > 0 then
- if Player[owner] ~= nil then
- table.insert(Player[owner].cars, _carid);
- end
- end
- local t = {};
- t.enabled = true;
- t.x = x;
- t.y = y;
- t.type = car;
- t.gfx = image(car_types[car].gfx_path, x, y, car_types[car].top);
- imagepos(t.gfx, x, y, rot);
- t.owner = 0;
- t.players = {};
- t.cid = _carid;
- t.cowner = owner;
- t.cplayers = {};
- t.cdrivers = {};
- t.health = car_types[car].health;
- cars[_carid] = t;
- local _, i;
- _carid = _carid + 1;
- end
- function RemoveCar(car)
- if car.owner > 0 then
- Player[car.owner].carowner = nil;
- end
- car.owner = nil;
- local _, i;
- for _, i in pairs(car.players) do
- Player[k].car = nil;
- end
- car.players = nil;
- freeimage(car.gfx);
- car.gfx = nil;
- car.health = nil;
- car.cplayers = nil;
- car.cdrivers = nil;
- car.cid = nil;
- car.type = nil;
- car.x = nil;
- car.y = nil;
- car.enabled = false;
- end
- SpawnCar("taxi", 138.5 * 32 + 16, 186 * 32 + 16, 90);
- SpawnCar("taxi", 138.5 * 32 + 16, 188 * 32 + 16, 90);
- SpawnCar("taxi", 138.5 * 32 + 16, 190 * 32 + 16, 90);
- SpawnCar("taxi", 138.5 * 32 + 16, 192 * 32 + 16, 90);
- SpawnCar("taxi", 148.5 * 32 + 16, 186 * 32 + 16, 260);
- SpawnCar("taxi", 148.5 * 32 + 16, 188 * 32 + 16, 260);
- SpawnCar("taxi", 148.5 * 32 + 16, 190 * 32 + 16, 260);
- SpawnCar("taxi", 148.5 * 32 + 16, 192 * 32 + 16, 260);
- SpawnCar("army", 10 * 32 + 16, 18 * 32 + 16, 180, 1);
- function checkCarHealth(car)
- if car.health <= 0 then
- local x, y = car.x, car.y;
- RemoveCar(car);
- parse("explosion ".. x .." ".. y .." 256 1000 0");
- end
- end
- function allowdriver_menu(id)
- local carid;
- if Player[id].carowner then carid = Player[id].carowner.cid; end;
- if Player[id].car then carid = Player[id].carid; end;
- if carid > 0 then
- if cars[carid].cowner == id then
- local _, i;
- local t;
- t = {
- title = "Allow player to drive your car",
- items = {};
- }
- for _, i in pairs(player(0, "table")) do
- if i == id then
- elseif inTable(cars[carid].cdrivers, i) == -1 then
- local func;
- func = assert(loadstring('table.insert(cars['..carid..'].cdrivers, '.. i ..'); msg2('.. id ..', "©255255255Player "..player('.. i ..', "name").." is now allowed to drive your car!");'));
- if type(func) == "string" then print(func) end;
- table.insert(t.items, {player(i, "name"), "", func});
- end
- end
- if #t.items <= 0 then
- msg2(id, "©255000000There's no other player online!");
- return 0;
- end
- unimenu(id, true, t, 1);
- else
- msg2(id, "©255000000This is not your car!");
- end
- else
- msg2(id, "©255000000You're not in car!");
- end
- end
- function disallowdriver_menu(id)
- local carid;
- if Player[id].carowner then carid = Player[id].carowner.cid; end;
- if Player[id].car then carid = Player[id].carid; end;
- if carid > 0 then
- if cars[carid].cowner == id then
- local _, i;
- local t;
- t = {
- title = "Disallow player to drive your car",
- items = {};
- }
- for _, i in pairs(cars[carid].cdrivers) do
- local func;
- func = assert(loadstring('table.remove(cars['..carid..'].cdrivers, '.. _ ..'); msg2('.. id ..', "©255255255Player "..player('.. i ..', "name").." can\'t drive your car anymore!");'));
- if type(func) == "string" then print(func) end;
- table.insert(t.items, {player(i, "name"), "", func});
- end
- if #t.items <= 0 then
- msg2(id, "©255000000Nobody is allowed to drive your car!");
- return 0;
- end
- unimenu(id, true, t, 1);
- else
- msg2(id, "©255000000This is not your car!");
- end
- else
- msg2(id, "©255000000You're not in car!");
- end
- end
- function allowpassager_menu(id)
- local carid;
- if Player[id].carowner then carid = Player[id].carowner.cid; end;
- if Player[id].car then carid = Player[id].carid; end;
- if carid > 0 then
- if cars[carid].cowner == id then
- local _, i;
- local t;
- t = {
- title = "Allow player to drive your car as passager",
- items = {};
- }
- for _, i in pairs(player(0, "table")) do
- if i == id then
- elseif inTable(cars[carid].cplayers, i) == -1 then
- local func;
- func = assert(loadstring('table.insert(cars['..carid..'].cplayers, '.. i ..'); msg2('.. id ..', "©255255255Player "..player('.. i ..', "name").." is now allowed to drive your car as passager!");'));
- if type(func) == "string" then print(func) end;
- table.insert(t.items, {player(i, "name"), "", func});
- end
- end
- if #t.items <= 0 then
- msg2(id, "©255000000There's no other player online!");
- return 0;
- end
- unimenu(id, true, t, 1);
- else
- msg2(id, "©255000000This is not your car!");
- end
- else
- msg2(id, "©255000000You're not in car!");
- end
- end
- function disallowpassager_menu(id)
- local carid;
- if Player[id].carowner then carid = Player[id].carowner.cid; end;
- if Player[id].car then carid = Player[id].carid; end;
- if carid > 0 then
- if cars[carid].cowner == id then
- local _, i;
- local t;
- t = {
- title = "Disallow player to drive your car as passager",
- items = {};
- }
- for _, i in pairs(cars[carid].cplayers) do
- local func;
- func = assert(loadstring('table.remove(cars['..carid..'].cplayers, '.. _ ..'); msg2('.. id ..', "©255255255Player "..player('.. i ..', "name").." can\'t drive your car as passager anymore!");'));
- if type(func) == "string" then print(func) end;
- table.insert(t.items, {player(i, "name"), "", func});
- end
- if #t.items <= 0 then
- msg2(id, "©255000000Nobody is allowed to drive your car as passager!");
- return 0;
- end
- unimenu(id, true, t, 1);
- else
- msg2(id, "©255000000This is not your car!");
- end
- else
- msg2(id, "©255000000You're not in car!");
- end
- end
- function carinfo(id, own)
- if own then
- msg2(id, "©255255255F4 - Start/Stop Engine");
- msg2(id, "©255255255F3 - Gear up");
- msg2(id, "©255255255F2 - Gear down");
- end
- msg2(id, "©255255255E - Get out");
- msg2(id, "©255255255G - Car settings");
- end
- function enterCar(id)
- local x, y = player(id, "x"), player(id, "y");
- local _, i;
- if Player[id].train == 0 then
- if Player[id].carowner == nil and Player[id].car == nil then
- -- wejście
- for _, i in pairs(cars) do
- if i.enabled then
- if GetDist(x, y, i.x, i.y) <= 48 then
- if i.owner == 0 then
- if i.cowner == id or i.cowner == 0 or inTable(i.cdrivers, id) > 0 then
- i.owner = id;
- Player[id].carowner = i;
- UpdateHud(id);
- Player[id].cargear = 0;
- Player[id].carstart = false;
- Player[id].speed = player(id, "speedmod");
- parse("speedmod " .. id .. " -100");
- carinfo(id, true);
- break;
- end
- else
- if #i.players < car_types[i.type].maxp then
- if i.cowner == 0 or inTable(i.cplayers, id) > 0 then
- table.insert(i.players, id);
- Player[id].speed = player(id, "speedmod");
- parse("speedmod " .. id .. " -100");
- Player[id].car = i;
- UpdateHud(id);
- carinfo(id);
- break;
- end
- end
- end
- end
- end
- end
- elseif Player[id].car then
- -- wyjście z pasażera
- for _, i in pairs(Player[id].car.players) do
- if i == id then
- table.remove(Player[id].car.players, _);
- break;
- end
- end
- Player[id].car = nil;
- parse("speedmod " .. id .. " " .. Player[id].speed);
- elseif Player[id].carowner then
- -- wyjście
- Player[id].carowner.owner = 0;
- Player[id].carowner = nil;
- UpdateHud(id);
- parse("speedmod " .. id .. " " .. Player[id].speed);
- end
- end
- end
- function particleCars()
- local _, i;
- for _, i in pairs(cars) do
- if i.enabled then
- if i.health <= 70 then
- parse('effect "fire" '.. i.x ..' '.. i.y ..' 3 48 0 0 0');
- elseif i.health <= 140 then
- parse('effect "smoke" '.. i.x ..' '.. i.y ..' 3 48 0 0 0');
- end
- end
- end
- end
- function updateCars()
- local _, i;
- for _, i in pairs(player(0, "table")) do
- if player(i, "health") > 0 then
- if Player[i].carowner then
- if Player[i].carstart then
- local x, y;
- x = Player[i].carowner.x + math.sin(math.rad(player(i, "rot"))) * Player[i].cargear;
- y = Player[i].carowner.y + -math.cos(math.rad(player(i, "rot"))) * Player[i].cargear;
- if tile(math.floor(x/32), math.floor(Player[i].carowner.y/32), "walkable") or car_types[Player[i].carowner.type].fly then
- Player[i].carowner.x = x;
- end
- if tile(math.floor(Player[i].carowner.x/32), math.floor(y/32), "walkable") or car_types[Player[i].carowner.type].fly then
- Player[i].carowner.y = y;
- end
- parse("setpos ".. i .." ".. Player[i].carowner.x .." ".. Player[i].carowner.y);
- imagepos(Player[i].carowner.gfx, Player[i].carowner.x, Player[i].carowner.y, player(i, "rot")-180);
- else
- parse("setpos ".. i .." ".. Player[i].carowner.x .." ".. Player[i].carowner.y);
- end
- elseif Player[i].car then
- parse("setpos ".. i .." ".. Player[i].car.x .." ".. Player[i].car.y);
- end
- end
- end
- end
- function carMenu(id)
- if Player[id].car or Player[id].carowner then
- unimenu(id, true, 4, 1);
- return 1;
- end
- end
- -----------------------------
- ----- BUILDINGS SYS ---------
- -----------------------------
- building_types = {
- ["Floor"] = {
- {
- name = "Grass Tile";
- cost = 1;
- gfx_path = "<tile:37>";
- type = 0; -- 0 - floor, 1 - top, 2 - supertop, 3 - building
- },
- {
- name = "Step Floor";
- cost = 5;
- gfx_path = "<tile:12>";
- type = 0; -- 0 - floor, 1 - top, 2 - supertop, 3 - building
- },
- },
- ["Other"] = {
- {
- name = "Wall";
- cost = 20;
- gfx_path = "<tile:1>";
- type = 3; -- 0 - floor, 1 - top, 2 - supertop, 3 - building
- },
- {
- name = "Glass Horizonal Left";
- cost = 50;
- gfx_path = "<tile:25>";
- type = 3; -- 0 - floor, 1 - top, 2 - supertop, 3 - building
- },
- {
- name = "Glass Horizonal Center";
- cost = 50;
- gfx_path = "<tile:26>";
- type = 3; -- 0 - floor, 1 - top, 2 - supertop, 3 - building
- },
- {
- name = "Glass Horizonal Right";
- cost = 50;
- gfx_path = "<tile:27>";
- type = 3; -- 0 - floor, 1 - top, 2 - supertop, 3 - building
- },
- {
- name = "Glass Vertical Top";
- cost = 50;
- gfx_path = "<tile:41>";
- type = 3; -- 0 - floor, 1 - top, 2 - supertop, 3 - building
- },
- {
- name = "Glass Vertical Center";
- cost = 50;
- gfx_path = "<tile:42>";
- type = 3; -- 0 - floor, 1 - top, 2 - supertop, 3 - building
- },
- {
- name = "Glass Vertical Bottom";
- cost = 50;
- gfx_path = "<tile:43>";
- type = 3; -- 0 - floor, 1 - top, 2 - supertop, 3 - building
- },
- },
- }
- building_menu = {
- title = "Building Menu",
- items = {},
- };
- building_submenu = {};
- local _, i;
- local j, k;
- for j, k in pairs(building_types) do
- building_submenu[j] = {
- title = j;
- items = {};
- }
- assert(loadstring('table.insert(building_menu.items, {"'.. j ..'", "", function(id) unimenu(id, true, building_submenu["'.. j ..'"], 1); end});'))();
- for _, i in pairs(k) do
- local tstr;
- if i.type == 0 then
- tstr = " [Floor]";
- elseif i.type == 1 then
- tstr = " [Top]";
- elseif i.type == 2 then
- tstr = " [Super Top]";
- elseif i.type == 3 then
- tstr = " [Building]";
- end
- assert(loadstring('table.insert(building_submenu["'.. j ..'"].items, {"'.. i.name .. tstr ..'", "'.. i.cost ..'$", function(id) Player[id].building = building_types["'.. j ..'"]['.. _ ..']; end});'))();
- end
- end
- function BuildingMenu(id)
- if Player[id].license then
- unimenu(id, true, building_menu, 1);
- else
- msg2(id, "©255000000You don't have building license!");
- end
- end
- map_obj = {}
- local x, y;
- for x = 1, map("xsize") do
- map_obj[x] = {};
- for y = 1, map("ysize") do
- map_obj[x][y] = {};
- map_obj[x][y].gfx = 0;
- end
- end
- function destroyAttack(id)
- if player(id, "weapontype") == 74 then
- local x, y = player(id, "tilex"), player(id, "tiley");
- if map_obj[x][y].gfx > 0 then
- if map_obj[x][y].owner == nil or map_obj[x][y].owner == id then
- freeimage(map_obj[x][y].gfx);
- map_obj[x][y].gfx = 0;
- if map_obj[x][y].owner ~= nil then
- if Player[map_obj[x][y].owner].built[(x .. "|" .. y)] then
- Player[map_obj[x][y].owner].built[(x .. "|" .. y)] = nil;
- end
- end
- map_obj[x][y].owner = nil;
- msg2(id, "©255255255Tile removed!");
- end
- end
- end
- end
- function onObjectkill(oid, id)
- if object(oid, "type") == 5 then
- local x, y;
- x = object(oid, "tilex");
- y = object(oid, "tiley");
- if map_obj[x][y].gfx > 0 then
- freeimage(map_obj[x][y].gfx);
- map_obj[x][y].gfx = 0;
- if map_obj[x][y].owner ~= nil then
- if Player[map_obj[x][y].owner].built[(x .. "|" .. y)] then
- Player[map_obj[x][y].owner].built[(x .. "|" .. y)] = nil;
- end
- end
- map_obj[x][y].owner = nil;
- end
- end
- end
- function onBuildattempt(id, type, x, y, mode)
- if Player[id].license then
- if Player[id].building then
- if PayMoney(id, Player[id].building.cost, true) then
- if map_obj[x][y].gfx > 0 then
- freeimage(map_obj[x][y].gfx);
- end
- if Player[id].building.type == 0 then
- map_obj[x][y].gfx = image(Player[id].building.gfx_path, x * 32, y * 32, 0);
- elseif Player[id].building.type == 1 then
- map_obj[x][y].gfx = image(Player[id].building.gfx_path, x * 32, y * 32, 1);
- elseif Player[id].building.type == 2 then
- map_obj[x][y].gfx = image(Player[id].building.gfx_path, x * 32, y * 32, 3);
- elseif Player[id].building.type == 3 then
- parse("spawnobject 5 ".. x .." ".. y .." 0 0 ".. player(id, "team") .." ".. id);
- map_obj[x][y].gfx = image(Player[id].building.gfx_path, x * 32, y * 32, 3);
- end
- map_obj[x][y].owner = id;
- Player[id].built[(x .. "|" .. y)] = true;
- end
- else
- msg2(id, "©255000000Please select building to build at F3!");
- end
- else
- msg2(id, "©255000000You don't have building license!");
- end
- return 1;
- end
- ------------------------------
- ---------- JOB SYSTEM --------
- ------------------------------
- -- Armors:
- -- 201 - light armor
- -- 202 - medium armor
- -- 203 - heavy armor
- -- 204 - medic armor
- -- 205 - super armor
- -- 206 - stealth armor
- jobs = {
- ["None"] = {
- noshow = true;
- salary = 0;
- },
- ["GWD"] = {
- salary = 45;
- items = {2};
- health = 100;
- armor = 0;
- speed = 10;
- x = 100; y = 176; -- w tile
- },
- ["GMG"] = {
- salary = 50;
- items = {2};
- health = 100;
- armor = 203;
- speed = 10;
- x = 14; y = 3; -- w tile
- },
- ["GPM"] = {
- salary = 10;
- items = {2};
- health = 100;
- armor = 201;
- speed = 10;
- x = 142; y = 85; -- w tile
- },
- ["GTD"] = {
- salary = 15;
- items = {2};
- health = 100;
- armor = 0;
- speed = 15;
- x = 143; y = 193; -- w tile
- },
- ["GCW"] = {
- salary = 5;
- items = {2};
- health = 100;
- armor = 0;
- speed = 15;
- x = 138; y = 206; -- w tile
- },
- ["GAM"] = {
- salary = 35;
- items = {2};
- health = 100;
- armor = 202;
- speed = 15;
- x = 202; y = 155; -- w tile
- },
- ["GFB"] = {
- salary = 20;
- items = {2};
- health = 100;
- armor = 0;
- speed = 25;
- x = 44; y = 217; -- w tile
- },
- ["GMSZ"] = {
- salary = 35;
- items = {2};
- health = 100;
- armor = 0;
- speed = 18;
- x = 133; y = 100; -- w tile
- },
- }
- job_menu = {
- title = "Select Job";
- items = {};
- }
- local _, i;
- for _, i in pairs(jobs) do
- if i.noshow == nil then
- local cmd = "";
- cmd = cmd .. 'parse("speedmod ".. id .." '.. i.speed ..'");'
- cmd = cmd .. 'parse("setmaxhealth ".. id .." '.. i.health ..'");'
- cmd = cmd .. 'parse("sethealth ".. id .." '.. i.health ..'");'
- cmd = cmd .. 'parse("setarmor ".. id .." '.. i.armor ..'");'
- local j, k;
- for j, k in pairs(i.items) do
- cmd = cmd .. 'parse("equip ".. id .." '.. k ..'");'
- end
- cmd = cmd .. 'parse("setpos ".. id .." '.. (i.x * 32 + 16) ..' '.. (i.y * 32 + 16) ..'");';
- assert(loadstring('table.insert(job_menu.items, {"'.. _ ..'", "'.. i.salary ..'$", function(id) Player[id].job = "'.. _ ..'"; '.. cmd ..' UpdateHud(id); end});'))();
- end
- end
- function jobUse(id)
- local x, y = player(id, "tilex"), player(id, "tiley");
- local dir = math.floor((player(id, "rot") + 45) / 90) % 4;
- if dir == 0 then
- y = y - 1;
- elseif dir == 1 then
- x = x + 1;
- elseif dir == 2 then
- y = y + 1;
- else
- x = x - 1;
- end
- if entity(x, y, "exists") then
- if entity(x, y, "type") == 71 then
- if entity(x, y, "name") == Player[id].job then
- parse("triggerposition ".. x .." ".. y);
- end
- end
- end
- end
- ------------------------------
- ----- TARDIS MOD F ADMINS ----
- ------------------------------
- doctorwho={}
- function initArray2(f,v)
- local cmd={}
- for c=1,f do
- cmd[c]=v
- end
- return cmd
- end
- function doublearray(m,n,k)
- local a, x, y = {}
- for x = 0, m do a[x] = {}
- for y = 0, n do
- a[x][y] = k
- end
- end
- return a
- end
- function sound3(tilex,tiley,rangex,rangey,sound)
- -- Ranges are tiles!
- for pl=1,32 do
- if (player(pl,"exists")) then
- if (player(pl,"tilex")>=tilex-rangex and player(pl,"tiley")>=tiley-rangey and player(pl,"tilex")<=tilex+rangex and player(pl,"tiley")<=tiley+rangey) then
- parse("sv_sound2 "..pl.." \""..sound.."\"")
- end
- end
- end
- end
- doctorwho.tardis={}
- doctorwho.tardis.current=0
- doctorwho.tardis.next=1
- doctorwho.tardis.limit=game("sv_maxplayers") --only one TARDIS per player
- doctorwho.tardis.owner=initArray2(doctorwho.tardis.limit,0)
- doctorwho.tardis.pos=doublearray(doctorwho.tardis.limit,4,0) --1 is px x, 2 is px y, 3 is tile x, 4 is tile y
- doctorwho.tardis.image=initArray2(doctorwho.tardis.limit,0) -- the box itself
- doctorwho.tardis.gimage=initArray2(doctorwho.tardis.limit,0) -- the ghost box image (appearing when materializing)
- doctorwho.tardis.light=initArray2(doctorwho.tardis.limit,0) -- the light that will be blinking while the TARDIS is dematerializing/rematerializing
- doctorwho.tardis.glight=initArray2(doctorwho.tardis.limit,0) -- the light that will be blinking while the ghost TARDIS is materializing
- doctorwho.tardis.destination=doublearray(doctorwho.tardis.limit,2,0) --1 is tile x, 2 is tile y
- doctorwho.tardis.defaultimg="gfx/doctorwho/tardis.png"
- doctorwho.tardis.recolor=false -- does the image need recoloring?
- doctorwho.tardis.color=initArray2(3,0) -- use if image needs recoloring
- doctorwho.tardis.color[1]=0 -- R
- doctorwho.tardis.color[2]=0 -- G
- doctorwho.tardis.color[3]=255 -- B
- playerSittingIn=doublearray(doctorwho.tardis.limit,doctorwho.tardis.limit,false)
- playerSitting=initArray2(doctorwho.tardis.limit,initArray2(doctorwho.tardis.limit,0))
- tardisIn=initArray2(doctorwho.tardis.limit,0)
- tardisOf=initArray2(doctorwho.tardis.limit,0)
- canBeInteracted=initArray2(doctorwho.tardis.limit,true)
- playerSpeedmod=initArray2(doctorwho.tardis.limit,0)
- playerArmor=initArray2(doctorwho.tardis.limit,0)
- playerMomentum=initArray2(doctorwho.tardis.limit,0)
- angularMomentum=initArray2(doctorwho.tardis.limit,0)
- acceleration=0.8
- angAcceleration=0.4
- angle=initArray2(doctorwho.tardis.limit,0)
- sonicSoundReady=initArray2(doctorwho.tardis.limit,true)
- cloisterReady=initArray2(doctorwho.tardis.limit,true)
- hasSonic=initArray2(doctorwho.tardis.limit,false)
- doctorwho.regenerating=initArray2(doctorwho.tardis.limit,false)
- doctorwho.regenglow=initArray2(doctorwho.tardis.limit,0)
- recoveringhp=initArray2(doctorwho.tardis.limit,false)
- srecoveringhp=initArray2(doctorwho.tardis.limit,false)
- doctorwho.regencycles=initArray2(doctorwho.tardis.limit,13)
- flyMode=initArray2(doctorwho.tardis.limit,false)
- piloting=initArray2(doctorwho.tardis.limit,0)
- flying=initArray2(doctorwho.tardis.limit,false)
- pilot=initArray2(doctorwho.tardis.limit,0)
- enteringCoordinates=initArray2(doctorwho.tardis.limit,false)
- matloop=initArray2(doctorwho.tardis.limit,false)
- doctorwho.admins={6943}
- function contains(table, element)
- for _, value in pairs(table) do
- if value == element then
- return true
- end
- end
- return false
- end
- function showkey(table, element)
- for key, value in pairs(table) do
- if value == element then
- return key
- end
- end
- return false
- end
- function createTARDIS(ply,x,y)
- if (doctorwho.tardis.next<tonumber(doctorwho.tardis.limit)) then
- doctorwho.tardis.image[doctorwho.tardis.next]=image(doctorwho.tardis.defaultimg,x*32+16,y*32+16,1)
- if (doctorwho.tardis.recolor) then
- imagecolor(doctorwho.tardis.image[doctorwho.tardis.next],doctorwho.tardis.color[1],doctorwho.tardis.color[2],doctorwho.tardis.color[3])
- end
- doctorwho.tardis.gimage[doctorwho.tardis.next]=image(doctorwho.tardis.defaultimg,x*32+16,y*32+16,1)
- if (doctorwho.tardis.recolor) then
- imagecolor(doctorwho.tardis.gimage[doctorwho.tardis.next],doctorwho.tardis.color[1],doctorwho.tardis.color[2],doctorwho.tardis.color[3])
- end
- doctorwho.tardis.light[doctorwho.tardis.next]=image("gfx/sprites/flare3.bmp",x*32+16,y*32+16,1)
- doctorwho.tardis.glight[doctorwho.tardis.next]=image("gfx/sprites/flare3.bmp",x*32+16,y*32+16,1)
- imagealpha(doctorwho.tardis.light[doctorwho.tardis.next],0)
- imagealpha(doctorwho.tardis.glight[doctorwho.tardis.next],0)
- imageblend(doctorwho.tardis.light[doctorwho.tardis.next],1)
- imageblend(doctorwho.tardis.glight[doctorwho.tardis.next],1)
- imagescale(doctorwho.tardis.light[doctorwho.tardis.next],0.3,0.3)
- imagescale(doctorwho.tardis.glight[doctorwho.tardis.next],0.3,0.3)
- imagealpha(doctorwho.tardis.gimage[doctorwho.tardis.next],0)
- doctorwho.tardis.owner[doctorwho.tardis.next]=ply
- doctorwho.tardis.pos[doctorwho.tardis.next][1]=x*32+16
- doctorwho.tardis.pos[doctorwho.tardis.next][2]=y*32+16
- doctorwho.tardis.pos[doctorwho.tardis.next][3]=x
- doctorwho.tardis.pos[doctorwho.tardis.next][4]=y
- doctorwho.tardis.current=doctorwho.tardis.current+1
- doctorwho.tardis.next=doctorwho.tardis.next+1
- end
- end
- function blinkTARDIS(id,deg)
- if (deg==1) then
- tween_alpha(doctorwho.tardis.image[id],1000,0.5)
- tween_alpha(doctorwho.tardis.light[id],1000,1)
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.image[id]..",1000,1)")
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.light[id]..",1000,0)")
- end
- if (deg==2) then
- tween_alpha(doctorwho.tardis.image[id],1000,0.25)
- tween_alpha(doctorwho.tardis.light[id],1000,1)
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.image[id]..",1000,0.5)")
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.light[id]..",1000,0)")
- end
- if (deg==3) then
- tween_alpha(doctorwho.tardis.image[id],1000,0)
- tween_alpha(doctorwho.tardis.light[id],1000,1)
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.image[id]..",1000,0.25)")
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.light[id]..",1000,0)")
- end
- if (deg==1.2) then
- tween_alpha(doctorwho.tardis.image[id],1000,0)
- tween_alpha(doctorwho.tardis.light[id],1000,0)
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.image[id]..",1000,1)")
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.light[id]..",1000,1)")
- end
- if (deg==2.2) then
- tween_alpha(doctorwho.tardis.image[id],1000,0)
- tween_alpha(doctorwho.tardis.light[id],1000,0)
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.image[id]..",1000,0.5)")
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.light[id]..",1000,1)")
- end
- if (deg==3.2) then
- tween_alpha(doctorwho.tardis.image[id],1000,0)
- tween_alpha(doctorwho.tardis.light[id],1000,0)
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.image[id]..",1000,0.25)")
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.light[id]..",1000,1)")
- end
- end
- function blinkGhostTARDIS(id,deg)
- if (deg==1) then
- tween_alpha(doctorwho.tardis.gimage[id],1000,1)
- tween_alpha(doctorwho.tardis.glight[id],1000,1)
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.gimage[id]..",1000,0.5)")
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.glight[id]..",1000,0)")
- end
- if (deg==2) then
- tween_alpha(doctorwho.tardis.gimage[id],1000,0.5)
- tween_alpha(doctorwho.tardis.glight[id],1000,1)
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.gimage[id]..",1000,0.25)")
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.glight[id]..",1000,0)")
- end
- if (deg==3) then
- tween_alpha(doctorwho.tardis.gimage[id],1000,0.25)
- tween_alpha(doctorwho.tardis.glight[id],1000,1)
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.gimage[id]..",1000,0)")
- timer(1000,"parse","lua tween_alpha("..doctorwho.tardis.glight[id]..",1000,0)")
- end
- end
- function transportPlayer(id,dx,dy)
- for ply=1,doctorwho.tardis.limit do
- if (playerSittingIn[id][ply]) then
- parse("setpos "..ply.." "..((dx*32)+16).." "..((dy*32)+16))
- end
- end
- end
- function updatePosition(id,x,y)
- doctorwho.tardis.pos[id][1]=x*32+16
- doctorwho.tardis.pos[id][2]=y*32+16
- doctorwho.tardis.pos[id][3]=x
- doctorwho.tardis.pos[id][4]=y
- end
- function changePosition(id,dx,dy)
- if (flying[id]) then
- freeimage(doctorwho.tardis.image[id])
- doctorwho.tardis.image[id]=image("gfx/doctorwho/tardis.png",0,0,200+doctorwho.tardis.owner[id])
- tween_rotateconstantly(doctorwho.tardis.image[id],5)
- else
- imagepos(doctorwho.tardis.image[id],dx*32+16,dy*32+16,0)
- imagepos(doctorwho.tardis.light[id],dx*32+16,dy*32+16,0)
- end
- end
- function transportTARDIS(id,dx,dy)
- flyMode[playerSitting[id][doctorwho.tardis.owner[id]]]=false
- piloting[playerSitting[id][doctorwho.tardis.owner[id]]]=0
- flying[id]=false
- pilot[id]=0
- freeimage(doctorwho.tardis.image[id])
- doctorwho.tardis.image[id]=image(doctorwho.tardis.defaultimg,(player(id,"tilex")*32+16),(player(id,"tiley")*32+16),1)
- tween_rotate(doctorwho.tardis.image[id],1500,0)
- parse("speedmod "..id.." -100")
- parse("setpos "..id.." "..(player(id,"tilex")*32+16).." "..(player(id,"tiley")*32+16))
- canBeInteracted[id]=false
- sound3(doctorwho.tardis.pos[id][3],doctorwho.tardis.pos[id][4],8,8,"doctorwho/tardis_takeoff.ogg")
- sound3(dx,dy,8,8,"doctorwho/tardis_land.ogg")
- doctorwho.tardis.gimage[id]=image(doctorwho.tardis.defaultimg,dx*32+16,dy*32+16,1)
- doctorwho.tardis.glight[id]=image("gfx/sprites/flare3.bmp",(player(id,"tilex")*32+16),(player(id,"tiley")*32+16),1)
- imagealpha(doctorwho.tardis.glight[id],0)
- imageblend(doctorwho.tardis.glight[id],1)
- imagescale(doctorwho.tardis.glight[id],0.3,0.3)
- if (doctorwho.tardis.recolor) then
- imagecolor(doctorwho.tardis.gimage[id],doctorwho.tardis.color[1],doctorwho.tardis.color[2],doctorwho.tardis.color[3])
- end
- imagealpha(doctorwho.tardis.gimage[id],0)
- imagepos(doctorwho.tardis.gimage[id],dx*32+16,dy*32+16,0)
- imagepos(doctorwho.tardis.glight[id],dx*32+16,dy*32+16,0)
- timer(6500,"parse","lua blinkTARDIS("..id..",1)")
- timer(8500,"parse","lua blinkTARDIS("..id..",1)")
- timer(10500,"parse","lua blinkTARDIS("..id..",2)")
- timer(10500,"parse","lua blinkGhostTARDIS("..id..",3)")
- timer(12500,"parse","lua blinkTARDIS("..id..",3)")
- timer(12500,"parse","lua blinkGhostTARDIS("..id..",3)")
- timer(14500,"parse","lua changePosition("..id..","..dx..","..dy..")")
- timer(14500,"parse","lua freeimage(doctorwho.tardis.gimage["..id.."])")
- timer(14500,"parse","lua freeimage(doctorwho.tardis.glight["..id.."])")
- timer(14500,"parse","lua transportPlayer("..id..","..dx..","..dy..")")
- timer(14500,"parse","lua blinkTARDIS("..id..",3.2)")
- timer(16500,"parse","lua blinkTARDIS("..id..",2.2)")
- timer(18500,"parse","lua blinkTARDIS("..id..",1.2)")
- timer(20500,"parse","lua updatePosition("..id..","..dx..","..dy..")")
- timer(20500,"parse","lua tween_alpha(doctorwho.tardis.light["..id.."],1000,0)")
- timer(21000,"parse","lua canBeInteracted["..id.."]=true")
- end
- function doctorwho.tardis.plyenter(id)
- for t=1,doctorwho.tardis.current do
- if (canBeInteracted[t] and player(id,"team")==2) then
- if (player(id,"tilex")==doctorwho.tardis.pos[t][3] and player(id,"tiley")==doctorwho.tardis.pos[t][4]) then
- if (not contains(playerSitting[t],id)) then
- parse("setpos "..id.." "..(doctorwho.tardis.pos[t][3]*32+16).." "..(doctorwho.tardis.pos[t][4]*32+16))
- playerSpeedmod[id]=player(id,"speedmod")
- parse("speedmod "..id.." -100")
- playerSittingIn[t][id]=true
- table.insert(playerSitting[t],id)
- tardisIn[id]=t
- elseif (contains(playerSitting[t],id)) then
- if (flyMode[id]) then
- flyMode[id]=false
- piloting[id]=0
- flying[tardisIn[id]]=false
- pilot[tardisIn[id]]=0
- freeimage(doctorwho.tardis.image[tardisIn[id]])
- doctorwho.tardis.image[tardisIn[id]]=image(doctorwho.tardis.defaultimg,(player(id,"tilex")*32+16),(player(id,"tiley")*32+16),1)
- tween_rotate(doctorwho.tardis.image[tardisIn[id]],1500,0)
- parse("setpos "..id.." "..(player(id,"tilex")*32+16).." "..(player(id,"tiley")*32+16))
- end
- parse("speedmod "..id.." "..playerSpeedmod[id])
- tardisIn[id]=0
- local key=showkey(playerSitting[t],id)
- table.remove(playerSitting[t],key)
- end
- end
- end
- end
- end
- function activateNearbyTriggers(id)
- if (entity(player(id,"tilex"),player(id,"tiley"),"exists")) then
- --parse("trigger "..entity(player(id,"tilex"),player(id,"tiley"),"name"))
- parse("trigger "..entity(player(id,"tilex"),player(id,"tiley"),"trigger"))
- end
- if (entity(player(id,"tilex")+1,player(id,"tiley"),"exists")) then
- --parse("trigger "..entity(player(id,"tilex")+1,player(id,"tiley"),"name"))
- parse("trigger "..entity(player(id,"tilex")+1,player(id,"tiley"),"trigger"))
- end
- if (entity(player(id,"tilex")-1,player(id,"tiley"),"exists")) then
- --parse("trigger "..entity(player(id,"tilex")-1,player(id,"tiley"),"name"))
- parse("trigger "..entity(player(id,"tilex")-1,player(id,"tiley"),"trigger"))
- end
- if (entity(player(id,"tilex"),player(id,"tiley")-1,"exists")) then
- --parse("trigger "..entity(player(id,"tilex"),player(id,"tiley")-1,"name"))
- parse("trigger "..entity(player(id,"tilex"),player(id,"tiley")-1,"trigger"))
- end
- if (entity(player(id,"tilex"),player(id,"tiley")+1,"exists")) then
- --parse("trigger "..entity(player(id,"tilex"),player(id,"tiley")+1,"name"))
- parse("trigger "..entity(player(id,"tilex"),player(id,"tiley")+1,"trigger"))
- end
- if (entity(player(id,"tilex")-1,player(id,"tiley")-1,"exists")) then
- --parse("trigger "..entity(player(id,"tilex")-1,player(id,"tiley")-1,"name"))
- parse("trigger "..entity(player(id,"tilex")-1,player(id,"tiley")-1,"trigger"))
- end
- if (entity(player(id,"tilex")-1,player(id,"tiley")+1,"exists")) then
- --parse("trigger "..entity(player(id,"tilex")-1,player(id,"tiley")+1,"name"))
- parse("trigger "..entity(player(id,"tilex")-1,player(id,"tiley")+1,"trigger"))
- end
- if (entity(player(id,"tilex")+1,player(id,"tiley")+1,"exists")) then
- --parse("trigger "..entity(player(id,"tilex")+1,player(id,"tiley")+1,"name"))
- parse("trigger "..entity(player(id,"tilex")+1,player(id,"tiley")+1,"trigger"))
- end
- if (entity(player(id,"tilex")+1,player(id,"tiley")-1,"exists")) then
- --parse("trigger "..entity(player(id,"tilex")+1,player(id,"tiley")-1,"name"))
- parse("trigger "..entity(player(id,"tilex")+1,player(id,"tiley")-1,"trigger"))
- end
- end
- function csconvert(rot,x,y,factor)
- if rot<-90 then rot=rot+360 end
- local angle=math.rad(math.abs(rot+90))-math.pi
- local cx=x+(math.cos(angle)*factor)
- local cy=y+(math.sin(angle)*factor)
- return cx,cy
- end
- function toggleTrigger(id,mode)
- local xx,yy=csconvert(player(id,"rot"),player(id,"x"),player(id,"y"),32)
- local cx=math.floor(xx/32)
- local cy=math.floor(yy/32)
- local xx2,yy2=csconvert(player(id,"rot"),player(id,"x"),player(id,"y"),64)
- local cx2=math.floor(xx2/32)
- local cy2=math.floor(yy2/32)
- local tx=player(id,"tilex")
- local ty=player(id,"tiley")
- if (mode==1) then
- if (entity(cx,cy,"trigger") and entity(cx,cy,"trigger")~=nil) then
- parse("trigger "..entity(cx,cy,"trigger"))
- end
- if (entity(cx2,cy2,"trigger") and entity(cx2,cy2,"trigger")~=nil) then
- parse("trigger "..entity(cx2,cy2,"trigger"))
- end
- if (entity(tx,ty,"trigger") and entity(tx,ty,"trigger")~=nil) then
- parse("trigger "..entity(tx,ty,"trigger"))
- end
- elseif (mode==2) then
- if (entity(cx,cy,"name") and entity(cx,cy,"name")~=nil) then
- parse("trigger "..entity(cx,cy,"name"))
- end
- if (entity(cx2,cy2,"name") and entity(cx2,cy2,"name")~=nil) then
- parse("trigger "..entity(cx2,cy2,"name"))
- end
- if (entity(tx,ty,"name") and entity(tx,ty,"name")~=nil) then
- parse("trigger "..entity(tx,ty,"name"))
- end
- end
- end
- plyposition=doublearray(32,3,0)
- function isGoodPos(pos,ppos)
- if (pos==ppos) then
- return 0
- elseif (pos==nil) then
- return 0
- end
- return pos
- end
- --[[function findNearestPlayer(id)
- for fid=1,doctorwho.tardis.limit do
- if (player(fid,"exists") and fid~=id) then
- plyposition[fid][1]=player(fid,"tilex")
- plyposition[fid][2]=player(fid,"tiley")
- plyposition[fid][3]=plyposition[fid][1]+plyposition[fid][2]
- end
- end
- plyposition[id][3]=player(id,"tilex")+player(id,"tiley")
- plypositionmin=math.min(math.abs(plyposition[id][3]-isGoodPos(plyposition[1][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[2][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[3][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[4][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[5][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[6][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[7][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[8][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[9][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[10][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[11][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[12][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[13][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[14][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[15][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[16][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[17][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[18][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[19][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[20][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[21][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[22][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[23][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[24][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[25][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[26][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[27][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[28][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[29][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[30][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[31][3],plyposition[id][3])),math.abs(plyposition[id][3]-isGoodPos(plyposition[32][3],plyposition[id][3])))
- for fid=1,doctorwho.tardis.limit do
- if (player(fid,"exists") and fid~=id) then
- if (plypositionmin==math.abs(plyposition[id][3]-plyposition[fid][3])) then
- msg("The nearest player is "..player(fid,"name").." ("..math.abs(plyposition[id][3]-plyposition[fid][3]).." tiles away)")
- break
- else
- msg("An error occured; could not find the nearest player!")
- break
- end
- end
- end
- end]]
- function printPosition(id)
- msg("Sonic Screwdriver: your current position is TILES ("..player(id,"tilex").."|"..player(id,"tiley").."); PIXELS ("..math.floor(player(id,"x")).."|"..math.floor(player(id,"y"))..")")
- end
- function sonicMenu(id)
- menu(id,"Sonic Screwdriver,Toggle trigger,Toggle entity,Toggle nearby triggers,Print own position,Summon TARDIS")
- end
- function doctorwho.ssmenu(id,menu,sel)
- if (menu=="Sonic Screwdriver") then
- if (sel==1) then
- sound3(player(id,"tilex"),player(id,"tiley"),5,5,"weapons/sonic.ogg")
- timer(1000,"parse","lua toggleTrigger("..id..",1)")
- end
- if (sel==2) then
- sound3(player(id,"tilex"),player(id,"tiley"),5,5,"weapons/sonic.ogg")
- timer(1000,"parse","lua toggleTrigger("..id..",2)")
- end
- if (sel==3) then
- sound3(player(id,"tilex"),player(id,"tiley"),5,5,"weapons/sonic.ogg")
- timer(1000,"parse","lua activateNearbyTriggers("..id..")")
- end
- if (sel==4) then
- sound3(player(id,"tilex"),player(id,"tiley"),5,5,"weapons/sonic.ogg")
- timer(1000,"parse","lua printPosition("..id..")")
- end
- if (sel==5) then
- sound3(player(id,"tilex"),player(id,"tiley"),5,5,"weapons/sonic.ogg")
- for t=1,doctorwho.tardis.current do
- if (doctorwho.tardis.owner[t]==id) then
- transportTARDIS(t,player(id,"tilex"),player(id,"tiley"))
- break
- end
- end
- end
- end
- if (menu=="TARDIS Controls") then
- if (sel==1) then
- enteringCoordinates[id]=true
- msg2(id,"Enter destination coordinates (TILEX;TILEY)")
- end
- if (sel==2) then
- if (not flyMode[id]) then
- flyMode[id]=true
- piloting[id]=tardisIn[id]
- flying[tardisIn[id]]=true
- pilot[tardisIn[id]]=id
- freeimage(doctorwho.tardis.image[tardisIn[id]])
- doctorwho.tardis.image[tardisIn[id]]=image(doctorwho.tardis.defaultimg,0,0,200+id)
- tween_rotateconstantly(doctorwho.tardis.image[tardisIn[id]],5)
- freeimage(doctorwho.tardis.light[tardisIn[id]])
- doctorwho.tardis.light[tardisIn[id]]=image("gfx/sprites/flare3.bmp",0,0,200+id)
- imagealpha(doctorwho.tardis.light[tardisIn[id]],0)
- imageblend(doctorwho.tardis.light[tardisIn[id]],1)
- imagescale(doctorwho.tardis.light[tardisIn[id]],0.3,0.3)
- parse("speedmod "..id.." "..playerSpeedmod[id])
- else
- flyMode[id]=false
- piloting[id]=0
- flying[tardisIn[id]]=false
- pilot[tardisIn[id]]=0
- freeimage(doctorwho.tardis.image[tardisIn[id]])
- doctorwho.tardis.image[tardisIn[id]]=image(doctorwho.tardis.defaultimg,(player(id,"tilex")*32+16),(player(id,"tiley")*32+16),1)
- tween_rotate(doctorwho.tardis.image[tardisIn[id]],1500,0)
- freeimage(doctorwho.tardis.light[tardisIn[id]])
- doctorwho.tardis.light[tardisIn[id]]=image("gfx/sprites/flare3.bmp",(player(id,"tilex")*32+16),(player(id,"tiley")*32+16),1)
- imagealpha(doctorwho.tardis.light[tardisIn[id]],0)
- imageblend(doctorwho.tardis.light[tardisIn[id]],1)
- imagescale(doctorwho.tardis.light[tardisIn[id]],0.3,0.3)
- parse("speedmod "..id.." -100")
- parse("setpos "..id.." "..(player(id,"tilex")*32+16).." "..(player(id,"tiley")*32+16))
- end
- end
- if (sel==3) then
- if (cloisterReady[tardisIn[id]]) then
- cloisterReady[tardisIn[id]]=false
- sound3(player(id,"tilex"),player(id,"tiley"),5,5,"doctorwho/cloisterbell.ogg")
- timer(3000,"parse","lua cloisterReady["..tardisIn[id].."]=true")
- end
- end
- end
- end
- function doctorwho.hitrender(id,src,wpn,dmg)
- if (tardisIn[id]~=0) then
- return 1
- end
- if (player(id,"team")==2 and doctorwho.regencycles[id]>0 and dmg>=player(id,"maxhealth")) then
- parse("sethealth "..id.." 1")
- return 1
- end
- end
- function quickPlural(count)
- if (count>1) then
- return "s"
- elseif (count<-1) then
- return "s"
- end
- return ""
- end
- function doctorwho.sayprocess(id,t)
- if (contains(doctorwho.admins,player(id,"usgn"))) then
- if (t:sub(1,5)=="/give") then
- if (t:sub(7,11)=="sonic") then
- local _=t:sub(13)
- local tid=tonumber(_)
- hasSonic[tid]=true
- msg2(id,"You have given a sonic screwdriver to "..player(tid,"name"))
- msg2(tid,player(id,"name").." has given you a sonic screwdriver")
- end
- if (t:sub(7,11)=="regen") then
- local _=t:sub(13,14)
- local __=t:sub(15)
- local tid=tonumber(__)
- local rc=tonumber(_)
- doctorwho.regencycles[tid]=doctorwho.regencycles[tid]+rc
- if (rc>0) then
- msg2(id,"You have given "..rc.." regeneration"..quickPlural(rc).." to "..player(tid,"name"))
- msg2(tid,player(id,"name").." has given you "..rc.." regeneration"..quickPlural(rc))
- end
- end
- if (t:lower():sub(7,12)=="tardis") then
- local _=t:sub(14)
- local tid=tonumber(_)
- createTARDIS(tid,player(tid,"tilex"),player(tid,"tiley"))
- msg2(id,"You have given a TARDIS to "..player(tid,"name"))
- msg2(tid,player(id,"name").." has given you a TARDIS")
- end
- return 1
- end
- end
- if (enteringCoordinates[id]) then
- if (tardisIn[id]~=0) then
- local divider=t:find(";")
- local c1=t:sub(1,divider-1)
- local c2=t:sub(divider+1)
- local x=tonumber(c1)
- local y=tonumber(c2)
- if (x>=0 and x<=map("xsize") and y>=0 and y<=map("ysize")) then
- transportTARDIS(tardisIn[id],x,y)
- enteringCoordinates[id]=false
- else
- msg2(id,"©255000000ERROR: Invalid coordinates")
- enteringCoordinates[id]=false
- end
- end
- return 1
- end
- end
- function doctorwho.regenerate(id)
- doctorwho.regenerating[id]=true
- doctorwho.regenglow[id]=image("gfx/sprites/flare2.bmp",1,0,200+id)
- imageblend(doctorwho.regenglow[id],1)
- imagecolor(doctorwho.regenglow[id],255,200,0)
- imagealpha(doctorwho.regenglow[id],0)
- tween_alpha(doctorwho.regenglow[id],10000,0.4)
- playerSpeedmod[id]=player(id,"speedmod")
- parse("speedmod "..id.." -25")
- timer(10000,"parse","lua tween_alpha(doctorwho.regenglow["..id.."],1000,0)")
- timer(10000,"parse","speedmod "..id.." -100")
- timer(11000,"parse","lua tween_alpha(doctorwho.regenglow["..id.."],1000,1)")
- timer(11000,"parse","lua sound3("..player(id,"tilex")..","..player(id,"tiley")..",8,8,\"doctorwho/regeneration.ogg\")")
- timer(12500,"parse","lua recoveringhp["..id.."]=true")
- timer(19250,"parse","lua tween_alpha(doctorwho.regenglow["..id.."],500,0)")
- timer(19750,"parse","speedmod "..id.." "..playerSpeedmod[id])
- end
- function doctorwho.abortregen(id)
- if (doctorwho.regenerating[id]) then
- doctorwho.regenerating[id]=false
- freetimer("parse","lua tween_alpha(doctorwho.regenglow["..id.."],1000,0)")
- freetimer("parse","lua playerSpeedmod["..id.."]=player("..id..",\"speedmod\")")
- freetimer("parse","speedmod "..id.." -100")
- freetimer("parse","lua tween_alpha(doctorwho.regenglow["..id.."],1000,1)")
- freetimer("parse","lua sound3("..player(id,"tilex")..","..player(id,"tiley")..",8,8,\"doctorwho/regeneration.ogg\")")
- freetimer("parse","lua recoveringhp["..id.."]=true")
- freetimer("parse","lua tween_alpha(doctorwho.regenglow["..id.."],500,0)")
- freetimer("parse","speedmod "..id.." "..playerSpeedmod[id])
- freeimage(doctorwho.regenglow[id])
- end
- end
- function matloopTransport(t)
- local x=math.random(0,map("xsize"))
- local y=math.random(0,map("ysize"))
- if (tile(x,y,"frame")~=0 and tile(x,y,"property")>=5 and tile(x,y,"property")<=15) then
- imagepos(doctorwho.tardis.image[t],x*32+16,y*32+16,0)
- if (playerSittingIn[t]) then
- transportPlayer(playerSitting[t],x,y)
- end
- updatePosition(t,x,y)
- else
- matloopTransport(t)
- end
- end
- tick=0
- stick=0
- function doctorwho.ms100()
- for id=1,doctorwho.tardis.limit do
- if (player(id,"exists") and player(id,"health")<=10 and player(id,"health")>0) then
- if (doctorwho.regencycles[id]>0) then
- srecoveringhp[id]=false
- doctorwho.regenerate(id)
- parse("sethealth "..id.." 11")
- doctorwho.regencycles[id]=doctorwho.regencycles[id]-1
- end
- end
- if (player(id,"exists") and recoveringhp[id]) then
- if (player(id,"health")<player(id,"maxhealth")) then
- if (tick<65) then
- parse("sethealth "..id.." "..player(id,"health")+1)
- tick=tick+1
- else
- tick=0
- recoveringhp[id]=false
- srecoveringhp[id]=true
- end
- end
- local rnd=math.random(75,100)/100
- imagealpha(doctorwho.regenglow[id],rnd)
- end
- if (player(id,"exists") and srecoveringhp[id]) then
- if (player(id,"health")<player(id,"maxhealth")) then
- tick=tick+0.5
- if (tick==7.5) then
- parse("sethealth "..id.." "..player(id,"health")+1)
- tick=0
- end
- else
- srecoveringhp[id]=false
- end
- end
- for t=1,doctorwho.tardis.current do
- if (matloop[t]) then
- matloopTransport(t)
- end
- end
- end
- stick=stick+0.1
- end
- function doctorwho.sonicscrewdriver(id,a)
- if (a==3) then
- if (hasSonic[id]) then
- if (sonicSoundReady[id] and player(id,"team")==2) then
- sound3(player(id,"tilex"),player(id,"tiley"),5,5,"doctorwho/sonicextend.ogg")
- sonicSoundReady[id]=false
- sonicMenu(id)
- timer(1000,"parse","lua sonicSoundReady["..id.."]=true")
- end
- end
- end
- end
- function tardismenu(id)
- menu(id,"TARDIS Controls,Teleport,Toggle Flying,Ring Cloister Bell")
- end
- function doctorwho.tardiscontrols(id,a)
- if (a==1) then
- if (tardisIn[id]~=0 and doctorwho.tardis.owner[tardisIn[id]]==id) then
- tardismenu(id)
- end
- end
- end
- mtick=0
- function doctorwho.second()
- mtick=mtick+1
- for id=1,32 do
- if (player(id,"exists") and flying[tardisIn[id]]) then
- if (stick>=1) then
- sound3(player(id,"tilex"),player(id,"tiley"),5,5,"doctorwho/inflight.ogg")
- imagescale(doctorwho.tardis.light[tardisIn[id]],0.3,0.3)
- tween_alpha(doctorwho.tardis.light[tardisIn[id]],1000,1)
- timer(1000,"parse","lua tween_alpha(doctorwho.tardis.light["..tardisIn[id].."],1000,0)")
- stick=0
- end
- end
- end
- for t=1,doctorwho.tardis.current do
- if (matloop[t]) then
- if (mtick>=2) then
- mtick=0
- parse("sv_sound2 "..playerSitting[t].." \"doctorwho/matloop.ogg\"")
- end
- end
- end
- end
- function doctorwho.movetile(id,x,y)
- if (flyMode[id]) then
- doctorwho.tardis.pos[tardisIn[id]][1]=player(id,"x")
- doctorwho.tardis.pos[tardisIn[id]][2]=player(id,"y")
- doctorwho.tardis.pos[tardisIn[id]][3]=x
- doctorwho.tardis.pos[tardisIn[id]][4]=y
- end
- end
- ----------------------------------------------------------------------------------------
- --------- IMPORTANT! CHECK THESE |||| CONFIGS ||||BEFORE YOU RUN THE SERVER ---------
- ----------------------------------------------------------------------------------------
- payday_time = 120; -- Minutes
- --sms_cost = 0.5;
- radar_hide = true;
- --car_lic_cost = 120000;
- --fly_lic_cost = 350000;
- mp_hud = 0;
- --bike_lic_cost = 100000;
- --ship_lic_cost = 200000;
- train_cost = 5;
- train_wait = 3;
- max_cars = 55;
- ownable_cars_max = 3;
- inv_items_max = 30;
- --max_atms = 40;
- --cRED = "©255000000";
- --cGREEN = "©000255000";
- --cBLUE = "©000000255";
- --cBLACK = "©000000000";
- --cWHITE = "©255255255";
- --cWBLUE = "©000190255";
- --cGREEN_DARK = "©000100000"
- -- ===[ Dzień wypłaty ]===
- payday_enabled = true; -- czy dzień wypłaty jest włączony (true/false)
- payday_text = "©255255255Payday! {AMOUNT}$"; -- tekst zostanie wyświetlony podczas wypłaty, {AMOUNT} zostanie automatycznie zamienione na payday_money
- payday_money_multiplier = 1.0; -- jeśli np. ktoś zarabia 1000$ to jeśli multiplier jest 2.0 to dostanie 2000$
- -- ===[ HUD ]===
- hud_x = 520;
- hud_y = 240;
- -- ===[ Plecak ]===
- --[[
- WornWeapons.lua
- Config file
- by Alistaire
- --]]
- weaponTiers = {
- -- Secondary
- [1] = 0,
- [2] = 0,
- [3] = 4,
- [4] = 1,
- [5] = 2,
- [6] = 3,
- -- Primary
- [10] = 7,
- [11] = 7,
- [20] = 3,
- [21] = 0,
- [22] = 4,
- [23] = 0,
- [24] = 2,
- [30] = 5,
- [31] = 6,
- [32] = 5,
- [33] = 6,
- [34] = 9,
- [35] = 10,
- [36] = 8,
- [37] = 8,
- [38] = 4,
- [39] = 4,
- [40] = 9,
- [45] = 13,
- [47] = 12,
- [48] = 10,
- [49] = 10,
- [88] = 11,
- [90] = 9,
- [91] = 6,
- -- Spec
- [41] = 'spec',
- [46] = 'spec',
- [85] = 'spec',
- -- Melee
- [50] = 0,
- [69] = 2,
- [74] = 1
- }
- specTable = {
- [41] = 1,
- [46] = 2,
- [85] = 0
- }
- ----------------------------------
- --** HAARP SERVER START **--
- ----------------------------------
- parse("trigger quake_start")
- parse("trigger haarp_demon")
- ----------------------------------
- --** ADMIN DUTY **--
- ----------------------------------
- ----------------------------------
- ------- SAVE LAST POSITION -------
- ----------------------------------
- pos = {}
- function AA_join(id)
- if io.open('sys/lua/saves/pos'..player(id, 'usgn')..'.lua') then
- dofile('sys/lua/saves/pos'..player(id, 'usgn')..'.lua')
- os.remove('sys/lua/saves/pos'..player(id, 'usgn')..'.lua')
- end
- end
- function AA_leave(id)
- local file = io.open('sys/lua/saves/pos'..player(id, 'usgn')..'.lua', 'w')
- file:write('pos['..player(id, 'usgn')..'] = {'..player(id, 'x')..','..player(id, 'y')..'}')
- end
- function AA_spawn(id)
- if io.open('sys/lua/saves/pos'..player(id, 'usgn')..'.lua') then
- parse('setpos '..id..' '..pos[player(id, 'usgn')][1]..' '..pos[player(id, 'usgn')][2])
- end
- end
- ----------------------------------
- ---- TRAVEL TO ANOTHER CITY ------
- ----------------------------------
- -- Travel System by Salad Fingers --
- ------------------------------------
- Map = {
- ["116,239"] = {
- IP = "localhost:36969",
- Name = "Gold Village"
- }
- }
- HookMoveTile = function(id, x, y)
- if Map[x..","..y] then
- msg2(id, "Click use key (\"e\") to enter location: "..Map[x..","..y].Name)
- end
- end
- HookUse = function(id)
- if Map[player(id, "tilex")..","..player(id, "tiley")] then
- parse("reroute "..id.." "..Map[player(id, "tilex")..","..player(id, "tiley")].IP.."")
- end
- end
- ----------------------------------
- --** INFOBAR IMG & TEXT **--
- ----------------------------------
- --addhook('second','_secondHook')
- --function _secondHook()
- -- for _, id in pairs(player(0, 'tableliving')) do
- -- if player(id, 'health')/player(id, 'maxhealth') <= 0.3 then
- -- parse('sv_sound2 '..id..' heart.wav')
- -- end
- -- end
- --end
- ------------------------------
- ----- WRAPPER ----------------
- ------------------------------
- -------------------------------------------------------------------
- -- Wrapper functions for easy usage of CS2D commands in Lua --
- -- 25.03.2011 - www.UnrealSoftware.de --
- -------------------------------------------------------------------
- -------------------------------------------------------------------
- -- These functions make it easier to use CS2D commands in Lua --
- -- They call the parse functions with the fitting parameters --
- -- --
- -- Example without wrapper function: --
- -- parse("spawnplayer "..id.." "..x.." " ..y) --
- -- --
- -- Example with wrapper function: --
- -- spawnplayer(id,x,y) --
- -- --
- -- Both examples do exactly the same but using the wrapper --
- -- function is much easier and not as error-prone as using parse.--
- -- Therefore it is recommended to use the wrapper functions. --
- -- --
- -- Use the following line to include the wrapper in your script: --
- -- if wrapper~=true then dofile("sys/lua/wrapper.lua") end --
- -------------------------------------------------------------------
- -- Set Wrapper state to LOADED/TRUE!
- wrapper=true
- -- Functions
- function bot_add()
- parse("bot_add")
- end
- function bot_add_ct()
- parse("bot_add_ct")
- end
- function bot_add_t()
- parse("bot_add_t")
- end
- function bot_count(count)
- parse("bot_count "..count)
- end
- function bot_jointeam(team)
- parse("bot_jointeam "..team)
- end
- function bot_kill()
- parse("bot_kill")
- end
- function bot_prefix(prefix)
- parse("bot_prefix "..prefix)
- end
- function bot_remove()
- parse("bot_remove")
- end
- function bot_remove_all()
- parse("bot_remove_all")
- end
- function bot_remove_ct()
- parse("bot_remove_ct")
- end
- function bot_remove_t()
- parse("bot_remove_t")
- end
- function bot_skill(skill)
- parse("bot_skill "..skill)
- end
- function bot_weapons(weapons)
- parse("bot_weapons "..weapons)
- end
- function changelevel(map)
- parse("changelevel "..map)
- end
- function changemap(map)
- parse("changemap "..map)
- end
- function customkill(killer,weaponname,victim)
- parse("customkill "..killer.." "..weaponname.." "..victim)
- end
- function deathslap(player)
- parse("deathslap "..player)
- end
- function effect(effect,x,y,p1,p2,r,g,b)
- parse('effect "'..effect..'" '..x..' '..y..' '..p1..' '..p2..' '..r..' '..g..' '..b)
- end
- function equip(player,weapon)
- parse("equip "..player.." "..weapon)
- end
- function explosion(x,y,size,damage,sourceplayer)
- parse("explosion "..x.." "..y.." "..size.." "..damage.." "..sourceplayer)
- end
- function flashplayer(player,intensity)
- parse("flashplayer "..player.." "..intensity)
- end
- function flashposition(x,y,intensity)
- parse("flashposition "..x.." "..y.." "..intensity)
- end
- function hudtxt(id,text,x,y,align)
- parse("hudtxt "..id.." "..text.." "..x.." "..y.." "..align)
- end
- function hudtxt2(player,id,text,x,y,align)
- parse("hudtxt2 "..player.." "..id.." "..text.." "..x.." "..y.." "..align)
- end
- function hudtxtalphafade(player,id,duration,alpha)
- parse("hudtxtalphafade "..player.." "..id.." "..duration.." "..alpha)
- end
- function hudtxtcolorfade(player,id,duration,red,green,blue)
- parse("hudtxtcolorfade "..player.." "..id.." "..duration.." "..red.." "..green.." "..blue)
- end
- function hudtxtmove(player,id,duration,x,y)
- parse("hudtxtmove "..player.." "..id.." "..duration.." "..x.." "..y)
- end
- function items()
- parse("items")
- end
- function kick(player,reason)
- parse("kick "..player.." "..reason)
- end
- function killobject(objectid)
- parse("killobject "..objectid)
- end
- function killplayer(player)
- parse("killplayer "..player)
- end
- function listbans()
- parse("listbans")
- end
- function listplayers()
- parse("listplayers")
- end
- function logaddress_add(address)
- parse("logaddress_add "..address)
- end
- function logaddress_remove(address)
- parse("logaddress_remove "..address)
- end
- function logaddress_removeall()
- parse("logaddress_removeall")
- end
- function lua(script)
- parse("lua "..script)
- end
- function luareset()
- parse("luareset")
- end
- function makect(player)
- parse("makect "..player)
- end
- function makespec(player)
- parse("makespec "..player)
- end
- function maket(player)
- parse("maket "..player)
- end
- function map(map)
- parse("map "..map)
- end
- function maps()
- parse("maps")
- end
- function mp_antispeeder(antispeederprotection)
- parse("mp_antispeeder "..antispeederprotection)
- end
- function mp_autogamemode(autogamemode)
- parse("mp_autogamemode "..autogamemode)
- end
- function mp_autoteambalance(balance)
- parse("mp_autoteambalance "..balance)
- end
- function mp_building_health(building,price)
- parse("mp_building_health "..building.." "..price)
- end
- function mp_building_limit(building,limit)
- parse("mp_building_limit "..building.." "..limit)
- end
- function mp_building_price(building,price)
- parse("mp_building_price "..building.." "..price)
- end
- function mp_buytime(_time)
- parse("mp_buytime ".._time)
- end
- function mp_c4timer(_time)
- parse("mp_c4timer ".._time)
- end
- function mp_curtailedexplosions(curtailed)
- parse("mp_curtailedexplosions "..curtailed)
- end
- function mp_damagefactor(factor)
- parse("mp_damagefactor "..factor)
- end
- function mp_deathdrop(drop)
- parse("mp_deathdrop "..drop)
- end
- function mp_dispenser_health(health)
- parse("mp_dispenser_health "..health)
- end
- function mp_dispenser_money(money)
- parse("mp_dispenser_money "..money)
- end
- function mp_dmspawnmoney(money)
- parse("mp_dmspawnmoney "..money)
- end
- function mp_dropgrenades(drop)
- parse("mp_dropgrenades "..drop)
- end
- function mp_floodprot(floodprotection)
- parse("mp_floodprot "..floodprotection)
- end
- function mp_freezetime(_time)
- parse("mp_freezetime ".._time)
- end
- function mp_grenaderebuy(allowed)
- parse("mp_grenaderebuy "..allowed)
- end
- function mp_hostagepenalty(kills)
- parse("mp_hostagepenalty "..kills)
- end
- function mp_idleaction(action)
- parse("mp_idleaction "..action)
- end
- function mp_idlekick(idleaction)
- parse("mp_idlekick "..idleaction)
- end
- function mp_idletime(_time)
- parse("mp_idletime ".._time)
- end
- function mp_infammo(infiniteammo)
- parse("mp_infammo "..infiniteammo)
- end
- function mp_kevlar(percent)
- parse("mp_kevlar "..percent)
- end
- function mp_kickpercent(percent)
- parse("mp_kickpercent "..percent)
- end
- function mp_killbuildingmoney(money)
- parse("mp_killbuildingmoney "..money)
- end
- function mp_killbuildings(kill)
- parse("mp_killbuildings "..kill)
- end
- function mp_killinfo(info)
- parse("mp_killinfo "..info)
- end
- function mp_killteambuildings(mode)
- parse("mp_killteambuildings "..mode)
- end
- function mp_lagcompensation(maxcompensationtime)
- parse("mp_lagcompensation "..maxcompensationtime)
- end
- function mp_localrconoutput(output)
- parse("mp_localrconoutput "..output)
- end
- function mp_luamap(use)
- parse("mp_luamap "..use)
- end
- function mp_luaserver(file)
- parse("mp_luaserver "..file)
- end
- function mp_mapgoalscore(score)
- parse("mp_mapgoalscore "..score)
- end
- function mp_mapvoteratio(percent)
- parse("mp_mapvoteratio "..percent)
- end
- function mp_maxclientsip(clients)
- parse("mp_maxclientsip "..clients)
- end
- function mp_maxrconfails(maxfails)
- parse("mp_maxrconfails "..maxfails)
- end
- function mp_natholepunching(allowpunching)
- parse("mp_natholepunching "..allowpunching)
- end
- function mp_pinglimit(limit)
- parse("mp_pinglimit "..limit)
- end
- function mp_radar(radar)
- parse("mp_radar "..radar)
- end
- function mp_randomspawn(_random)
- parse("mp_randomspawn ".._random)
- end
- function mp_reservations(reservations)
- parse("mp_reservations "..reservations)
- end
- function mp_respawndelay(delay)
- parse("mp_respawndelay "..delay)
- end
- function mp_roundlimit(rounds)
- parse("mp_roundlimit "..rounds)
- end
- function mp_roundtime(_time)
- parse("mp_roundtime ".._time)
- end
- function mp_startmoney(money)
- parse("mp_startmoney "..money)
- end
- function mp_supply_items(itemlist)
- parse("mp_supply_items "..itemlist)
- end
- function mp_teamkillpenalty(kills)
- parse("mp_teamkillpenalty "..kills)
- end
- function mp_teleportreload(reloadtime)
- parse("mp_teleportreload "..reloadtime)
- end
- function mp_tempbantime(_time)
- parse("mp_tempbantime ".._time)
- end
- function mp_timelimit(_time)
- parse("mp_timelimit ".._time)
- end
- function mp_tkpunish(kill)
- parse("mp_tkpunish "..kill)
- end
- function mp_trace(accuracy)
- parse("mp_trace ".."accuracy")
- end
- function mp_turretdamage(damage)
- parse("mp_turretdamage "..damage)
- end
- function mp_unbuildable(buildings)
- parse("mp_unbuildable "..buildings)
- end
- function mp_unbuyable(unbuyable)
- parse("mp_unbuyable "..unbuyable)
- end
- function mp_vulnerablehostages(vulnerable)
- parse("mp_vulnerablehostages "..vulnerable)
- end
- function mp_winlimit(wins)
- parse("mp_winlimit "..wins)
- end
- function mp_wpndmg(name,damage)
- parse("mp_wpndmg "..name.." "..damage)
- end
- function mp_wpndmg_z1(name,damage)
- parse("mp_wpndmg_z1 "..name.." "..damage)
- end
- function mp_wpndmg_z2(name,damage)
- parse("mp_wpndmg_z2 "..name.." "..damage)
- end
- function mp_zombiedmg(percentageofdamage)
- parse("mp_zombiedmg "..percentageofdamage)
- end
- function mp_zombiekillequip(weapon)
- parse("mp_zombiekillequip "..weapon)
- end
- function mp_zombiekillscore(killscore)
- parse("mp_zombiekillscore "..killscore)
- end
- function mp_zombierecover(recover)
- parse("mp_zombierecover "..recover)
- end
- function mp_zombiespeedmod(speedmod)
- parse("mp_zombiespeedmod "..speedmod)
- end
- function msg(message)
- parse("msg "..message)
- end
- function rcon(commands)
- parse("rcon "..commands)
- end
- function rcon_password(password)
- parse("rcon_password "..password)
- end
- function rcon_pw(password)
- parse("rcon_pw "..password)
- end
- function removeitem(item)
- parse("removeitem "..item)
- end
- function reroute(player,address)
- parse("reroute "..player.." "..address)
- end
- function restart(delay)
- parse("restart "..delay)
- end
- function restartround(delay)
- parse("restartround "..delay)
- end
- function setarmor(player,armor)
- parse("setarmor "..player.." "..armor)
- end
- function setdeaths(player,deaths)
- parse("setdeaths "..player.." "..deaths)
- end
- function sethealth(player,health)
- parse("sethealth "..player.." "..health)
- end
- function setmaxhealth(player,maxhealth)
- parse("setmaxhealth "..player.." "..maxhealth)
- end
- function setmoney(player,money)
- parse("setmoney "..player.." "..money)
- end
- function setname(player,name)
- parse("setname "..player.." "..name)
- end
- function setpos(player,x,y)
- parse("setpos "..player.." "..x.." "..y)
- end
- function setscore(player,score)
- parse("setscore "..player.." "..score)
- end
- function setweapon(player,weapon)
- parse("setweapon "..player.." "..weapon)
- end
- function shake(player,power)
- parse("shake "..player.." "..power)
- end
- function slap(player)
- parse("slap "..player)
- end
- function spawnitem(item,x,y)
- parse("spawnitem "..item.." "..x.." "..y)
- end
- function spawnnpc(_type,x,y,rot)
- parse("spawnnpc ".._type.." "..x.." "..y.." "..rot)
- end
- function spawnobject(_type,x,y,rot,mode,team,player)
- parse("spawnobject ".._type.." "..x.." "..y.." "..rot.." "..mode.." "..team.." "..player)
- end
- function spawnplayer(player,x,y)
- parse("spawnplayer "..player.." "..x.." "..y)
- end
- function speedmod(player,speedmod)
- parse("speedmod "..player.." "..speedmod)
- end
- function strip(player,weapon)
- parse("strip "..player.." "..weapon)
- end
- function sv_fow(fow)
- parse("sv_fow "..fow)
- end
- function sv_friendlyfire(FF)
- parse("sv_friendlyfire "..FF)
- end
- function sv_gamemode(mode)
- parse("sv_gamemode "..mode)
- end
- function sv_gm(mode)
- parse("sv_gm "..mode)
- end
- function sv_hostport(port)
- parse("sv_hostport "..port)
- end
- function sv_lan(lan)
- parse("sv_lan "..lan)
- end
- function sv_map(map)
- parse("sv_map "..map)
- end
- function sv_maptransfer(transfer)
- parse("sv_maptransfer "..transfer)
- end
- function sv_maxplayers(players)
- parse("sv_maxplayers "..players)
- end
- function sv_msg(message)
- parse("sv_msg "..message)
- end
- function sv_msg2(player,message)
- parse("sv_msg2 "..player.." "..message)
- end
- function sv_name(name)
- parse("sv_name "..name)
- end
- function sv_password(password)
- parse("sv_password "..password)
- end
- function sv_rcon(rconpassword)
- parse("sv_rcon "..rconpassword)
- end
- function sv_restart(delay)
- parse("sv_restart "..delay)
- end
- function sv_restartround(delay)
- parse("sv_restartround "..delay)
- end
- function sv_sound(soundfile)
- parse("sv_sound "..soundfile)
- end
- function sv_sound2(player,soundfile)
- parse("sv_sound2 "..player.." "..soundfile)
- end
- function sv_specmode(mode)
- parse("sv_specmode "..mode)
- end
- function sv_spraytransfer(spraytransfer)
- parse("sv_spraytransfer "..spraytransfer)
- end
- function sv_usgnonly(usgnonly)
- parse("sv_usgnonly "..usgnonly)
- end
- function transfer_speed(speed)
- parse("transfer_speed "..speed)
- end
- function trigger(trigger)
- parse("trigger "..trigger)
- end
- function unban(banmask)
- parse("unban "..banmask)
- end
- function unbanall()
- parse("unbanall")
- end
- function usgn_addserver()
- parse("usgn_addserver")
- end
- function usgn_info()
- parse("usgn_info")
- end
- ------------------------------
- ------- CHAT SYSTEM ----------
- ------------------------------
- colour = {
- [1] = {'255220000','©255025000','©050150255','©050150255'},
- [2] = {'©255220000','©000255000','©000255000'},
- ooc = '©200200200'
- }
- queries = {
- ['ooc'] = colour.ooc.."(($n: $t))",
- ['me'] = "$s>$n $t",
- ['do'] = "$c[$i]: $s**$t**"
- }
- distance = 200 --distance in pixels a player has to be to see your messages
- function getDist(x1, y1, x2, y2)
- return math.floor(((x1 - x2)^2 + (y1 - y2)^2)^.5)
- end
- function msg3(id, text)
- for _, i in pairs(player(0, 'tableliving')) do
- if getDist(player(i, 'x'), player(i, 'y'), player(id, 'x'), player(id, 'y')) <= distance then msg2(i, text) end
- end
- end
- --getDist & msg3 by Avobolt | unedited source: http://www.unrealsoftware.de/forum_posts.php?post=366814&start=0#post366831
- function _sayHook(id, txt)
- msg3(id, queryCmd(id, txt, string.match(txt, '!(%a+)%s-')))
- return 1;
- end
- function queryCmd(id, txt, cmd)
- local txtn = txt:match('!%a+%s(.*)') or txt
- local rep = {
- ['t'] = txtn and string.gsub(txtn, '^%s*(.-)%s*$', '%1') or 'nothing',
- ['i'] = id,
- ['n'] = player(id, 'name'),
- ['c'] = colour[(tonumber(game('sv_gamemode'))==1 and 2 or 1)][player(id, 'team')+1],
- ['s'] = '©255220000',
- ['$'] = '$'
- }
- if queries[cmd] then return queries[cmd]:gsub("$(.)", rep);
- else return rep.c..rep.n..rep.s..' says: '..rep.t; end
- end
- ------------------------------
- ------ WORN WEAPONS ----------
- ------------------------------
- function array(val)
- local a = {}
- for i = 1, 32 do
- a[i] = val
- end
- return a;
- end
- --// Slots: [1] primary | [2] secondary | [3] melee | spec special (flamethrower)
- wornWeaponIMG = {slot = {array(0), array(0), array(0), spec = array(0)}, used = {array(true), array(true), array(true), spec = array(true)}, current = {array(0), array(0), array(0), spec = array(0)}}
- function WW_collectHook(id, type)
- if player(id, 'weapontype') ~= type then
- wornImages(id, type)
- end
- end
- function WW_dropHook(id, type)
- function continueImages()
- wornImages(id, player(id, 'weapontype'))
- end
- timer(5, 'continueImages')
- end
- function WW_selectHook(id, type)
- wornImages(id, type)
- end
- function WW_spawnHook(id)
- function continueImages()
- wornImages(id, player(id, 'weapontype'))
- end
- timer(5, 'continueImages')
- end
- function clearSlots(id)
- function clearSlot(slot)
- if wornWeaponIMG.used[slot][id] == false then
- freeimage(wornWeaponIMG.slot[slot][id])
- wornWeaponIMG.used[slot][id] = true
- end
- end
- for slot = 1, 3 do
- clearSlot(slot)
- end
- clearSlot('spec')
- end
- function wornImages(id, currentType)
- clearSlots(id)
- function wearSlot(iid, slot)
- if iid ~= 0 then
- local slotType = 100
- if slot == 1 or slot == 'spec' then
- slotType = 200
- end
- wornWeaponIMG.slot[slot][id] = image('gfx/WornWeapons/'..iid..'.png', 1, 0, slotType + id)
- wornWeaponIMG.used[slot][id] = false
- end
- end
- for _, iid in pairs(playerweapons(id)) do
- if currentType ~= iid and iid ~= 78 then
- local slot = itemtype(iid, 'slot')
- if slot >= 1 and slot <= 3 then
- if weaponTiers[iid] == 'spec' then slot = 'spec' end
- if wornWeaponIMG.current[slot][id] ~= 0 then
- if weaponTiers[iid] == 'spec' then
- if specTable[iid] > specTable[wornWeaponIMG.current.spec[id]] then
- wornWeaponIMG.current.spec[id] = iid
- end
- elseif weaponTiers[iid] > weaponTiers[wornWeaponIMG.current[slot][id]] then
- wornWeaponIMG.current[slot][id] = iid
- end
- else
- if weaponTiers[iid] == 'spec' then
- wornWeaponIMG.current.spec[id] = iid
- else
- wornWeaponIMG.current[slot][id] = iid
- end
- end
- end
- end
- end
- wearSlot(wornWeaponIMG.current.spec[id], 'spec')
- wornWeaponIMG.current.spec[id] = 0
- for slot = 1, 3 do
- wearSlot(wornWeaponIMG.current[slot][id], slot)
- wornWeaponIMG.current[slot][id] = 0
- end
- end
- ------------------------------
- ------- BADWORDS -------------
- ------------------------------
- ------------------------------
- --------- SOCCER SYSTEM ------
- ------------------------------
- -----------------------------
- ------ STREAM FUNCTIONS -----
- -----------------------------
- -----------------------------
- ------ TRAIN SYSTEM ---------
- -----------------------------
- trains = {
- [1] = {
- img = "gfx/mhappy/train.png",
- speed = 6;
- tid, gfx = 0, x1 = 0, y1 = 0, x2 = 0, y2 = 0, dir = 0, nodes = 0, current = 0, wait = false,
- players = {},
- node = {
- {128, 19, 30}, {128, 27}, {137, 27}, {137, 67},
- {167, 67}, {167, 130}, {156, 130}, {156, 146},
- {131, 146, 5}, {156, 146}, {156, 221}, {110, 221},
- {110, 216, 5}, {110, 221}, {156, 221}, {156, 146},
- {131, 146, 5}, {156, 146}, {156, 130}, {189, 130},
- {189, 98, 5}, {189, 130}, {167, 130}, {167, 67},
- {137, 67}, {137, 27}, {128, 27}, {128, 19, 30},
- },
- },
- }
- function GetDir(x1, y1, x2, y2)
- return math.atan2(x2-x1, y2-y1);
- end
- function GetDist(x1, y1, x2, y2)
- return math.sqrt((x2 - x1)^2 + (y2 - y1)^2);
- end
- function InitTrains()
- local _, i;
- for _, i in pairs(trains) do
- i.nodes = #i.node;
- i.current = 1;
- i.tid = _;
- i.x1 = (i.node[1][1] * 32) + 16;
- i.y1 = (i.node[1][2] * 32) + 16;
- i.x2 = (i.node[2][1] * 32) + 16;
- i.y2 = (i.node[2][2] * 32) + 16;
- i.dir = GetDir(i.x1, i.y1, i.x2, i.y2);
- i.gfx = image(i.img, i.x1, i.y1, 1);
- imagepos(i.gfx, i.x1, i.y1, -math.deg(i.dir));
- end
- end
- InitTrains();
- function UnwaitTrain(i)
- trains[tonumber(i)].wait = false;
- end
- function moveTrains()
- local _, i;
- for _, i in pairs(trains) do
- if not i.wait then
- i.x1 = i.x1 + math.sin(i.dir) * i.speed;
- i.y1 = i.y1 + math.cos(i.dir) * i.speed;
- local tx1, ty1;
- tx1 = math.floor(i.x1 / 32);
- ty1 = math.floor(i.y1 / 32);
- if tx1 == math.floor(i.x2 / 32) and ty1 == math.floor(i.y2 / 32) then
- i.current = i.current + 1;
- if i.node[i.current] ~= nil then
- if i.node[i.current][3] ~= nil then
- i.wait = true;
- timer(i.node[i.current][3] * 1000, "UnwaitTrain", tostring(_));
- end
- end
- i.x1 = i.x2;
- i.y1 = i.y2;
- if i.current == i.nodes + 1 then
- i.current = 1;
- i.x1 = (i.node[1][1] * 32) + 16;
- i.y1 = (i.node[1][2] * 32) + 16;
- i.x2 = (i.node[2][1] * 32) + 16;
- i.y2 = (i.node[2][2] * 32) + 16;
- elseif (i.current + 1) > i.nodes then
- i.x2 = (i.node[1][1] * 32) + 16;
- i.y2 = (i.node[1][2] * 32) + 16;
- else
- i.x2 = (i.node[i.current + 1][1] * 32) + 16;
- i.y2 = (i.node[i.current + 1][2] * 32) + 16;
- end
- i.dir = GetDir(i.x1, i.y1, i.x2, i.y2);
- end
- imagepos(i.gfx, i.x1, i.y1, -math.deg(i.dir));
- end
- local j, k;
- for j, k in pairs(i.players) do
- if player(k, "health") > 0 then
- parse("setpos ".. k .." ".. i.x1 .." ".. i.y1);
- else
- table.remove(i.players, j);
- end
- end
- end
- end
- function enterTrain(id)
- local x, y = player(id, "x"), player(id, "y");
- local _, i;
- if not Player[id].car and not Player[id].carowner then
- if Player[id].train == 0 then
- for _, i in pairs(trains) do
- if GetDist(x, y, i.x1, i.y1) <= 48 then
- if i.wait then
- table.insert(i.players, id)
- Player[id].speed = player(id, "speedmod");
- Player[id].train = _;
- parse("speedmod ".. id .." -100");
- break;
- else
- msg2(id, "©255000000You can enter train only at station!");
- end
- end
- end
- else
- if trains[Player[id].train].wait then
- for _, i in pairs(trains[Player[id].train].players) do
- if i == id then
- table.remove(trains[Player[id].train].players, _);
- break;
- end
- end
- Player[id].train = 0;
- parse("speedmod ".. id .." ".. Player[id].speed);
- else
- msg2(id, "©255000000You can't get out of train while travelling!");
- end
- end
- end
- end
- -----------------------------
- ---- DOOR LOCK FOR H --------
- -----------------------------
- --[[
- Password for doors - lock doors on your map!
- By Avobolt (USGN#88318)
- ]]--
- function Array(m, v)
- local T = {}
- for i = 1, m do
- T[i] = v
- end
- return T
- end
- AnglePosition = function(rot, x, y, factor)
- if rot < -90 then rot = rot + 360 end
- local angle = math.rad(math.abs(rot + 90)) - math.pi
- local x = x + (math.cos(angle) * factor)
- local y = y + (math.sin(angle) * factor)
- return x, y
- end
- pkl = {}
- pkl.Comb = Array(32, { "" , "", {0, 0} } ) -- [ 1 ] - password, [ 2 ] - inserted password, [3] - position
- pkl.Chars = {"1","2","3","4","5","6","7","8","0"} -- up to 9 chars, I was too lazy to unclude inf menus
- pkl.HookUse = function(id)
- local x, y = AnglePosition(player(id, "rot"), player(id, "x"), player(id, "y"), 32)
- x, y = math.floor(x/32), math.floor(y/32)
- local name = entity(x, y, "name")
- if tile(x,y, "entity") and type(entity(x, y, "name")) == "string" and entity(x, y, "name"):sub(1,5) == "lock:" then
- local name = entity(x, y, "name")
- if entity(x, y, "state") == false then
- if #name <= 5 then return end
- pkl.Comb[id][1] = name:sub(6)
- pkl.Comb[id][2] = ""
- pkl.Comb[id][3] = {x, y}
- pkl.OpenMenu(id)
- else
- parse("triggerposition "..x.." "..y)
- end
- end
- end
- pkl.OpenMenu = function(id, step)
- if not step then step = 1 end
- local x, y = unpack(pkl.Comb[id][3])
- if entity(x, y, "state") == false then
- menu(id, "Lock - step "..step..","..table.concat(pkl.Chars, ","))
- end
- end
- pkl.HookMenu = function(id,title,b)
- if title:sub(1, 12) == "Lock - step " then
- if b == "x" or b == 0 then return end
- local step = tonumber(title:sub(13))
- local ch = pkl.Chars[b]
- pkl.Comb[id][2] = pkl.Comb[id][2]..ch
- if #pkl.Comb[id][1] == #pkl.Comb[id][2] then
- parse("triggerposition "..pkl.Comb[id][3][1].." "..pkl.Comb[id][3][2])
- else
- if pkl.Comb[id][2] == pkl.Comb[id][1]:sub(1, #pkl.Comb[id][2]) then
- parse("sv_sound2 "..id.."\"wpn_select.wav\"")
- pkl.OpenMenu(id, step + 1)
- else
- parse("sv_sound2 "..id.."\"wpn_denyselect.wav\"")
- end
- end
- end
- end
- -----------------------------
- ------ HOUSE SYSTEM ---------
- -----------------------------
- houses = {
- {
- name = "House 2";
- ex = 115; ey = 115; -- pozycja w ktorej sie kupuje dom
- x1 = 104; y1 = 128; -- rozmiar domu
- x2 = 112; y2 = 134;
- price = 500;
- },
- }
- function InitHouses()
- local _, i;
- for _, i in pairs(houses) do
- i.allowed = {};
- i.owner = 0;
- end
- end
- InitHouses();
- function houseUse(id)
- if Player[id].house then
- local x, y = player(id, "tilex"), player(id, "tiley");
- local dir = math.floor((player(id, "rot") + 45) / 90) % 4;
- if dir == 0 then
- y = y - 1;
- elseif dir == 1 then
- x = x + 1;
- elseif dir == 2 then
- y = y + 1;
- else
- x = x - 1;
- end
- if x >= Player[id].house.x1 and y >= Player[id].house.y1 and x <= Player[id].house.x2 and y <= Player[id].house.y2 then
- if entity(x, y, "exists") then
- if entity(x, y, "type") == 71 then
- parse("triggerposition ".. x .." ".. y);
- end
- end
- end
- end
- end
- function BuyHouse(id)
- local x, y;
- x = player(id, "tilex");
- y = player(id, "tiley");
- local _, i;
- local hid = 0;
- for _, i in pairs(houses) do
- if x == i.ex and y == i.ey then
- hid = _;
- break;
- end
- end
- if hid > 0 then
- if houses[hid].owner == 0 then
- if houses[hid].only == nil or Player[id].job == houses[hid].only then
- if PayMoney(id, houses[hid].price, true) then
- msg2(id, "©255255255Succefully bought " .. houses[hid].name .. "!");
- msg2(id, "©255255255Go to F2/Property Options, Press E to open doors!");
- Player[id].house = houses[hid];
- houses[hid].owner = id;
- end
- else
- msg2(id, "©255000000Only "..houses[hid].only.." can buy this property!");
- end
- end
- end
- end
- function houseCheck(id, x, y)
- local _, i;
- for _, i in pairs(houses) do
- if x == i.ex and y == i.ey then
- if not Player[id].house then
- if i.owner == 0 then
- local t = {
- title = "Do you want to buy this property?",
- items = {
- {"Yes", "You can later sell it.", function(id) BuyHouse(id) end};
- {"No", "", nil};
- {"(Property Info)", "", nil};
- {"(Tiles Count: ".. ((i.x2-i.x1)*(i.y2-i.y1)) ..")", "", nil};
- {"(Price: ".. i.price .."$)", "", nil};
- },
- }
- unimenu(id, true, t, 1);
- end
- end
- elseif x >= i.x1 and y >= i.y1 and x <= i.x2 and y <= i.y2 then
- local index = inTable(i.allowed, id);
- if i.owner == id then
- break;
- elseif index > 0 then
- break;
- else
- parse("setpos ".. id .." ".. Player[id].lastx * 32 + 16 .." ".. Player[id].lasty * 32 + 16);
- end
- end
- end
- Player[id].lastx = player(id, "tilex");
- Player[id].lasty = player(id, "tiley");
- end
- House = {
- ["16,87"] = {
- StreetName = "1 Rich Street", -- Street name
- Owner = "Salad Fingers", -- Owner's name
- USGN = 6943, -- Owner's USGN
- Trigger = "house_salad" -- Door trigger's name
- }
- }
- House_MoveTile = function(id, x, y)
- if House[x..","..y] then
- msg2(id, "Welcome on "..House[x..","..y].StreetName.." \n Owner: "..House[x..","..y].Owner)
- end
- end
- HouseInfo = function(id, x, y)
- if House[player(id, "tilex")..","..player(id, "tiley")] then
- elseif player(id, "usgn") == House[x..","..y].USGN then
- parse("trigger" ..House[x..","..y].Trigger)
- end
- end
- -----------------------------
- ------- ITEMS FOR INV -------
- -----------------------------
- Item = {
- [1] = {
- name = "AK-47";
- drop = 30; -- id itemy do wyrzucenia, usuń to jak nie pozwalasz wyrzucać
- equip = 30; -- id itemu do ubrania, usuń to jak nie pozwalasz ubrać
- };
- [2] = {
- name = "Apple";
- use = {"Eat", function(id, slotid) DecHunger(id, 5); removeItem(id, slotid); msg2(id, "©255000000Yummy apple!"); end};
- };
- [3] = {
- name = "AK-47 Shipment";
- drop = {30,30,30,30,30};
- };
- [4] = {
- name = "Bandage";
- use = {"Use", function(id, slotid) if player(id, "health") <= 50 then parse("sethealth "..id.."" +50); end removeItem(id, slotid); msg2(id, "©000255000Ahhh, Feeling myself better now!"); end};
- drop = {30};
- };
- [5] = {
- name = "Mobile Phone";
- use = {"SMS", function (id, slotid) if mobile[id]==1 then msg2(id, "©255255000Usage: !SMS [Number] [Message]");end end};
- use = {"Call", function (id, slotid) if mobile[id]==1 then msg2(id, "©255255000Usage: !Call [Number]"); end end};
- };
- }
- -----------------------------
- ------- INVENTORY SYS -------
- -----------------------------
- function showInv(id)
- if #Player[id].inv == 0 then
- msg2(id, "©255000000You don't have anything in inventory!");
- return 0;
- end
- local _, i;
- local t = {
- title = "Inventory";
- items = {};
- };
- for _, i in pairs(Player[id].inv) do
- table.insert(t.items, {Item[i].name, "", assert(loadstring("local id = ".. id .."; showItem(id, ".. _ ..");"))});
- end
- unimenu(id, true, t, 1);
- end
- function showItem(id, slotid)
- local iid = Player[id].inv[slotid];
- local t = {
- title = "Item " .. Item[iid].name;
- items = {};
- }
- if Item[iid].drop ~= nil then
- table.insert(t.items, {"Drop", "", assert(loadstring("local id = ".. id .."; dropItem(id, ".. slotid ..");"))});
- end
- if Item[iid].equip ~= nil then
- table.insert(t.items, {"Equip", "", assert(loadstring("local id = ".. id .."; equipItem(id, ".. slotid ..");"))});
- end
- if Item[iid].use ~= nil then
- table.insert(t.items, {Item[iid].use[1], "", assert(loadstring("local id = ".. id .."; Item[".. iid .."].use[2](id, ".. slotid ..");"))});
- end
- unimenu(id, true, t, 1);
- end
- function removeItem(id, slotid)
- table.remove(Player[id].inv, slotid);
- end
- function buyItem(id, cost, iid)
- if Player[id].money >= cost then
- if addItem(id, iid) then
- msg2(id, "©255128064You bought ".. Item[iid].name .."!");
- Player[id].money = Player[id].money - cost;
- if show then
- msg2(id, "©255000000-" .. cost .. "$");
- end
- UpdateHud(id);
- else
- msg2(id, "©255000000You don't have enough space in inventory!");
- end
- else
- msg2(id, "©255000000You don't have enough money!");
- end
- end
- function addItem(id, iid)
- if #Player[id].inv <= inv_maxitems then
- table.insert(Player[id].inv, iid);
- return true;
- end
- return false;
- end
- function dropItem(id, slotid)
- local iid = Player[id].inv[slotid];
- if Item[iid].drop ~= nil then
- msg2(id, "©255128064Dropped "..Item[iid].name.."!");
- removeItem(id, slotid);
- if type(Item[iid].drop) == "table" then
- local _, i;
- for _, i in pairs(Item[iid].drop) do
- parse("spawnitem ".. i .." ".. player(id, "tilex") .." ".. player(id, "tiley"));
- end
- else
- parse("spawnitem ".. Item[iid].drop .." ".. player(id, "tilex") .." ".. player(id, "tiley"));
- end
- end
- end
- function equipItem(id, slotid)
- local iid = Player[id].inv[slotid];
- if Item[iid].equip ~= nil then
- msg2(id, "©255128064Equipped "..Item[iid].name.."!");
- removeItem(id, slotid);
- if type(Item[iid].equip) == "table" then
- local _, i;
- for _, i in pairs(Item[iid].equip) do
- parse("equip ".. id .." ".. i);
- end
- else
- parse("equip ".. id .." ".. Item[iid].equip);
- end
- end
- end
- -----------------------------
- ---------- NPC SYSTEM -------
- -----------------------------
- shop_mc = {
- title = "Buy Food",
- items = {
- {"Hamburger", "[2$]", function(id) BuyFood(id, 10.1, 2); end},
- {"Double CheeseBurger", "[3$]", function(id) BuyFood(id, 15.4, 3); end},
- {"Happy Meal", "[4$]", function(id) BuyFood(id, 40.0, 4); end},
- {"MC Menu +", "[4$]", function(id) BuyFood(id, 60.0, 4); end},
- },
- }
- shop_water = {
- title = "Buy Drink",
- items = {
- {"Water", "[1$]", function(id) BuyWater(id, 10.9, 1); end},
- {"Coca-Cola", "[3$]", function(id) BuyWater(id, 5.5, 3); end},
- {"Pepsi", "[3$]", function(id) BuyWater(id, 5.5, 3); end},
- },
- }
- shop_drink_automat = {
- title = "Drink Vending Machine",
- items = {
- {"Hot-Water", "[2$]", function(id) BuyWater(id, 1.0, 2); end},
- {"Crystal-Water", "[3$]", function(id) BuyWater(id, 20, 3); end},
- {"Coca-Cola", "[5$]", function(id) BuyWater(id, 5.5, 5); end},
- {"Pepsi", "[5$]", function(id) BuyWater(id, 2.5, 5); end},
- {"Fanta", "[5$]", function(id) BuyWater(id, 2.5, 5); end},
- {"Sprite", "[5$]", function(id) BuyWater(id, 2.5, 5); end},
- {"Coffee", "[2$]", function(id) BuyWater(id, 2.5, 2); end},
- {"Coffee + Sugar", "[3$]", function(id) BuyWater(id, 2.8, 3); end},
- {"Hot Chocolate", "[4$]", function(id) BuyWater(id, 3.0, 4); end},
- {"Lemon Tea", "[3$]", function(id) BuyWater(id, 2.5, 3); end},
- },
- }
- shop_snack_machine = {
- title = "Snak Machine",
- items = {
- {"Lays", "[2$]", function(id) BuyFood(id, 20.0, 2); end},
- {"Snickers", "[1$]", function(id) BuyFood(id, 5.0, 1); end},
- {"Mars", "[1$]", function(id) BuyFood(id, 5.0, 1); end},
- {"Counter Chips", "[4$]", function(id) BuyFood(id, 25.0, 4); end},
- {"Kit-Kat", "[2$]", function(id) BuyFood(id, 6.0, 2); end},
- {"m&m", "[2$]", function(id) BuyFood(id, 5.0, 2); end},
- {"Cookie Crisp", "[3$]", function(id) BuyFood(id, 15.0, 3); end},
- {"Cheetos", "[2$]", function(id) BuyFood(id, 20.0, 2); end},
- {"Milka", "[3$]", function(id) BuyFood(id, 12.0, 3); end},
- {"Toblerone", "[4$]", function(id) BuyFood(id, 12.0, 4); end},
- },
- }
- shop_cars = {
- title = "Car Shop",
- items = {
- {"Ford Fiesta", "[1000$]", function(id) if PayMoney(id, 1000, true) then SpawnCar("red", player(id, "tilex")*32+16, player(id, "tiley")*32+16, player(id, "rot")) end end},
- {"Suzuki SJZ-200", "[500$]", function(id) if PayMoney(id, 500, true) then SpawnCar("motor", player(id, "tilex")*32+16, player(id, "tiley")*32+16, player(id, "rot")) end end},
- },
- }
- npc_list = {
- {
- x = 181;
- y = 186;
- m = shop_mc;
- };
- {
- x = 132;
- y = 78;
- m = shop_drink_automat;
- };
- {
- x = 131;
- y = 78;
- m = shop_snack_machine;
- };
- {
- x = 38;
- y = 137;
- m = shop_drink_automat;
- };
- { x = 39;
- y = 137;
- m = shop_snack_machine;
- };
- {
- x = 48;
- y = 183;
- m = shop_drink_automat;
- };
- {
- x = 49;
- y = 183;
- m = shop_snack_machine;
- };
- {
- x = 133;
- y = 12;
- m = shop_drink_automat;
- };
- {
- x = 134;
- y = 12;
- m = shop_snack_machine;
- };
- {
- x = 134;
- y = 138;
- m = shop_drink_automat;
- };
- {
- x = 135;
- y = 138;
- m = shop_snack_machine;
- };
- {
- x = 11;
- y = 91;
- m = shop_drink_automat;
- };
- {
- x = 12;
- y = 91;
- m = shop_snack_machine;
- };
- {
- x = 209;
- y = 66;
- m = shop_drink_automat;
- };
- {
- x = 210;
- y = 66;
- m = shop_snack_machine;
- };
- {
- x = 185;
- y = 186;
- m = shop_mc;
- };
- {
- x = 112;
- y = 221;
- m = shop_drink_automat;
- };
- {
- x = 113;
- y = 221;
- m = shop_snack_machine;
- };
- {
- x = 102;
- y = 176;
- m = shop_cars;
- };
- {
- x = 34;
- y = 21;
- m = shop_water;
- };
- {
- x = 129;
- y = 77;
- m = shop_water;
- };
- {
- x = 31;
- y = 142;
- m = job_menu;
- };
- }
- -----------------------------
- -- IRC CHANNEL CONFIG --
- -----------------------------
- --------------------------
- --** ADVERTISE **--
- --------------------------
- timer(600000,"advertise")
- function advertise()
- msg("©255255255Tip: Are you feel hungry? Go to eat any restaurants, or vending-machines!");
- end
- timer(900000,"advertise2")
- function advertise2()
- msg("©255255255Tip: Are you see player breaking rules? Report him with /report <id> <reason>");
- end
Add Comment
Please, Sign In to add comment