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

Storage with certain time {Help}

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,857
Reaction score
96
Location
Brazil
Hello,
I need this 'function' to add in a NPC in a War OT.

The player receive a storage, and this storage expires after 3 minutes(time configurable please)

I know it's possible but I don't know how to do that. If someone can help me, please do that.
 
LUA:
function doPlayerSetStorageByTime(cid, storage, value, seconds)
	local function removeStorageIfIsOnline(cid, storage)
		if isPlayer(cid) then
			setPlayerStorageValue(cid, storage, -1)
			return true
		end
		return false
	end
	setPlayerStorageValue(cid, storage, value)
	addEvent(removeStorageIfIsOnline, seconds * 1000, cid, storage)
	return true
end

Try with this.
Note: If the player is offline the function will return error and the storage wont be changed.
 
No, because you do not use any function on CallBack parameter, and yes, exists a way that you can use this script within the part of off line player, I think is within using MySQL programming, but I do not know so much.
 
No, because you do not use any function on CallBack parameter, and yes, exists a way that you can use this script within the part of off line player, I think is within using MySQL programming, but I do not know so much.

I'm adding the storage like this:
LUA:
setPlayerStorageValue(cid,storage,1)
I just need an event to remove this storage after 3 minutes
 
LUA:
function doPlayerSetStorageByTime(cid, storage, value, seconds)
	if isPlayer(cid) then
		local guid = getPlayerGUID(cid)
	
		setPlayerStorageValue(cid, storage, value)		
		addEvent(db.executeQuery, seconds * 1000, "UPDATE `player_storage` SET `key` = " .. storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
	end
	return true
end
 
LUA:
function doPlayerSetStorageByTime(cid, storage, value, seconds)
	if isPlayer(cid) then
		local guid = getPlayerGUID(cid)
	
		setPlayerStorageValue(cid, storage, value)		
		addEvent(db.executeQuery, seconds * 1000, "UPDATE `player_storage` SET `key` = " .. storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
	end
	return true
end

How can I add this code here?
LUA:
function magicl(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
        if getPlayerMoney(cid) >= 5000 and (isDruid(cid) or isSorcerer(cid)) then
 
            doPlayerRemoveMoney(cid,5000)
            local conditionMagic = createConditionObject(CONDITION_ATTRIBUTES)
	    setConditionParam(condition, CONDITION_PARAM_BUFF, TRUE)
            setConditionParam(conditionMagic, CONDITION_PARAM_TICKS, skillsseconds*1000)
            setConditionParam(conditionMagic, CONDITION_PARAM_STAT_MAGICPOINTS, skillsupgrade['ml'])
            selfSay('Your magic level has increased for ".. skillsseconds .."!', cid)
            setPlayerStorageValue(cid, 77777, value)
 
        else
            selfSay('You don\'t have such money.', cid)
    end
end

The storage 77777 must be removed in 3 minutes
 
I don't think so that this script will work.

LUA:
function magicl(cid, message, keywords, parameters, node)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
	local storage, value = 77777, 1
	
	if getPlayerMoney(cid) >= 5000 and (isDruid(cid) or isSorcerer(cid)) then
		doPlayerRemoveMoney(cid, 5000)
		
		local conditionMagic = createConditionObject(CONDITION_ATTRIBUTES)
		setConditionParam(condition, CONDITION_PARAM_BUFF, TRUE)
		setConditionParam(conditionMagic, CONDITION_PARAM_TICKS, skillsseconds*1000)
		setConditionParam(conditionMagic, CONDITION_PARAM_STAT_MAGICPOINTS, skillsupgrade['ml'])
		
		selfSay('Your magic level has increased for ".. skillsseconds .."!', cid)

		local guid = getPlayerGUID(cid)			
		setPlayerStorageValue(cid, storage, value)		
		addEvent(db.executeQuery, skillsseconds * 1000, "UPDATE `player_storage` SET `key` = " .. storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
	else
		selfSay('You don\'t have such money.', cid)
	end
end
 
I think it will not work S:
Is possible something like this?
LUA:
storage = setPlayerStorageValue(cid, storage, -1)
addEvent(seconds*1000, cid, storage)
 
LUA:
local config = {
	storage = 77777,
	value = 1,
	money = 5000
}

function magicl(cid, message, keywords, parameters, node)
	local guid = getPlayerGUID(cid)

	if not npcHandler:isFocused(cid) then
		return false
	end
	
	if isDruid(cid) or isSorcerer(cid) then
		if getPlayerMoney(cid) >= config.money then
			doPlayerRemoveMoney(cid, config.money)
	 
			local conditionMagic = createConditionObject(CONDITION_ATTRIBUTES)
			setConditionParam(conditionMagic, CONDITION_PARAM_BUFF, TRUE)
			setConditionParam(conditionMagic, CONDITION_PARAM_TICKS, skillsseconds * 1000)
			setConditionParam(conditionMagic, CONDITION_PARAM_STAT_MAGICLEVEL, skillsupgrade['ml'])
			doAddCondition(cid, conditionMagic)
	 
			selfSay('Your magic level has increased for ' .. skillsseconds .. '!', cid)

			setPlayerStorageValue(cid, config.storage, config.value)		
			addEvent(db.executeQuery, skillsseconds * 1000, "UPDATE `player_storage` SET `key` = " .. config.storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
		else
			selfSay('You don\'t have such money.', cid)
		end
	else
		selfSay('You must be a druid or sorcerer', cid)
	end
end
 
Back
Top