Ir para conteúdo

Featured Replies

Postado

Pessoal, esse é um script de um evento de sobrevivência, porém, essa parte dele(creaturescripts) da um erro geral nos players, quando eu boto ele pra funcionar os players do serv inteiro n morrem mais, n sei se é pq ta faltando a função nele, enfim, é mt complexo pra mim, se alguém puder ajudar... minha tfs é 1.0

 

Mostrar conteúdo oculto

 

Postado
local item = {
	id = 3058,
	count = 1
}

local G = {
	set = function(s, v) Game.setStorage(s, v) end,
	get = function(s) return Game.getStorage(s) end
}

broadcast = Game.broadcastMessage

function deathMessage(name, attacker)
	return "You recognize " .. name .. ". He was killed by ".. (attacker:isCreature() and "a "..attacker:getName():lower() or "a field item")
end

function setTextOfItem(item, attr, str)
	if not item:isItem() then
		return
	end
	if type(attr) == 'table' then
		for attribute, text in pairs(attr) do
			item:setAttribute(attribute, text)
		end
	else
		item:setAttribute(attribute, str)
	end
end

function onStatsChange(cid, attacker, type, combat, value)
	if type == STATSCHANGE_HEALTHLOSS then
		local player = Player(cid)
		if player then
			local p = {}
			p.health = player:getHealth()
			p.name = player:getName()
			p.get = function(s) return player:getStorage(s) end
			p.set = function(s, v) return player:setStorage(s, v) end
			p.pos = player:getPosition()
			p.temple = Town(player:getTown():getId()):getTemplePosition()
						
			if p.health <= value then
				if p.get(OL_playerStorage) > 0 then
					if G.get(OL_playerCount) > OL_winnerscount then
					
						broadcast(p.name .. " have been died!", MESSAGE_STATUS_CONSOLE_RED)
						
						local corpse = doCreateItem(item.id, item.count, p.pos)
						setTextOfItem(corpse, ITEM_ATTRIBUTE_DESCRIPTION, deathMessage(p.name, attacker))
						
						p.pos:sendMagicEffect(CONST_ME_POFF)
						player:teleportTo(p.temple, false)
						p.temple:sendMagicEffect(CONST_ME_TELEPORT)
						
						player:addHealth(-player:getMaxHealth())
						
						G.set(OL_playerCount, G.get(OL_playerCount) - 1)
						p.set(OL_playerStorage, 0)

					elseif G.get(OL_playerCount) <= OL_winnerscount then
						if OL_winnerscount > 1 then
							broadcast(p.name .. " is one of " .. OL_winnerscount .. " winners of One Left event! Congratulations!", MESSAGE_STATUS_WARNING)
							player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You are one of the winners of One Left Event.")
						else
							broadcast(p.name " is the winner of One Left event! Congratulations!", MESSAGE_STATUS_WARNING)
							player:sendTextMessage(MESSAGE_INFO_DESCR,	"Congratulations! You are the winner of One Left Event.")
						end
						
						if OL_goblet[1] then
							local wgoblet = player:addItem(OL_goblet[2], 1)
							setTextOfItem(wgoblet, 
								{
									[ITEM_ATTRIBUTE_DESCRIPTION] = "Awarded to " .. p.name .. " for winning the One Left event.",
									[ITEM_ATTRIBUTE_TEXT] = "Awarded to " .. p.name .. " for winning the One Left event."
								}
							)
						end
						if OL_PPoints[1] then
							local accountId = getAccountNumberByPlayerName(p.name)
							db.storeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. OL_PPoints[2] .. " WHERE `account_id` = " .. accountId)
						end

						for _, reward in ipairs(OL_rewards) do
							player:addItem(reward, 1)
						end

						if OL_moneyReward[1] then
							player:addItem(OL_moneyReward[2], OL_moneyReward[3])
						end

						if G.set(OL_playerCount) == 0 then
							for x = OL_fromPosition.x, OL_toPosition.x do
								for y = OL_fromPosition.y, OL_toPosition.y do
									for z = OL_fromPosition.z, OL_toPosition.z do
										areapos = {x = x, y = y, z = z, stackpos = 253}
										getMonsters = getThingfromPos(areapos)
										if isMonster(getMonsters.uid) then
											doRemoveCreature(getMonsters.uid)
										end
									end
								end
							end
						end
					end
				end
			end
		end
	end
	return true
end

 

Editado por Codex NG
Changed syntax style (veja o histórico de edições)

Postado
  • Autor

@Codex NG vlw man, vou testar quando chegar em casa. Obs se vc tiver o evento oneleft inteiro funcionando cria um tiro pra ele, acho q a galera iria gostar

@Codex NG vlw man, vou testar quando chegar em casa. Obs se vc tiver o evento oneleft inteiro funcionando cria um tiro pra ele, acho q a galera iria gostar. Se puder, posta sua tag do creaturescripts tb aqui pra mim

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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo