• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Quests [help]

Glidarn

Member
Joined
May 9, 2009
Messages
970
Reaction score
16
Location
Åkersberga, Sweden
My dhq, anni and like "100cc" quest doesnt work and i dno why, i mean you don't get any rewards, anyone know why and what i need to do?

I mean how do i put an item in the chest? :confused:

/ Glidarn
 
Last edited:
This is my anniscript, dno why it doesnt work?

PHP:
local playerPosition =
{
	{x = 247, y = 659, z = 13, stackpos = STACKPOS_TOP_CREATURE},
	{x = 247, y = 660, z = 13, stackpos = STACKPOS_TOP_CREATURE},
	{x = 247, y = 661, z = 13, stackpos = STACKPOS_TOP_CREATURE},
	{x = 247, y = 662, z = 13, stackpos = STACKPOS_TOP_CREATURE}
}

local newPosition =
{
	{x = 189, y = 650, z = 13},
 	{x = 189, y = 651, z = 13},
	{x = 189, y = 652, z = 13},
	{x = 189, y = 653, z = 13}
}

-- Do not modify the declaration lines below.
local player = {0, 0, 0, 0}
local failed = TRUE

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		for i = 1, 4 do
			player[i] = getThingfromPos(playerPosition[i])
			if player[i].itemid > 0 then
				if isPlayer(player[i].uid) == TRUE then
					if getPlayerStorageValue(player[i].uid, 30015) == nil then
						if getPlayerLevel(player[i].uid) >= 100 then
							failed = FALSE
						end
					end
				end
			end

			if failed == TRUE then
				doPlayerSendCancel(cid, "Sorry, not possible.")
				return TRUE
			end

			failed = TRUE
		end

		for i = 1, 4 do
			doSendMagicEffect(playerPosition[i], CONST_ME_POFF)
			doTeleportThing(player[i].uid, newPosition[i], FALSE)
			doSendMagicEffect(newPosition[i], CONST_ME_ENERGYAREA)
		end
		doTransformItem(item.uid, item.itemid + 1)
	elseif item.itemid == 1946 then
		doPlayerSendCancel(cid, "Sorry, not possible.")
	end

	return TRUE
end

Looks like that
 
Last edited:
Aaaaaaa use code tags.
Im not going to help you if you dont use tags. Script must be tabbed too. :blink:

When you finish your job tell us: are there any errors in console?
 
PHP:
local playerPosition =
{
    {x = 247, y = 659, z = 13, stackpos = STACKPOS_TOP_CREATURE},
    {x = 247, y = 660, z = 13, stackpos = STACKPOS_TOP_CREATURE},
    {x = 247, y = 661, z = 13, stackpos = STACKPOS_TOP_CREATURE},
    {x = 247, y = 662, z = 13, stackpos = STACKPOS_TOP_CREATURE}
}

local newPosition =
{
    {x = 189, y = 650, z = 13},
     {x = 189, y = 651, z = 13},
    {x = 189, y = 652, z = 13},
    {x = 189, y = 653, z = 13}
}

PHP:
15:16 You see a switch.
ItemID: [1945], UniqueID: [5000].
Position: [X: 33226] [Y: 31671] [Z: 13].

What should i change in this then casue it's something wrong here ... and i have no idea
 
Here is the script I use for mine TFS 0.3.5 pl1, made by Shawak, all creds to him, I added some explanations next to the values.

