• 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:
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 :)



I tried it and i also changed
change
doSendAnimatedText
to
doCreatureSay
didn't work for me either.
 
ops, doSendAnimatedText only supports up to 8 letters
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local function timer()
    doSetCreatureOutfit(cid, 36) -- Citizen
    doChangeSpeed(cid, 100) -- Normal speed
    doSendMagicEffect(cid, CONST_ME_POFF)
end
        if item.itemid == 1945 then
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "We have warned you to enter this room. and now we cursed you !")
                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
 
ops, doSendAnimatedText only supports up to 8 letters
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local function timer()
    doSetCreatureOutfit(cid, 36) -- Citizen
    doChangeSpeed(cid, 100) -- Normal speed
    doSendMagicEffect(cid, CONST_ME_POFF)
end
        if item.itemid == 1945 then
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "We have warned you to enter this room. and now we cursed you !")
                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


Still dosent work
 
are you not getting the outfit?

edit:
sorry there is a need for cid

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local function timer(cid)
    doSetCreatureOutfit(cid, 36) -- Citizen
    doChangeSpeed(cid, 100) -- Normal speed
    doSendMagicEffect(cid, CONST_ME_POFF)
end
        if item.itemid == 1945 then
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "We have warned you to enter this room. and now we cursed you !")
                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
 
Last edited:
Try THis:
Lua:
local Printer = {
	time = 60, --60 = 1min!
	storage = 3333, --add a unused storage
	outfit_name = "Skeleton"
}

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, 100)
			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,251,"Seems this switch is only one-way !")
                doTransformItem(item.uid, item.itemid - 1)
        end
        return TRUE
end
 
Last edited:
Try and see if you get a print on console!
Lua:
local Printer = {
	time = 60, --60 = 1min!
	storage = 3333, --add a unused storage
	outfit_name = "Skeleton"
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
        print("Well, the lever works, but the script doesn't! Report this message to the Printer")
	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, 100)
			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,251,"Seems this switch is only one-way !")
                doTransformItem(item.uid, item.itemid - 1)
        end
        return TRUE
end
 
I used that and got error:
Code:
14/04/2013 19:43:59] [Error - LuaScriptInterface::loadFile] data/actions/scripts/skeletonchanger.lua:13: ')' expected near 'EA'
[14/04/2013 19:43:59] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/skeletonchanger.lua)
[14/04/2013 19:43:59] data/actions/scripts/skeletonchanger.lua:13: ')' expected near 'EA'
[14/04/2013 19:43:59] Reloaded actions.

- - - Updated - - -

And now i used that edited one and on screen popups message: 19:45 You are cursed!
Nothing else happens
 
now console error on Printers script:
Code:
[14/04/2013 19:47:11] Well, the lever works, but the script doesn't! Report this message to the Printer
 
My fault, now it should work :)
Lua:
local Printer = {
	time = 60, --60 = 1min!
	storage = 3333, --add a unused storage
	outfit_name = "Skeleton"
}
 
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, 100)
			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
 
Back
Top