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

What is wrong with this script??? PLEASE HELP ME! {REP++}

Status
Not open for further replies.

ryandometal

Guitarist!
Joined
Dec 18, 2008
Messages
143
Reaction score
0
Location
Brazil
What is wrong with this script? Please HELP me!!!

Lua:
local EXP = 1500000
local MESSAGE = "You earned 1.500.000 experience points for learning black africans."
local CANCEL = "DON'T OPEN THIS BOOK WITHOUT A GOOD EXPERIENCE, LITTLE MORTAL! GET THIS CURSE FOR YOU!"
local LEARNED = "You've already learned everything that was written in this book."
local STORAGE = 26666

function onUse(cid, item, frompos, item2, topos)
if (getPlayerStorageValue(cid, 4322) <= 0) then
doPlayerSendCancel(cid, "Sorry, you can not open this book.")

elseif (getPlayerStorageValue(cid, 4322) >= 2) and (getPlayerStorageValue(cid, STORAGE) <= 0) and getPlayerLevel(cid) >= 80 then
doPlayerAddExp(cid, EXP)
doCreatureSay(cid, MESSAGE, TALKTYPE_ORANGE_1)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MORTAREA)
setPlayerStorageValue(cid, STORAGE, 1)
doRemoveItem(item.uid, 1)

elseif (getPlayerStorageValue(cid, STORAGE) >= 1) then
doCreatureSay(cid, LEARNED, TALKTYPE_ORANGE_1)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA)

elseif getPlayerLevel(cid) < 80 then
local condition = createConditionObject(CONDITION_CURSED)
doCreatureSay(cid, CANCEL, TALKTYPE_ORANGE_1)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MORTAREA)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 10, 3600, -100)
setCombatCondition(combat, condition)

end
return TRUE 
end

PHP:
[22/02/2010 21:00:57] Lua Script Error: [Action Interface] 
[22/02/2010 21:00:57] data/actions/scripts/quests/magician_book.lua:onUse

[22/02/2010 21:00:57] luaSetCombatCondition(). This function can only be used while loading the script.

I want to, if the player is level < 80, he got cursed condition, that hits -100 hp in 30 turns, but I got some errors.
Using TFS 0.2.7.

rep++
 
i think you need to set up the condition above/outside of the onUse function, then apply the condition inside the use function.
 
You need to put the condition before function onUse , also , I think you'll need to define combat , else you might get this error [not sure tho]:

Code:
[23/02/2010 15:35:39] Description: 
[23/02/2010 15:35:39] (luaSetCombatCondition) Combat not found
 
Code:
local EXP = 1500000
local MESSAGE = "You earned 1.500.000 experience points for learning black africans."
local CANCEL = "DON'T OPEN THIS BOOK WITHOUT A GOOD EXPERIENCE, LITTLE MORTAL! GET THIS CURSE FOR YOU!"
local LEARNED = "You've already learned everything that was written in this book."
local STORAGE = 26666

local condition = createConditionObject(CONDITION_CURSED)
setConditionParam(condition, CONDITION_PARAM_DELAYED, TRUE)
addDamageCondition(condition, 10, 3600, -100)

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerStorageValue(cid, 4322) < 1 then
		doPlayerSendCancel(cid, "Sorry, you can not open this book.")
	elseif getPlayerStorageValue(cid, 4322) >= 2 and getPlayerStorageValue(cid, STORAGE) < 1 and getPlayerLevel(cid) >= 80 then
		doPlayerAddExp(cid, EXP)
		doSendAnimatedText(getThingPos(cid), EXP, 215)
		doCreatureSay(cid, MESSAGE, TALKTYPE_ORANGE_1)
		doSendMagicEffect(getThingPos(cid), CONST_ME_MORTAREA)
		setPlayerStorageValue(cid, STORAGE, 1)
		doRemoveItem(item.uid, 1)
	elseif getPlayerStorageValue(cid, STORAGE) >= 1 then
		doCreatureSay(cid, LEARNED, TALKTYPE_ORANGE_1)
		doSendMagicEffect(getThingPos(cid), CONST_ME_HOLYAREA)
	elseif getPlayerLevel(cid) < 80 then
		doCreatureSay(cid, CANCEL, TALKTYPE_ORANGE_1)
		doSendMagicEffect(getThingPos(cid), CONST_ME_MORTAREA)
		doAddCondition(cid, condition)
	end
	return TRUE
end
 
Status
Not open for further replies.
Back
Top