Postado Abril 7, 2016 9 anos O script é basico mas não estou conseguindo cria-lo. Quando o player morre ele verifica os leveis do que matou ele e de quem morreu, se os dois forem level maior que 750, então ele adiciona 1 ponto para quem matou na tabela `rep` que fica em players na database, e tira 1 ponto de quem morreu. Obs: Script não da erro mas não adiciona os pontos e nem tira. function onDeath(cid, corpse, deathList) local repu = (1) local perd = (-1) if isPlayer(deathList[1]) then local p1 = getPlayerLevel(deathList[1]) local p2 = getPlayerLevel(cid) local id1 = getPlayerGUID(deathList[1]) local id2 = getPlayerGUID(cid) if p1 >= 750 then if p2 >= 750 then db.executeQuery("UPDATE `players` SET `rep` = `rep` + " .. repu .. " WHERE `id` = " .. id1 .. ";") db.executeQuery("UPDATE `players` SET `rep` = `rep` + " .. perd .. " WHERE `id` = " .. id2 .. ";") return true end end end return true end
Postado Abril 7, 2016 9 anos Solução Fiz um com onKill pra você: function onKill(cid, target) local cidID, targetID = getPlayerGUID(cid), getPlayerGUID(target) local targetREP = db.getResult("SELECT `rep` FROM `players` WHERE `id` = " .. targetID .. ";") local rep = targetREP:getDataInt("rep") if isPlayer(cid) and isPlayer(target) then if getPlayerLevel(cid) >= 750 and getPlayerLevel(target) >= 750 then db.executeQuery("UPDATE `players` SET `rep` = `rep` + " .. 1 .. " WHERE `id` = " .. cidID .. ";") if rep > 0 then db.executeQuery("UPDATE `players` SET `rep` = `rep` - " .. 1 .. " WHERE `id` = " .. targetID .. ";") end end end return true end TAG: <event type="kill" name="repNew" event="script" value="arquivo.lua"/> E não esqueça de registrar no login.lua! registerCreatureEvent(cid, "repNew") Coloquei também uma checagem de rep para não deixar o player com rep negativo, se você quiser tirar é só remover essas linhas: if rep > 0 then db.executeQuery("UPDATE `players` SET `rep` = `rep` - " .. 1 .. " WHERE `id` = " .. targetID .. ";") end ➥ Regras | Seções OTServ | Seções BOT
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.