Postado Setembro 22, 2013 11 anos Bom, o titulo já diz tudo, a área pvp já ta certa mas quero assim: quando o player entrar no pvp um nascer de um lado sendo do time Azul e o outro nascer do outro lado sendo do Time Vermelho. O de teleport eu já arrumei, só quero mesmo é o Sistema de Times, Azul e Vermelho. REP+ pra quem resolver
Postado Setembro 22, 2013 11 anos Segue o código abaixo (não testei) em "data\creaturescripts\scripts" crie um arquivo chamado "pvpTeam.lua" e cole o seguinte código redTeamSpawn = { x = 100, y = 100, z = 7} -- red team spawn position blueTeamSpawn = { x = 200, y = 200, z = 7} -- blue team spawn position redTeamParticipants = {} blueTeamParticipants = {} function teamLength(team) -- return the number of players in team local count = 0 for _ in pairs(T) do count = count + 1 end return count end function playerJoin(cid) -- try to join player in event if ableToJoin(cid) then redTeamParticipantsLength = teamLength(redTeamParticipants) blueTeamParticipantsLength = teamLength(blueTeamParticipants) if redTeamParticipantsLength <= blueTeamParticipantsLength then redTeamParticipants[cid] = true else blueTeamParticipants[cid] = true end return TRUE else return FALSE end end function playerRemove(cid) -- remove player from event (if its participating) if isParticipating(cid) then if redTeamParticipants[cid] == true then redTeamParticipants[cid] = nil else blueTeamParticipants[cid] = nil end return TRUE else return FALSE end end function isParticipating (cid) -- verify if player is participating of the event if blueTeamParticipants[cid] == true or redTeamParticipants[cid] == true then return FALSE else return TRUE end end function ableToJoin (cid) -- checks if players are able to join if isPlayer(cid) and not isParticipating(cid) then return TRUE else return FALSE end end function playersOfSameTeam (cid1, cid2) -- checks if the players are of the same team if ((blueTeamParticipants[cid1] == true and blueTeamParticipants[cid2] == true) or (redTeamParticipants[cid1] and redTeamParticipants[cid2])) then return TRUE else return FALSE end end function onLogout(cid) -- this function is essential to not unbalance the teams if isParticipating (cid) then return playerRemove(cid) end return TRUE end function onStatsChange(cid, attacker, t, combat, value) -- verify if both are logged in if not isPlayer(cid) or not isPlayer(attacker) then return FALSE end -- verify if both are participating of PVP if isParticipating(cid) and isParticipating(attacker) then -- both are participating of event -- verify if both are of the same team if playersOfSameTeam(cid, attacker) then -- they're of the same team. Only heals are acceptable if t == STATSCHANGE_HEALTHGAIN then return TRUE else return FALSE end else -- they're not of the same team. Only damages are acceptable if t == STATSCHANGE_HEALTHGAIN then return FALSE else return TRUE end end else -- one or both are not participating of event return TRUE end -- getting local player1Team = monstersTeam[getCreatureName(cid)] -- return if it has no team if player1Team == nil then return TRUE end -- getting monster that is attacking team local monster2Team = monstersTeam[getCreatureName(attacker)] -- return if it has no team if monster2Team == nil then return TRUE end -- check if they're of the same team if monster1Team == monster2Team then -- if they're of the same team, returning false will not allow the damage to be done to its partner return FALSE else return TRUE end return TRUE end agora, em "creaturescripts.xml" adicione o seguinte <event type="statschange" name="PvpTeam1" event="script" value="pvpTeam.lua"/> <event type="logout" name="PvpTeam2" event="script" value="pvpTeam.lua"/> depois, no arquivo "login.lua" que se encontra em "data\creaturescripts\scripts" adicione registerCreatureEvent(cid, "PvpTeam1") registerCreatureEvent(cid, "PvpTeam2") Lembrando que você tem que acoplar a sua função de participação do evento à este sistema que eu fiz (já possui as funções de adicionar e remover players). Caso dê algum problema, me fale, podemos testar o sistema mais tarde. Bom, é isso. Espero ter ajudado. P.S.: Não me importo que roubem meus créditos e/ou postem em outros fórums. Editado Setembro 22, 2013 11 anos por warotserv (veja o histórico de edições)
Postado Setembro 22, 2013 11 anos Autor Tipo não é de evento tlg, é só um PVP normal' mas eu queria de times
Postado Setembro 22, 2013 11 anos Pronto, sistema testado e funcionando.em "data\creaturescripts\scripts" crie um arquivo chamado "pvpTeam.lua" e cole o seguinte código redTeamSpawn = { x = 100, y = 100, z = 7} -- red team spawn position blueTeamSpawn = { x = 200, y = 200, z = 7} -- blue team spawn position redTeamParticipants = {} blueTeamParticipants = {} function teamLength(team) -- return the number of players in team local count = 0 for _ in pairs(team) do count = count + 1 end return count end function playerJoin(cid) -- try to join player in event if ableToJoin(cid) then redTeamParticipantsLength = teamLength(redTeamParticipants) blueTeamParticipantsLength = teamLength(blueTeamParticipants) if redTeamParticipantsLength <= blueTeamParticipantsLength then redTeamParticipants[cid] = true doPlayerSendTextMessage(cid,22,"Voce foi escolhido para ser do time vermelho.") else blueTeamParticipants[cid] = true doPlayerSendTextMessage(cid,22,"Voce foi escolhido para ser do time azul.") end return TRUE else return FALSE end end function playerRemove(cid) -- remove player from event (if its participating) if isParticipating(cid) then if redTeamParticipants[cid] == true then redTeamParticipants[cid] = nil else blueTeamParticipants[cid] = nil end return TRUE else return FALSE end end function isParticipating (cid) -- verify if player is participating of the event if blueTeamParticipants[cid] == true or redTeamParticipants[cid] == true then return TRUE else return FALSE end end function ableToJoin (cid) -- checks if players are able to join if isPlayer(cid) and not isParticipating(cid) then return TRUE else return FALSE end end function arePlayersOfSameTeam (cid1, cid2) -- checks if the players are of the same team if ((blueTeamParticipants[cid1] == true and blueTeamParticipants[cid2] == true) or (redTeamParticipants[cid1] and redTeamParticipants[cid2])) then return TRUE else return FALSE end end function onLogin(cid) -- checks if it's really a player and if it's only if isPlayer(cid) then if isParticipating(cid) == true then return FALSE -- Ooops! If the script reachs here, we gotta verify what's going wrong else if playerJoin(cid) == true then return TRUE -- everything gone as expected else return FALSE -- Ooops! If the script reachs here, we gotta verify what's going wrong end end else return TRUE end end function onLogout(cid) -- this function is essential to not unbalance the teams if isParticipating (cid) then return playerRemove(cid) end return TRUE end function onAttack(cid, attacker) -- verify if both are players if not isPlayer(cid) or not isPlayer(attacker) then return TRUE end -- are those players participating of the event? if not isParticipating(cid) or not isParticipating (attacker) then return TRUE end if arePlayersOfSameTeam(cid, attacker) then -- a player of the same team cannot attack the other!! return FALSE else return TRUE end end function onStatsChange(cid, attacker, t, combat, value) -- verify if both are players if not isPlayer(cid) or not isPlayer(attacker) then return TRUE end -- verify if both are participating of PVP if isParticipating(cid) and isParticipating(attacker) then -- both are participating of event -- verify if both are of the same team if arePlayersOfSameTeam(cid, attacker) then -- they're of the same team. Only heals are acceptable if t == STATSCHANGE_HEALTHGAIN or t == STATSCHANGE_MANAGAIN then return TRUE else return FALSE end else -- they're not of the same team. Only damages are acceptable if t == STATSCHANGE_HEALTHGAIN or t == STATSCHANGE_MANAGAIN then return FALSE else return TRUE end end else -- one or both are not participating of event return TRUE end -- getting local player1Team = monstersTeam[getCreatureName(cid)] -- return if it has no team if player1Team == nil then return TRUE end -- getting monster that is attacking team local monster2Team = monstersTeam[getCreatureName(attacker)] -- return if it has no team if monster2Team == nil then return TRUE end -- check if they're of the same team if monster1Team == monster2Team then -- if they're of the same team, returning false will not allow the damage to be done to its partner return FALSE else return TRUE end return TRUE end agora, em "creaturescripts.xml" adicione o seguinte <event type="attack" name="PvpTeam1" event="script" value="pvpTeam.lua"/> <event type="statschange" name="PvpTeam2" event="script" value="pvpTeam.lua"/> <event type="login" name="PvpTeam3" event="script" value="pvpTeam.lua"/> <event type="logout" name="PvpTeam4" event="script" value="pvpTeam.lua"/> depois, no arquivo "login.lua" que se encontra em "data\creaturescripts\scripts" adicione registerCreatureEvent(cid, "PvpTeam1") registerCreatureEvent(cid, "PvpTeam2") registerCreatureEvent(cid, "PvpTeam3") registerCreatureEvent(cid, "PvpTeam4") Obs: use os spawn points apenas se desejar. Bom, é isso. Espero ter ajudado. P.S.: Não me importo que roubem meus créditos e/ou postem em outros fórums. Editado Setembro 22, 2013 11 anos por warotserv (veja o histórico de edições)
Postado Setembro 23, 2013 11 anos Autor Bom cara, não testei mas leva Rep+ garantido por ter tentado ajudar e provavelmente ajudado kkkk' Obrigado
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.