• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

[Lua Function] Teleport If Player Have Quest Completed

Seminari

Banned User
Joined
Dec 13, 2009
Messages
1,496
Reaction score
34
Location
Poland
questStorage - is player storage key used in maaaany things, example: in quests ;s
questStorageId - is value of questStorage
goodPos - if player have done quest then will be teleported to this postions
badPos - if player haven't done quest then will be teleported to this positions

sign -:

0 - if you want to pass players which haven't got quest
1 - if you want to pass players which have special questStorageId (if player have bigger storage then required then he would'nt pass)
2 - if you want to pass players which have bigger storage then questStorageId


0 - pass if player have < questStorageId
1 - pass if player have == questStorageId
2 - pass if player have > questStorageId

Lua:
function doTeleportPlayerIfHasSpecialStorageIDofQuest(cid, questStorage, questStorageId, sign, goodPos, badPos, fromPosition)
	if sign < 1 then
		if getPlayerStorageValue(cid, questStorage) < quesStorageId then
			doTeleportThing(cid, goodPos)
			doSendMagicEffect(goodPos, CONST_ME_TELEPORT)
		else
			if (badPos == 0 or nil) then
				doTeleportThing(cid, fromPosition)
			else
				doTeleportThing(cid, badPos)
			end
		end
	elseif sign == 1 then
		if getPlayerStorageValue(cid, questStorage) == quesStorageId then
			doTeleportThing(cid, goodPos)
			doSendMagicEffect(goodPos, CONST_ME_TELEPORT)
		else
			if (badPos == 0 or nil) then
				doTeleportThing(cid, fromPosition)
			else
				doTeleportThing(cid, badPos)
			end
		end
	elseif sign > 1 then
		if getPlayerStorageValue(cid, questStorage) > quesStorageId then
			doTeleportThing(cid, goodPos)
			doSendMagicEffect(goodPos, CONST_ME_TELEPORT)
		else
			if (badPos == 0 or nil) then
				doTeleportThing(cid, fromPosition)
			else
				doTeleportThing(cid, badPos)
			end
		end
	end

return true
end
 
for exampe in movement:

Lua:
function onStepIn(cid, item, position, fromPosition) 


local yalahar = {x=32780, y=31168, z=14} 
local gate = {x=32480, y=31268, z=7} 
yalaharStg = 22222
missionYala = 5

        if item.itemid == 1111 then 
        doTeleportPlayerIfHasSpecialStorageIDofQuest(cid, yalaharStg, missionYala, 2, yalahar, gate, fromPosition)
        end
 
for exampe in movement:

Lua:
function onStepIn(cid, item, position, fromPosition) 


local yalahar = {x=32780, y=31168, z=14} 
local gate = {x=32480, y=31268, z=7} 
yalaharStg = 22222
missionYala = 5

        if item.itemid == 1111 then 
        doTeleportPlayerIfHasSpecialStorageIDofQuest(cid, yalaharStg, missionYala, 2, yalahar, gate, fromPosition)
        end

This means that if you have storage 22222 < 5, will be transported to the exit and if you have storage 22222 = 5, will be transported to Yalahar?
 
.... NO

this means

if player have storage 22222 > 5 then will be teleported to Yalahar, else he will be teleported to gate


doTeleportPlayerIfHasSpecialStorageIDofQuest(cid, yalaharStg, missionYala, 2, yalahar, gate, fromPosition)

doTeleportPlayerIfHasSpecialStorageIDofQuest(cid, questStorage, questStorageId, sign, goodPos, badPos, fromPosition)

questStorage = yalaharStg questStorageId = missionYala

sign = 2 (player will be teleported to good pos if storage.value > required.value)

if sign will be sign = 1 then player will be teleported to good pos if storage.value < required.value
 
Thats too long, what about:
Lua:
 function doTeleportIfStorage(parameters)
 
Back
Top