Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- FUNÇOES --
- function addInvite(cid, player)
- local playerinvite = nil
- for _, func in ipairs(getPlayersOnline()) do
- if getCreatureStorage(func, 15215) == getCreatureName(player) then
- playerinvite = tostring(getCreatureName(func))
- end
- end
- if getCreatureStorage(cid, 15215) == getCreatureName(player) then
- doPlayerSendTextMessage(cid, 27, "Voce ja convidou "..getCreatureName(player).." para duelar, aguarde a resposta.")
- return true
- end
- if getDistanceBetween(getPlayerPosition(cid), getPlayerPosition(player)) > 3 then
- doPlayerSendTextMessage(cid, 27, "Voce precisa chegar perto desse jogador para convida-lo.")
- return true
- end
- if playerinvite ~= nil then
- doPlayerSendTextMessage(cid, 27, "Esse jogador ja foi convidado por outro jogador.")
- return true
- end
- if not isCreature(player) then
- doPlayerSendTextMessage(cid, 27, "Esse jogador nao é valido.")
- return true
- end
- if getCreatureStorage(cid, 15215) ~= -1 then
- doPlayerSendTextMessage(cid, 27, "Voce nao pode convidar outro jogador, voce ja convidou o jogador "..getPlayerStorageValue(cid, 15215))
- return true
- end
- if getTilePzInfo(getThingPos(cid)) then
- doPlayerSendTextMessage(cid, 27, "Voce nao pode convidar outro jogador para o duelo, estando em Protection Zone.")
- return true
- end
- setPlayerStorageValue(cid, 15215, getCreatureName(player))
- doPlayerSendTextMessage(cid, 27, "Voce está convidando "..getCreatureName(player).." Para duelar.")
- doSendAnimatedText(getThingPos(player), "INVITED", 120)
- doPlayerSendTextMessage(player, 27, "Voce foi convidado para duelo por "..getCreatureName(cid))
- return true
- end
- local tempo = 5
- function doStartDuel(cid, cid2)
- if tempo == 0 then
- doCreatureSetSkullType(cid, SKULL_GREEN)
- doCreatureSetSkullType(cid2, SKULL_GREEN)
- doSendAnimatedText(getThingPos(cid), "BATTLE", 120)
- doSendAnimatedText(getThingPos(cid2), "BATTLE", 120)
- return true
- else
- doSendAnimatedText(getThingPos(cid), tempo, 120)
- doSendAnimatedText(getThingPos(cid2), tempo, 120)
- tempo = tempo - 1
- return addEvent(doStartDuel, 1000, cid, cid2)
- end
- return true
- end
- function doSalvePosition(cid)
- local p = getThingPos(cid)
- if isCreature(cid) then
- setPlayerStorageValue(cid, 18210, p.x)
- setPlayerStorageValue(cid, 18211, p.y)
- setPlayerStorageValue(cid, 18212, p.z)
- end
- return true
- end
- function acceptInvite(cid, player)
- if getCreatureStorage(player, 15215) ~= getCreatureName(cid) then
- doPlayerSendTextMessage(cid, 27, "Voce nao foi convidado por esse jogador.")
- return true
- end
- if getDistanceBetween(getPlayerPosition(cid), getPlayerPosition(player)) > 3 then
- doPlayerSendTextMessage(cid, 27, "Voce precisa chegar perto desse jogador para aceitar o seu pedido.")
- return true
- end
- if getTilePzInfo(getThingPos(cid)) then
- doPlayerSendTextMessage(cid, 27, "Voce nao pode aceitar o pedido de duelo, estando em Protection Zone.")
- return true
- end
- if getPlayerStorageValue(cid, 12577) <= 0 then
- setPlayerStorageValue(cid, 12577, 0)
- end
- if getPlayerStorageValue(cid, 12578) <= 0 then
- setPlayerStorageValue(cid, 12578, 0)
- end
- doPlayerSendTextMessage(player, 27, "O Jogador "..getCreatureStorage(player, 15215).." aceitou o seu pedido.")
- doSendAnimatedText(getThingPos(cid), "ACCEPTED", 120)
- setPlayerStorageValue(cid, 15122, 1)
- setPlayerStorageValue(player, 15122, 1)
- doSalvePosition(cid)
- doSalvePosition(player)
- addEvent(doStartDuel,1000,cid, player)
- return true
- end
- function recuseInvite(cid, player)
- if getCreatureStorage(player, 15215) ~= getCreatureName(cid) then
- doPlayerSendTextMessage(cid, 27, "Voce nao foi convidado por esse jogador.")
- return true
- end
- setPlayerStorageValue(player, 15215, -1)
- doPlayerSendTextMessage(player, 27, "O Jogador "..getCreatureName(cid).." Cancelou seu pedido de duelo.")
- doPlayerSendTextMessage(cid, 27, "Voce cancelou o pedido do jogador "..getCreatureName(player))
- doSendAnimatedText(getThingPos(cid), "RECUSED", 120)
- return true
- end
- function cancelInvite(cid)
- local player_cancel = nil
- for _, players in ipairs(getPlayersOnline()) do
- if getCreatureStorage(cid, 15215) == getCreatureName(players) then
- player_cancel = tostring(getCreatureName(players))
- end
- end
- if player_cancel == nil then
- doPlayerSendTextMessage(cid, 27, "Voce nao convidou ninquem, para cancelar.")
- return true
- end
- setPlayerStorageValue(cid, 15215, -1)
- doPlayerSendTextMessage(cid, 27, "Voce cancelou o seu pedido para "..player_cancel)
- doPlayerSendTextMessage(getPlayerByName(player_cancel), 27, "O Jogador "..getCreatureName(cid).." cancelou o seu convite de duelo.")
- doSendAnimatedText(getThingPos(cid), "RECUSED", 120)
- return true
- end
- function checkMeInvite(cid)
- local invites = nil
- for _, players in ipairs(getPlayersOnline()) do
- if getCreatureStorage(players, 15215) == getCreatureName(cid) then
- invites = tostring(getCreatureName(players))
- end
- end
- if invites ~= nil and getCreatureStorage(cid, 15215) == -1 then
- doPlayerSendTextMessage(cid, 27, "Voce tem invites de "..invites)
- elseif getCreatureStorage(cid, 15215) ~= -1 then
- doPlayerSendTextMessage(cid, 27, "Voce invitou o jogador "..getCreatureStorage(cid, 15215))
- else
- doPlayerSendTextMessage(cid, 27, "Voce nao convidou ninquem , e nem foi convidado.")
- end
- return true
- end
- function checkStatus(cid, player)
- if not isCreature(player) then
- doPlayerSendCancel(cid, "Creature Not found.")
- return true
- end
- doShowTextDialog(cid, 2160, " "..getCreatureName(player).." Status\n\nVitórias : "..getPlayerStorageValue(player, 12578).."\nDerrotas : "..getPlayerStorageValue(player, 12577).."")
- return true
- end
- -- FUNÇOES --
- function onSay(cid, words, param)
- function showCommands(cid)
- if isCreature(cid) then
- local msg = "Comandos:\n-Invite\n-Accept\n-Recuse\n-Cancel\n-Status\n-Check\n\nModo de Uso:\n"..words.." comando, NomedoJogador"
- doShowTextDialog(cid, 2160, msg)
- end
- return true
- end
- local txt = string.explode(param, ",")
- local pid = getPlayerByNameWildcard(txt[2])
- if txt[1] == "invite" then
- addInvite(cid, pid)
- elseif txt[1] == "accept" then
- acceptInvite(cid, pid)
- elseif txt[1] == "recuse" then
- recuseInvite(cid, pid)
- elseif txt[1] == "commands" then
- showCommands(cid)
- elseif txt[1] == "cancel" then
- cancelInvite(cid)
- elseif txt[1] == "status" then
- checkStatus(cid, pid)
- elseif txt[1] == "check" then
- checkMeInvite(cid)
- else
- doPlayerSendTextMessage(cid, 27, "Comando nao valido, para saber os comandos use: "..words.." commands")
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement