• 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:
Now i turned to skeleton, but speed is same

Edit: And now i changed back to citizen, only problem is that to my speed was same. It must be 154 that time when i'mskeleton
 
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, (getCreatureBaseSpeed(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
 
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!
 
Just to try out, if you feel any diffrence, ive made the speed +1000!

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, (getCreatureBaseSpeed(cid)) + 1000)
			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
 
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
 
This would be perfect if you can't use hastes when cursed, but if you are busy you don't have to make it :p

- - - Updated - - -

And if you log out while curse is on you, that curse will disappear
 
Go to spells/scripts/support/strong haste.lua and replace with this:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_HASTE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 22000)
setConditionFormula(condition, 0.7, -56, 0.7, -56)
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
	if (getPlayerStorageValue(cid, 3333) == -1) then
		doCombat(cid, combat, var)
	else
		doPlayerSendCancel(cid,"You can't use strong haste, when you are cursed.")
	end
	return true
end

Go to spells/scripts/support/haste.lua and replace with this:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_HASTE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 33000)
setConditionFormula(condition, 0.3, -24, 0.3, -24)
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
	if (getPlayerStorageValue(cid, 3333) == -1) then
		doCombat(cid, combat, var)
	else
		doPlayerSendCancel(cid,"You can't use haste, when you are cursed.")
	end
	return true
end

- - - Updated - - -

About the logout thing, its already doing that, when you login back the curse is removed.
 
Go to creaturescripts/creaturscripts.xml and add this line:
Lua:
<event type="logout" name="Curse" event="script" value="curselogout.lua"/>

Now goto creaturescripts/scripts/ and create new lua and name it {curselogout.lua} and add the code below:
Lua:
function onLogout(cid)
 
	if (getCreatureStorage(cid, 3333) == 1) then
		doPlayerSendCancel(cid,"You can't logout when you are cursed.")
		return false
	end
	return true
end
 
Back
Top