• 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] lever add level and items

mesosot

Member
Joined
Aug 16, 2007
Messages
356
Reaction score
5
hello there i want a scripts that when player use the lever
he get "xxx of exp" and " xx yy zz Items "

For example :-
when player use lever he get 8500 exp and p set and wand and shiled and bag ....




NB:- I donno if this right section to ask for something like this ... if not pls move =)
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local cfg = {
	storage = 38897, -- Storage Value
	experience = 8500, -- Amount of experience
	items = {
		{XXXX}, -- Armor
		{XXXX}, -- Legs
		{XXXX}, -- Shield
		{XXXX}, -- Bag
                {XXXX} -- Other
		}
	}
	
local items = cfg.items
		
if getPlayerStorageValue(cid, cfg.storage) == -1 then
	if item.itemid == 1945 then
		for _, v in ipairs(items) do
			setPlayerStorageValue(cid, cfg.storage, 1)
			doTransformItem(item.uid, 1946)
			doPlayerAddItem(cid, v[1], v[2] or 1)
	elseif item.itemid == 1946 then
		doTransformItem(item.uid, 1945)
	end
else
	return doPlayerSendDefaulfCancel(cid, RETURNVALUE_NOTPOSSIBLE)
end
return TRUE
end


Not tested, I'm not sure whether it works. It's late ... I can't test it now.
 
error
[13/08/2010 13:34:29] data/actions/scripts/Fitems.lua:3: unexpected symbol near '='
[13/08/2010 13:34:29] [Error - LuaScriptInterface::loadFile] data/actions/scripts/Fitems.lua:9: '}' expected (to close '{' at line 1) near '{'
[13/08/2010 13:34:29] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/Fitems.lua)
[13/08/2010 13:34:29] data/actions/scripts/Fitems.lua:9: '}' expected (to close '{' at line 1) near '{'
 
Lua:
local cfg = {
	storage = 38897, -- Storage Value
	experience = 8500, -- Amount of experience
	}
	local items = {
		{XXXX}, -- Armor
		{XXXX}, -- Legs
		{XXXX}, -- Shield
		{XXXX}, -- Bag
        {XXXX} -- Other
		}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, cfg.storage) == -1 then
    for i = 1, #items
			setPlayerStorageValue(cid, cfg.storage, 1)
	        doPlayerAddItem(cid, items[i], 1)
			doPlayerAddExperience(cid, cfg.experience)
	end
else
  doPlayerSendDefaulfCancel(cid, RETURNVALUE_NOTPOSSIBLE)
end

return item.itemid == 1945 and doTransformItem(item.uid,1946) or doTransformItem(item.uid,1945)
end
 
testing and i add answer ^^

[13/08/2010 15:31:47] data/actions/scripts/Fitems.lua:15: 'do' expected near 'setPlayerStorageValue'
[13/08/2010 15:31:47] [Error - LuaScriptInterface::loadFile] data/actions/scripts/Fitems.lua:15: 'do' expected near 'setPlayerStorageValue'
[13/08/2010 15:31:47] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/Fitems.lua)
[13/08/2010 15:31:48] data/actions/scripts/Fitems.lua:15: 'do' expected near 'setPlayerStorageValue'

error !

may i installing it wrong ,,, or there something missing add how to install it ;s
 
Last edited:
do was missing
Lua:
local cfg = {
	storage = 38897, -- Storage Value
	experience = 8500, -- Amount of experience
	}
	local items = {
		{XXXX}, -- Armor
		{XXXX}, -- Legs
		{XXXX}, -- Shield
		{XXXX}, -- Bag
        {XXXX} -- Other
		}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, cfg.storage) == -1 then
    for i = 1, #items do
			setPlayerStorageValue(cid, cfg.storage, 1)
	        doPlayerAddItem(cid, items[i], 1)
			doPlayerAddExperience(cid, cfg.experience)
	end
else
  doPlayerSendDefaulfCancel(cid, RETURNVALUE_NOTPOSSIBLE)
end
 
return item.itemid == 1945 and doTransformItem(item.uid,1946) or doTransformItem(item.uid,1945)
end
 
look just add this in action
Code:
<action actionid="2499" event="script" value="Fitems.lua"/>
annd add the action id 2499 to the lever.
 
i have added leer with UniqueID: [1989].

but when i use in game it only get the exp ... no items

also get this error

[13/08/2010 15:58:04] [Error - Action Interface]
[13/08/2010 15:58:04] data/actions/scripts/Fitems.lua:eek:nUse
[13/08/2010 15:58:04] Description:
[13/08/2010 15:58:04] data/actions/scripts/Fitems.lua:20: attempt to call global 'doPlayerSendDefaulfCancel' (a nil value)
[13/08/2010 15:58:04] stack traceback:
[13/08/2010 15:58:04] data/actions/scripts/Fitems.lua:20: in function <data/actions/scripts/Fitems.lua:12>
 
hmm ye i forgot:
Lua:
local cfg = {
	storage = 38897, -- Storage Value
	experience = 8500, -- Amount of experience
	}
	local items = {2466,2466,2466}   -- add items here
		
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid, cfg.storage) == -1 then
doPlayerAddExperience(cid, cfg.experience)
setPlayerStorageValue(cid, cfg.storage, 1)
    for i = 1, #items do
		doPlayerAddItem(cid, items[i], 1)
	end
else
  doPlayerSendCancel(cid,"Sorry,not possible")
end
 
return item.itemid == 1945 and doTransformItem(item.uid,1946) or doTransformItem(item.uid,1945)
end
 
i have made this..


try this
Code:
local noob_item = {2466,2467}  -- put here id of most items to be won
local semi_item = {2494,2495}  -- put here id of semi won items
local best_item = {2470,2471}   --put id of rare items
function onUse(cid, item, fromPosition, itemEx, toPosition)
   local r = math.random(100)
     local noob = noob_item[math.random(1, #noob_item)]
       local semi = semi_item[math.random(1, #semi_item)]
         local best =  best_item[math.random(1, #best_item)]
              if r >= 1 and r < 51 then
                   doPlayerAddItem(cid,noob,1)
                   doPlayerSendTextMessage(cid,25,"Lottery bird : you have won ["..getItemNameById(noob)..".")
                   doSendMagicEffect(getThingPos(cid),27)
              elseif r >= 51 and r < 85 then
                   doPlayerAddItem(cid,semi,1)
                   doPlayerSendTextMessage(cid,25,"Lottery bird : you have won ["..getItemNameById(semi)..".")
                   doSendMagicEffect(getThingPos(cid),27)
              elseif r >= 85 then
                   doPlayerAddItem(cid,best,1)
	               doSendMagicEffect(getThingPos(cid),27)
	               doPlayerSendTextMessage(cid,25,"Lottery bird : you have won ["..getItemNameById(best)..".")
	               doBroadcastMessage("Lottery bird : Congratulations! "..getCreatureName(cid).." have won a ["..getItemNameById(best).."].")
              end
   return doRemoveItem(item.uid)
end
Add the line in the action.xml
Code:
<action itemid="xxxxx" event="script" value="xxxxx.lua"/>
 
Back
Top