Skrypty & Kody Przer?bka

Pucek1993

Active User
Zarejestrowany
Dołączył
Luty 4, 2016
Posty
71
Liczba reakcji
1
Witam, czy pom?g?by mi kto? przerobi? poni?szy skrypt, aby da?o si? ustawi? % szansy na to ?e z danego potwora wypadnie dodatkowy item? :) Chcia?bym aby pojawia? si? w ciele - ale w plecaku r?wnie? mnie zadowoli.

PHP:
local config = {
	nagroda = {id = 2160, ilosc = 5}, -- id, ilosc
	nazwaPotwora = 'Rabbit' -- nazwa potwora
}
function onKill(cid, target)
	if (getCreatureName(target) == config.nazwaPotwora) then
		doPlayerAddItem(cid,config.nagroda.id,config.nagroda.ilosc)
		doPlayerSendTextMessage(cid, 22, "Gratulacje, otrzymales nagrode.") -- komunikat pdczas otrzymywania nagrody
		return true
	else
		return true
	end
end

btw.

nazwaPotwora = 'Rabbit' -- nazwa potwora

Mog? tutaj wpisa? wi?cej potwor?w, ni? jeden?

nazwaPotwora = 'Rabbit, Rat'
 
Odp: Przer?bka

gdybys czegos nie wiedzial to pytaj w tym temacie ;)

[lua]local config = {
nagrody = {
{2160, 5},
{2160, math.random(100)}, -- tutaj przyklad gdybys chcial losowa ilosc danego itema, dziala tylko na stackujacych sie itemach, do normalnyc trzeba by zmienci troche :D
--tu moesz analogicznie dopisywac wiecejj itemow tak:
--{id_itema, ilosc itema},przecinek
},
monsters = {'Rabbit', 'Troll', 'Ghull'}, -- nazwy mobow
percent = 10, --procent szans ze po zabiciu cos poleci
randomRewards = true --jak dasz false to bedzie dawalo wszystkie nagrody, obecnie daje losowe
}
function onKill(cid, target)

if(isMonster(target)) then
if(isInArray(config.monsters, getCreatureName(target))) then
if(math.random(100) < config.percent) then
if(config.randomRewards == false) then
for i = 1, #config.nagrody do
doPlayerAddItem(cid, config.nagrody[1], config.nagrody[2], true) -- te true na koncu robi ze jak ktos capa/miejsca nie ma to wywali na ziemie
end
else
local randomItem = config.nagrody[math.random(1, #config.nagrody)]
doPlayerAddItem(cid, randomItem[1], randomItem[2])
end
doPlayerSendTextMessage(cid, 22, "Gratulacje, otrzymales nagrode.")
end
end
end
return true
end

[/lua]
 
Ostatnia edycja:
Odp: Przer?bka

PHP:
08:47 Welcome to Forgotten!
08:47 Your last visit was on Thu Oct 13 08:45:25 2016.
08:47 Gratulacje, otrzymales nagrode.
08:47 Loot of a rabbit: a carrot, meat
08:47 Gratulacje, otrzymales nagrode.
08:47 Loot of a rabbit: a carrot, meat

Dzi?kuj? Ci bardzo :) - kurde, mam jeszcze jeden pomys?. Mia?oby to polega? na "boss" systemie (nigdzie tego nie widzia?em) skrypt mia?by jak?? tam szanse, na to ?e jak zabijemy np. trolla, to pojawia si? boss troll. Mam taki skrypt:

PHP:
local config = {
	-- ordered by chance, the last chance being 100
	{chance = 10,  monster = 'Troll',   message = 'The white deer summons all his strength and turns to fight!'},
	{chance = 10, monster = 'Demon', message = 'The white deer desperately tries to escape!'}
}

function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
	local targetMonster = creature:getMonster()
	if not targetMonster or targetMonster:getMaster() then
		return true
	end

	local chance = math.random(100)
	for i = 1, #config do
		if chance <= config[i].chance then
			local spawnMonster = Game.createMonster(config[i].monster, targetMonster:getPosition(), true, true)
			if spawnMonster then
				spawnMonster:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
				targetMonster:say(config[i].message, TALKTYPE_MONSTER_SAY)
			end
			break
		end
	end
	return true
end

ale przy moich umiej?tno?ciach, musia?bym do ka?dego potwora tworzy? nowy event, nowy skrypt. + ?eby to dzia?a?o, musze do ka?dego potwora dodawa? event. Potrafi?by? mi to ogarn??? :)
 
Back
Do góry