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

Ticket Exp x2

NieWiemJakiNick

New Member
Joined
Jan 7, 2011
Messages
7
Reaction score
0
Please help with a script on exp x2 for 5 h.
So, I have a script but when a player or die Become the script stops working.

Code:
local config = {
	rate = 2.0, -- 4x More Experience
	time = 5, -- Hours of Exp Time
	storage = 20012
}
local function endExpRate(cid)
	if isPlayer(cid) == TRUE then
		doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
		setPlayerStorageValue(cid, config.storage, -1)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your extra experience time has ended.")
	end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerStorageValue(cid, config.storage) < 0) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your extra experience rate is now: " .. config.rate .. ". It will last for ".. config.time .." hours.")
		doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
		setPlayerStorageValue(cid, config.storage, os.time() + config.time * 3600)
		addEvent(endExpRate, config.time * 3600 * 1000, cid)
		doRemoveItem(item.uid, 1)
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have extra experience time left.")
	end
	return TRUE
end

So I will explain further what is wrong. The script adds storage to the player and when the player has the storage he have bonus exp. but when the time is up, storage is removed. By contrast, when a player die or is a character relog storage will have to constantly ... How do I fix this?

Sorry for bad english. I use google translator ;p

Any ideas? ;|
 
Last edited:
Here you go
Code:
function onUse(cid, item, frompos, item2, topos)
 
local c = {
	ExpScroll = 6119, -- Item ID
	ExpStorage = 99997, -- Storage Value
	ExpAmount = 12500000, -- How much experience will be given?
	ExpTimes = 2, -- How many times may a player use this scroll?
	TrueMagicEffect = CONST_ME_MAGIC_RED, -- What magic effect should be made when it work?
	FalseMagicEffect = CONST_ME_POFF, -- What magic effect should be made when it doesn't work?
	LevelLimit = 200 -- Which level are you not allowed to use it?
	}
 
	if item.itemid == c.ExpScroll then
		if getPlayerLevel(cid) <= c.LevelLimit then
			if getPlayerStorageValue(cid, c.ExpStorage) ~= (c.ExpTimes-1) then
				doPlayerAddExperience(cid, c.ExpAmount)
				doSendMagicEffect(frompos, c.TrueMagicEffect)
				doRemoveItem(item.uid, 1)
				setPlayerStorageValue(cid, c.ExpStorage, (getPlayerStorageValue(cid, c.ExpStorage)+1))
			else
				doPlayerSendCancel(cid, "You have already used this scroll " .. c.ExpTimes .. " times!")
				doSendMagicEffect(frompos, c.FalseMagicEffect)
			end
		end
	end
	return TRUE
end
 
Back
Top