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

[SOLVED] What's wrong with this script?

Haju Torttu

Half-Life 3 Confirmed
Joined
Nov 27, 2011
Messages
54
Reaction score
0
Location
Finland
I tried make script what changes players outfit to skeleton and players speed to 154 for 1 hour, but it crashes client when I use that lever. Can someone who's better in scripting than me fix that script?
actions.xml
PHP:
	<action actionid="6669" event="script" value="skeletonchanger.lua"/>
skeletonchanger.lua
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
        if item.itemid == 1945 then
	        	doPlayerSendTextMessage(cid,251,"We have warned you to enter this room. and now we cursed you !")
	            doSetCreatureOutfit(cid,33, 36000)
				doChangeSpeed(cid,154, 36000)
				doTransformItem(item.uid, item.itemid + 1)
		elseif item.itemid == 1946 then
	        	doPlayerSendTextMessage(cid,251,"Seems this switch is only one-way !")
				doTransformItem(item.uid, item.itemid - 1)
        end
		return TRUE
end


-----SOLVED-----
Well, it seems that the storage didnt get deleted.

go to creaturescripts/scripts/login.lua and under function onLogin(cid) add:
Lua:
	if getPlayerStorageValue(cid,3333) == 1 then
		setPlayerStorageValue(cid,3333,-1)
	end

Restart the server!

Try:

Lua:
local Printer = {
	time = 60, --60 = 1min!
	storage = 3333, --add a unused storage
	outfit_name = "Skeleton",
        speed = 154
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	function Back(cid)
		if isPlayer(cid) then
			doChangeSpeed(cid, getCreatureBaseSpeed(cid))
			doPlayerSendTextMessage(cid,25,"The curse is gone.")
			doSendMagicEffect(getThingPos(cid),CONST_ME_HOLYAREA)
                        setPlayerStorageValue(cid,Printer.storage, -1)
		end
		return true
	end
 
        if item.itemid == 1945 then
		if getPlayerStorageValue(cid,Printer.storage) == -1 then
                        doPlayerSendTextMessage(cid,25,"We have warned you to enter this room. and now we cursed you !")
                        doSetMonsterOutfit(cid, Printer.outfit_name, Printer.time*1000)
                        addEvent(Back, Printer.time*1000, cid)
                        doChangeSpeed(cid, Printer.speed - getCreatureSpeed(cid))
			setPlayerStorageValue(cid,Printer.storage, 1)
                        doTransformItem(item.uid, item.itemid + 1)
		else
			doPlayerSendTextMessage(cid,25,"You are cursed!")
		end
        elseif item.itemid == 1946 then
                doPlayerSendTextMessage(cid,25,"Seems this switch is only one-way !")
                doTransformItem(item.uid, item.itemid - 1)
        end
        return TRUE
end
 
Last edited:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
        if item.itemid == 1945 then
                doPlayerSendTextMessage(cid,251,"We have warned you to enter this room. and now we cursed you !")
                doSetCreatureOutfit(cid,33, 36000)
                doChangeSpeed(cid,154, 36000)
                doTransformItem(item.uid, item.itemid + 1)
        elseif item.itemid == 1946 then
                doPlayerSendTextMessage(cid,251,"Seems this switch is only one-way !")
                doTransformItem(item.uid, item.itemid - 1)
        end
       end
        return TRUE
end

One more end sine you use elseif
 
I guess the problem is with doChangeSpeed.
Lua:
doChangeSpeed(cid, delta) -- There is no "time" parameter
 
In my functions examples got :D
Lua:
	doChangeSpeed(cid, delta, time)

But how then I make it like that speed goes normal after 1 hour?
 
Last edited:
I think you can use addEvent in that case :p
Lua:
addEvent(doChangeSpeed, 36000, cid, 154)
 
Thanks Ninja, but now arrived console error
Code:
[14/04/2013 17:50:46] [Error - LuaScriptInterface::loadFile] data/actions/scripts/skeletonchanger.lua:13: '<eof>' expected near 'end'
[14/04/2013 17:50:46] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/skeletonchanger.lua)
[14/04/2013 17:50:46] data/actions/scripts/skeletonchanger.lua:13: '<eof>' expected near 'end'
[14/04/2013 17:50:46] Reloaded actions.
 
I removed it and then new console error arrived
Code:
4/2013 18:06:50] [Error - Action Interface] 
[14/04/2013 18:06:50] data/actions/scripts/skeletonchanger.lua:onUse
[14/04/2013 18:06:50] Description: 
[14/04/2013 18:06:50] attempt to index a number value
[14/04/2013 18:06:50] stack traceback:
[14/04/2013 18:06:50] 	[C]: in function 'doSetCreatureOutfit'
[14/04/2013 18:06:50] 	data/actions/scripts/skeletonchanger.lua:4: in function <data/actions/scripts/skeletonchanger.lua:1>
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

function timer(cid)
    doSetCreatureOutfit(cid, 36) -- Citizen
    doChangeSpeed(cid, 100) -- Normal speed
    doSendMagicEffect(cid, CONST_ME_POFF)
end
        if item.itemid == 1945 then
				doSendAnimatedText(cid, "We have warned you to enter this room. and now we cursed you !", TALKTYPE_ORANGE_1)
                doSetCreatureOutfit(cid, 33)
                doChangeSpeed(cid, 15 )
                doTransformItem(item.uid, item.itemid + 1)
                addEvent(timer, 360 * 1000)
        elseif item.itemid == 1946 then
                doTransformItem(item.uid, item.itemid - 1)
        end
       end
        return TRUE
end

Im not sure about the ends, but I guess Cornex is right
 
Last edited:
That didn't work and only two ends. Console errors again when i used Cloows script
Code:
[14/04/2013 18:21:40] [Error - Action Interface] 
[14/04/2013 18:21:40] data/actions/scripts/skeletonchanger.lua:onUse
[14/04/2013 18:21:40] Description: 
[14/04/2013 18:21:40] attempt to index a number value
[14/04/2013 18:21:40] stack traceback:
[14/04/2013 18:21:40] 	[C]: in function 'doSendAnimatedText'
[14/04/2013 18:21:40] 	data/actions/scripts/skeletonchanger.lua:9: in function <data/actions/scripts/skeletonchanger.lua:1>
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local playerPos = getCreaturePosition(cid)
local function timer()
    doSetCreatureOutfit(cid, 36) -- Citizen
    doChangeSpeed(cid, 100) -- Normal speed
    doSendMagicEffect(cid, CONST_ME_POFF)
end
        if item.itemid == 1945 then
				doSendAnimatedText(playerPos, "We have warned you to enter this room. and now we cursed you !", TALKTYPE_ORANGE_1)
                doSetCreatureOutfit(cid, 33)
                doChangeSpeed(cid, 15 )
                doTransformItem(item.uid, item.itemid + 1)
                addEvent(timer, 3600 * 1000) -- seconds
        elseif item.itemid == 1946 then
                doTransformItem(item.uid, item.itemid - 1)
        end
       end
        return TRUE
end

if you use 0.4
change
doSendAnimatedText
to
doCreatureSay

Edit:
Sorry, forgot to make the timer function local and there is no need for cid
Should work now :)
 
Last edited:
Now happens only this when i used Cloows second script (without that edit what Cloows did just) use that link for bigger pic Image - TinyPic - Free Image Hosting, Photo Sharing & Video Hosting (Those 'Annihilation!' words comes from -1. That's full of Annihilators)

Edit:
Same thing with that newest Cloows script. Sends only messege: 'We have w'
 

Attachments

Last edited:
Back
Top