• 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!

[Request] OnUse script, help please

Ryryk

New Member
Joined
Jun 28, 2008
Messages
30
Reaction score
0
Im looking for a script that turns a player into a looktype of 275 (sea serpent) when they use itemid 2346 is used. The player has to be in walkable water to use it (ids 4820, 4821, 4822, 4823, 4824, 4825 ). The item also has to increase the players movement speed while in the swimmable water. I would also like it to last only 2 minutes if possible aswell. Hope someone can help me with this script, I will ++ rep too =P

Basically its a swimming mount script xD
 
try with this:

Lua:
local id = 275 -- id of creature

function onUse(cid, item, fromPosition, itemEx, toPosition)
    doCreatureChangeOutfit(cid, id)
    doCreatureSay(cid, "Whooa! im a sea!!", TALKTYPE_ORANGE_1)
    setPlayerStorageValue(cid, 2529,1)
end

movement:

Lua:
function onStepIn(cid, item, frompos, itemEx, topos, fromPosition)

if getPlayerStorageValue(cid,2529) == 1 then
    doCreatureSay(cid, "Im walk here!!", TALKTYPE_ORANGE_1)
else
    doCreatureSay(cid, "You dont have permission to walk here!!", TALKTYPE_ORANGE_1)
    doTeleportThing(cid,fromPosition)
return TRUE
  end


Report Errorrs Bye
 
Last edited:
Actions.xml
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local s,v = 18528,getThingPos(cid) --storage value,function.
	if getCreatureOutfit(cid).lookType ~= 275 then
		if getPlayerStorageValue(cid,s) < os.time or getPlayerStorageValue(cid,s) < 0 then
		local tmp = getCreatureOutfit(cid)
		tmp.lookType = 275
			doCreatureChangeOutfit(cid,tmp)
			doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_RED,'You turned into a sea serpent for 2 minutes.')
			setPlayerStorageValue(cid,s,os.time+120)
		else
			doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_RED,'You can\'t use this for '..getPlayerStorageValue(cid,s)..' seconds!')
			doPlayerSendMagicEffect(v,CONST_ME_POFF)
		end
	else
		doPlayerSendCancel(cid,'Not possible for '..getPlayerStorageValue(cid,s)..' seconds.')
		doSendMagicEffect(v,CONST_ME_POFF)
	end
	return true
end
@updated.

Movements.xml
Lua:
local speed = createConditionObject(CONDITION_HASTE)
setConditionParam(speed, CONDITION_PARAM_TICKS,2*60*1000)
setConditionFormula(speed, 0.9,150, 0.9,150)

local allowed = {4820,4821,4822,4823,4824,4825} --tiles.
function onStepIn(cid, item, frompos, itemEx, topos, fromPosition)
local s,v = 18528,getThingPos(cid)
local p = getThingPos(cid)
p.stackpos = 0
	if isInArray(allowed,getThingFromPos(p).itemid) then
		if getPlayerStorageValue(cid,s) < os.time then
		local tmp = getCreatureOutfit(cid)
		tmp.lookType = 125 -- change to outfit to change into when done.
			doCreatureChangeOutfit(cid,tmp)
			doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_RED,'['..os.time..'] You changed back into a human being.')
		else
			if getCreatureCondition(cid,speed) then
				if getPlayerStorageValue(cid,s) < os.time then
					return true
				else
					doRemoveCondition(cid,speed)
					doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_RED,'You lost you\'re speed bonus.')
				end
			else
				doAddCondition(cid,speed)
				doSendMagicEffect(v,CONST_ME_POFF)
			end
		end
		return true
	else
	local tmp = getCreatureOutfit(cid)
	tmp.lookType = 125 -- change to outfit to change into when done.
		doCreatureChangeOutfit(cid,tmp)
		doRemoveCondition(cid,speed)
		doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_RED,'You lost you\'re speed bonus and changed back into a human being.')
	end
	return true
end

Made this Stoned :)
 
Last edited:
I tried both scripts and neither worked. narko the error I got from your's

Code:
[Error - Action Interface]
data/actions/scripts/custom/swim.lua:onUse
Description:
attempt to index a number value
stack traceback:
         [C]: in function 'doSetCreatureOutfit'
         data/actions/scripts/custom/swim.lua:4: in functions <data/actions/scripts/custom/swim.lua:3>

and unknown666 I got a error in game saying "You can't use this for -1 seconds!"
 
Not working, I think its cause
Code:
if getCreatureOutfit(cid).lookType ~= 275 then
is expecting the player to be a sea serpent already, but it should be turning them to that lookType instead. If I change
Code:
if getCreatureOutfit(cid).lookType ~= 275 then
to
Code:
if getCreatureOutfit(cid).lookType ~= 267 then
which is the tibia looktype for a player swimming, then it says the "Cannot do this for -1 seconds." but if I add it all and dont change anything, I get the error

Code:
data/actions/scripts/custom/swim.lua:4: attempt to compare number with function stack traceback:
           data/actions/scripts/custom/swim.lua:4: in function <data/actions/scripts/custom/swim.lua:1>

and the movement error i get when I walk on the water ID is

Code:
data/movements/scripts/swim.lua:11: attempt to compare number with function stack traceback:
          data/movements/scripts/swim.lua:11: in function <data/movements/scripts/swim.lua:6>
 
Lua:
if getCreatureOutfit(cid).lookType ~= 275 then

That means that the creatureOufit.looktype is not equal to (~=) 275.

I just never made an os.time related storagevalue check in a script, so that's the part that must not work.
 
Back
Top