BE

[Creatureevent] Respect System By Gustavo

Por Beeki, 02 de jun. de 2012 em Globalevents e Spells

otserv
tibia
script
8
2.8k
BeekiB
02 de junho de 2012 às 17:59

Olá amigos, vim lhes trazer um sistema feito pelo nosso querido Administrador Gustavo.

 

Antes de tudo execute este comando no seu banco de dados.

 

CREATE TABLE IF NOT EXISTS `respects` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `to_pid` int(11) NOT NULL,
 `from_pid` int(11) NOT NULL,
 `time` int(11) NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

 

Logo após, crie um novo script em data/talkactions com o nome de respect, e insira o seguinte código.

 

--[[
by Gustavo from Xtibia.com
to (Precisa estar online)
from (Ser level 125+)
!respect surtado
==]]

function onSay(cid, words, param, channel)

--local param =
local param = string.lower(param)
--local fromPid = cid

if(param == "") then
 --doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to write a player name.")
 doPlayerSendCancel(cid, "You have ".. getPlayerRespects(getPlayerGUID(cid)).." respect(s).")
 --doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
 return true
end

-- cid to is online?
local pid = getPlayerByName(param)
if not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(cid) < getPlayerGhostAccess(pid)) then
 doPlayerSendCancel(cid, "Player must be online.")
 doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
 return true
end

-- cid from has level 125?
if(getPlayerLevel(cid) < 125) then
 doPlayerSendCancel(cid, "You must have level 125 to give respect!")
 doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
 return true
end

local toPid = getPlayerGUID(pid)
local fromPid = getPlayerGUID(cid)
-- cid from has level 125?
if(toPid == fromPid) then
 doPlayerSendCancel(cid, "You are so humble!! You cannot give respect to yourself. ")
 doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
 return true
end

-- ja tem respect? Se sim, tira. Se nao, coloca
local idRespect = getPlayerRespect(toPid, fromPid)
 if(idRespect > 0) then
  removeRespect(idRespect)
  doSendAnimatedText(getPlayerPosition(pid), "-1 Resp", TEXTCOLOR_RED)
  doPlayerSendCancel(cid, "You remove your respect from "..param.."")
else
 addRespect(toPid, fromPid)
 doSendAnimatedText(getPlayerPosition(pid), "+1 Resp", TEXTCOLOR_YELLOW)
 doPlayerSendCancel(cid, "You give your respect to "..param.."")  
 return true
 end

end

 

Talkactions.xml

 

  <talkaction words="!respect;/respect" event="script" value="respect.lua"/>

 

Em seguida... Crie um arquivo com o nome respect_system em data/creaturescripts, e insira o seguinte código.

 

function onLook(cid, thing, position, lookDistance)
 if(isPlayer(thing.uid)) then
doPlayerSetSpecialDescription(thing.uid,' [Respect: '..getPlayerRespects(getPlayerGUID(thing.uid))..']')
 end
 return true  
end

 

Creaturescripts.xml

 

<event type="look" name="respectLook" event="script" value="respect_system.lua"/> -->

 

Para terminar é só inserir em seu servidor essas novas libs.

 

 

function getPlayerRespect(toPid, fromPid)
local Info = db.getResult("SELECT `id` FROM `respects` WHERE `to_pid` = " .. toPid .. " and `from_pid` = " .. fromPid .. " LIMIT 1")
	if Info:getID() ~= -1 then					
			local id = Info:getDataInt("id")
	Info:free()
	return id
end
 return 0
end
function getPlayerRespects(toPid)
local Info = db.getResult("SELECT count(id) as id FROM `respects` WHERE `to_pid` = " .. toPid .. " LIMIT 1")
	if Info:getID() ~= LUA_ERROR then
	local id = Info:getDataInt("id")
	Info:free()
	return id
end
 return LUA_ERROR
end
function removeRespect(idRespect)
	db.executeQuery("DELETE FROM `respects` WHERE `id` = " .. idRespect .. "")
end
function addRespect(toPid, fromPid)
	db.executeQuery("INSERT INTO `respects` (to_pid, from_pid,time) VALUES (" .. toPid .. ", " .. fromPid .. ", " .. os.time() .. ")")
end

 

 

Créditos: Gustavo XTibia, Demonbholder.

Editado Junho 4 por Beeki

SkyDangerousS
02 de junho de 2012 às 19:24

Bom, quando eu baixei o global war no meu pc tinha esse script.

 

O problema foi fazer a query que eu não sabia direito .. tive que fazer umas tabelas com nome diferente pra funfar.

 

agora falta a parte de web que fica no gesior ;D

BeekiB
02 de junho de 2012 às 19:49

Ok, irei ver se consigo a pagina em PHP do mesmo.

OneshotO
04 de junho de 2012 às 08:06

Ui Ui Ui

 

O grande Gustavo fazendo scripts Lua. Gostei :)

 

Rep+ para você por trazer ao XTibia, Beeki

Editado Junho 4 por Oneshot

BeekiB
04 de junho de 2012 às 08:23

HAHA, valeu carinha (:

 

 

@One

 

Poderia me passar seu e-mail ou msn de contato?

6 anos depois...
QwizerQ
21 de junho de 2018 às 16:01

se tiver a pagina do gesior posta ai :)

BennyB
21 de junho de 2018 às 18:24
2 horas atrás, Qwizer disse:

se tiver a pagina do gesior posta ai :)

 

Olha a data, poxa, logo você? :(

 

BeekiB
25 de junho de 2018 às 17:28
Em 21/06/2018 em 16:01, Qwizer disse:

se tiver a pagina do gesior posta ai :)

 

Não tenho mais.