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

Chest Quest gives EXP!

GuHB

Member
Joined
Dec 14, 2009
Messages
630
Reaction score
9
Location
Brazil
Hi, I look in to the forum and try to use search but can't find this script.

Can someone do that for me? Its simple, when player click "use" on the Chest, he receive "X" experience, and take the MSG "You recevei X experience".

Thanks.
 
Lua:
 function onUse(cid, item, frompos, item2, topos)

local config = {
        storage = 5316, -- change to your own storage value
        amount = 1000, -- change to amount 
		

}

        if getPlayerStorageValue(cid, config.storage) == -1 then
                setPlayerStorageValue(cid, config.storage, 1)
				doPlayerSendTextMessage(cid,25,"You have recieved 1000 experience points.")
                key = doPlayerAddExperience(cid, config.amount)
        else
                doPlayerSendTextMessage(cid,25,"You have already recieved your experience.")
                end
        return TRUE
end

I really have no idea if this will work, never made a script before LOL. Just tried to piece it together from another script and an LUA tutorial. Worth a shot though, right? :D
 
I just made this because i was bored, but its what you wanted... with more features


Lua:
function onUse(cid, item, frompos, item2, topos)

local t = {
		exp = 'single',		-- single/random - single amount (eg 1000 experience) random amount (between x and x experience)
		stor = 1337 -- Storage to store quest
		}
	
local r = { -- if using random setup this
	min = 1000,
	max = 2000,
	rdm = math.random(min, max)
	}
	
local s = { -- if using single amount setup this
	exp = 1000 
	}

if getPlayerStorageValue(cid, t.stor) == -1 then
	if #t.exp == 'single' then
		doPlayerAddExperience(cid, s.exp)
			doPlayerSendTextMessage(cid, "You have gained ".. s.exp .." experience!")
				setPlayerStorageValue(cid, t.stor)
	elseif #t.exp == 'random' then
		doPlayerAddExperience(cid, r.rdm)
			doPlayerSendTextMessage(cid, "You have gained ".. r.rdm .." experience!")
				setPlayerStorageValue(cid, t.stor)
	else
		doPlayerSendCancel(cid, "You have already used this chest.")
		end
		return true
	end
end
 
Would my script of worked? Haven't tested it but if it wouldn't, could someone explain why? :p

It would work fine, I don't understand this part though
Lua:
 key = doPlayerAddExperience(cid, config.amount)
the key = doesnt make sense, should just be:
Lua:
 doPlayerAddExperience(cid, config.amount)

Also, tab them scripts!

And you can also add variables into the text..
Lua:
function onUse(cid, item, frompos, item2, topos)
 
local config = {
        storage = 5316, -- change to your own storage value
        amount = 1000, -- change to amount 
}
 
        if getPlayerStorageValue(cid, config.storage) == -1 then
                setPlayerStorageValue(cid, config.storage, 1)
		        doPlayerSendTextMessage(cid,25,"You have recieved " .. config.amount .. " experience points.")
                                doPlayerAddExperience(cid, config.amount)
        else
                doPlayerSendTextMessage(cid,25,"You have already recieved your experience.")
        end
return TRUE
end
 
Well its a very simple all scripts from other guys won't work cuz new version tfs 0.2 can work with itemEx.. not with item2...


First add string to actions.xml to initialize script:
<action actionid="5555" script="testscript.lua"/>
Here is your script:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local config = {
actionID = 5555,
expToPlayer = 10000,
}
if (item.actionid == config.actionID) then
doCreatureSay(cid, "Added " .. config.expToPlayer .. " experience.", TALKTYPE_MONSTER)
doPlayerAddExp(cid, config.expToPlayer)
else
return FALSE
end
return TRUE
end


:rolleyes: :rolleyes:
 
Well its a very simple all scripts from other guys won't work cuz new version tfs 0.2 can work with itemEx.. not with item2...


First add string to actions.xml to initialize script:

Here is your script:



:rolleyes: :rolleyes:

I test it but have a Debug :S

Here's the debug.

2vd43l5.png
 
Back
Top