Postado Setembro 13, 2020 4 anos Relou, alguém pode da um help aqui pfv? Tô achando que é alguma função que não tem no servidor, mas gostaria de saber de alguém com mais experiência. 011-string.lua Spoiler string.split = function (str) local t = {} return not str:gsub("%w+", function(s) table.insert(t, s) return "" end):find("%S") and t or {} end string.trim = function (str) return str:gsub("^%s*(.-)%s*$", "%1") end string.explode = function (str, sep, limit) if(type(sep) ~= 'string' or isInArray({tostring(str):len(), sep:len()}, 0)) then return {} end local i, pos, tmp, t = 0, 1, "", {} for s, e in function() return string.find(str, sep, pos) end do tmp = str:sub(pos, s - 1):trim() table.insert(t, tmp) pos = e + 1 i = i + 1 if(limit ~= nil and i == limit) then break end end tmp = str:sub(pos):trim() table.insert(t, tmp) return t end string.expand = function (str) return string.gsub(str, "$(%w+)", function(n) return _G[n] end) end string.timediff = function (diff) local format = { {"week", diff / 60 / 60 / 24 / 7}, {"day", diff / 60 / 60 / 24 % 7}, {"hour", diff / 60 / 60 % 24}, {"minute", diff / 60 % 60}, {"second", diff % 60} } local t = {} for k, v in ipairs(format) do local d, tmp = math.floor(v[2]), "" if(d > 0) then tmp = (k < table.maxn(format) and (table.maxn(t) > 0 and ", " or "") or " and ") .. d .. " " .. v[1] .. (d ~= 1 and "s" or "") table.insert(t, tmp) end end return t end ARMAS.LUA Spoiler ARMAS = { [5947] = {municao = 2144, atk = 22, preco = 8000, balasmax = 30, buyable = false}, -- Nemesis Bazooka's [2450] = {municao = 2144, atk = 13, preco = 15000, balasmax = 12, buyable = true}, -- [2422] = {municao = 2143, atk = 13, preco = 15000, balasmax = 12, buyable = true}, -- Shotgun M1 [2426] = {municao = 2144, atk = 13, preco = 15000, balasmax = 12, buyable = true}, -- Golden Desert Eagle [2451] = {municao = 2144, atk = 13, preco = 15000, balasmax = 12, buyable = true}, -- [2376] = {municao = 2144, atk = 13, preco = 15000, balasmax = 12, buyable = true}, -- P90 [2412] = {municao = 2144, atk = 13, preco = 15000, balasmax = 12, buyable = true}, -- Silver 38 [7451] = {municao = 2144, atk = 13, preco = 15000, balasmax = 12, buyable = true}, -- [2428] = {municao = 2143, atk = 13, preco = 15000, balasmax = 12, buyable = true}, -- Machine-Shotgun 23T3 [2448] = {municao = 2144, atk = 13, preco = 15000, balasmax = 12, buyable = true}, -- [2449] = {municao = 2144, atk = 13, preco = 15000, balasmax = 12, buyable = true}, -- [2425] = {municao = 2144, atk = 13, preco = 15000, balasmax = 12, buyable = true}, -- MP5 [2421] = {municao = 2143, atk = 13, preco = 15000, balasmax = 12, buyable = true}, -- Shotgun M2 [2435] = {municao = 2143, atk = 13, preco = 15000, balasmax = 12, buyable = true}, -- Country Shotgun [2559] = {municao = 2143, atk = 13, preco = 15000, balasmax = 12, buyable = true}, -- Shotgun } function fixString(string) local k = string.explode(string," ") local x = "" local y = 0 for i = 1, #k do if y == 0 then x = x ..string.sub(k,0,1):upper()..string.sub(k,2) y = 1 else x = x .." "..string.sub(k,0,1):upper()..string.sub(k,2) end end return xend function arb(a,b) return a ~= nilend function isUsingGun(cid) if arb(ARMAS,getPlayerSlotItem(cid, 6).itemid) or arb(ARMAS,getPlayerSlotItem(cid, 5).itemid) then return true end return falseend function getPlayerGun(cid) if arb(ARMAS,getPlayerSlotItem(cid, 6).itemid) then return {getPlayerSlotItem(cid, 6).uid,getPlayerSlotItem(cid, 6).itemid} elseif arb(ARMAS,getPlayerSlotItem(cid, 5).itemid) then return {getPlayerSlotItem(cid, 5).uid,getPlayerSlotItem(cid, 5).itemid} endend function isGun(id) return ARMAS[id] ~= nilend function getGunBullets(uid) return tonumber(string.explode(string.explode(getItemAttribute(uid,"description")," ")[2],"/")[1])end function getGunMaxBullets(uid) return tonumber(string.explode(string.explode(getItemAttribute(uid,"description")," ")[2],"/")[2])end function setGunBullets(uid,val) return doItemSetAttribute(uid,"description","Bullets: "..val.."/"..string.explode(getItemAttribute(uid,"description"),"/")[2])end Gun.lua Spoiler function onUseWeapon(cid, var) if isUsingGun(cid) then local gun = getPlayerGun(cid)[1] if getGunBullets(gun) > 0 then setGunBullets(gun,getGunBullets(gun)-1) doSendDistanceShoot(getThingPos(cid),getThingPos(getCreatureTarget(cid)),40) addEvent(doAreaCombatHealth,100,cid,COMBAT_PHYSICALDAMAGE, getThingPos(getCreatureTarget(cid)), 0, -ARMAS[getPlayerGun(cid)[2]].atk, -(ARMAS[getPlayerGun(cid)[2]].atk+(math.floor(ARMAS[getPlayerGun(cid)[2]].atk/2))), 0) else doPlayerSendCancel(cid,"Você não tem munição na arma.") end end return falseend Estou usando essa versão do TFS: Meu Curso sobre Programação para OTServer Programando OTServer Peça o seu script! Entre agora mesmo no grupo Developing Conteúdos: Spoiler • Cidade [8.60] • Cave de Boss • Widget Gesior • Autoloot 100% • [Old Client] Como Hookar Dll • Configurando VPS Windowns • [Solução] Código Caracteres Especiais Discord: Belmont#7352 Não esqueça do REP+
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.