Code:
        -- Annihilator by Shawak v2.1

        -- CONFIG --

        local room = {     -- room with demons, from top corner with demons, to the bottom corner (reward room)
        fromX = 172,
        fromY = 31,
        fromZ = 13,
        --------------
        toX = 190,
        toY = 36,
        toZ = 13
        }

        local monster_pos = { -- Where the demons should spawn
        [1] = {pos = {172, 31, 13}, monster = "Demon"},
        [2] = {pos = {174, 31, 13}, monster = "Demon"},
        [3] = {pos = {173, 35, 13}, monster = "Demon"},
        [4] = {pos = {175, 35, 13}, monster = "Demon"},
        [5] = {pos = {176, 33, 13}, monster = "Demon"},
        [6] = {pos = {177, 33, 13}, monster = "Demon"}
        }

        local players_pos = { -- 4 spots where players stands before pulling the lever
        {x = 173, y =52, z = 13, stackpos = 253},
        {x = 174, y =52, z = 13, stackpos = 253},
        {x = 175, y =52, z = 13, stackpos = 253},
        {x = 176, y =52, z = 13, stackpos = 253}
        }

        local new_player_pos = { -- The positions where the players should get TP:ed to
        {x = 172, y = 33, z = 13},
        {x = 173, y = 33, z = 13},
        {x = 174, y = 33, z = 13},
        {x = 175, y = 33, z = 13}
        }

        local playersOnly = "no" -- If you can use monsters and get TP:ed.
        local questLevel = 100

        ------------------------------------------------------
        --- CONFIG END ---------------------------------------
        ------------------------------------------------------

function onUse(cid, item, fromPosition, itemEx, toPosition)
        local all_ready, monsters, player, level = 0, 0, {}, 0
        if item.itemid == 1945 then
                for i = 1, #players_pos do
                        table.insert(player, 0)
                end
                for i = 1, #players_pos do
                        player[i] = getThingfromPos(players_pos[i])
                        if player[i].itemid > 0 then
                                if string.lower(playersOnly) == "yes" then
                                        if isPlayer(player[i].uid) == TRUE then
                                                all_ready = all_ready+1
                                        else
                                                monsters = monsters+1
                                        end
                                else
                                        all_ready = all_ready+1
                                end
                        end
                end
                if all_ready == #players_pos then
                        for i = 1, #players_pos do
                                player[i] = getThingfromPos(players_pos[i])
                                if isPlayer(player[i].uid) == TRUE then
                                        if getPlayerLevel(player[i].uid) >= questLevel then
                                                level = level+1
                                        end
                                else
                                        level = level+1
                                end
                        end
                        if level == #players_pos then
                                if string.lower(playersOnly) == "yes" and monsters == 0 or string.lower(playersOnly) == "no" then
                                        for _, area in pairs(monster_pos) do
                                                        doSummonCreature(area.monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]})
                                        end
                                        for i = 1, #players_pos do
                                                doSendMagicEffect(players_pos[i], CONST_ME_POFF)
                                                doTeleportThing(player[i].uid, new_player_pos[i], FALSE)
                                                doSendMagicEffect(new_player_pos[i], CONST_ME_ENERGYAREA)
                                                doTransformItem(item.uid,1946)
                                        end
                                else
                                        doPlayerSendTextMessage(cid,19,"Only players can do this quest.")
                                end
                        else
                                doPlayerSendTextMessage(cid,19,"All players have to be level "..questLevel.." to do this quest.")
                        end
                else
                        doPlayerSendTextMessage(cid,19,"You need "..table.getn(players_pos).." players to do this quest.")
                end
        elseif item.itemid == 1946 then
                local player_room = 0
                for x = room.fromX, room.toX do
                        for y = room.fromY, room.toY do
                                for z = room.fromZ, room.toZ do
                                        local pos = {x=x, y=y, z=z,stackpos = 253}
                                        local thing = getThingfromPos(pos)
                                        if thing.itemid > 0 then
                                                if isPlayer(thing.uid) == TRUE then
                                                        player_room = player_room+1
                                                end
                                        end
                                end
                        end
                end
                if player_room >= 1 then
                        doPlayerSendTextMessage(cid,19,"There is already a team in the quest room.")          
                elseif player_room == 0 then
                        for x = room.fromX, room.toX do
                                for y = room.fromY, room.toY do
                                        for z = room.fromZ, room.toZ do
                                                local pos = {x=x, y=y, z=z,stackpos = 253}
                                                local thing = getThingfromPos(pos)
                                                if thing.itemid > 0 then
                                                        doRemoveCreature(thing.uid)
                                                end
                                        end
                                end
                        end
                        doTransformItem(item.uid,1945)
                end
        end
        return TRUE
end

That's all :)
 
Back
Top