• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Set Player Storage Value

trollebror

Developer
Joined
Aug 8, 2009
Messages
362
Reaction score
57
Location
Sweden, Linköping
I could not find a similar script so I made one myself.

What it does: Sets a players storage value.
Use example: !storage "GM Trollebror, 21212, -1

set_storage.lua
Code:
function onSay(cid, words, param)
	local parameters = string.explode(param, ",")
	local player = getPlayerByName(parameters[1])
	local storage = tonumber(parameters[2])
	local storageValue = tonumber(parameters[3])
	
	if player and storage and storageValue and getPlayerAccess(cid) > 0 then
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_BUBBLES)
		setPlayerStorageValue(player, storage, storageValue)
	else
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
	end
end

Inside talkactions.xml (TFS 0.2.14~)
Code:
<talkaction words="!storage" script="set_storage.lua"/>
 
already exist in 0.3.7:
Lua:
function onSay(cid, words, param)
	local t = string.explode(param, ",")
	if(not t[2]) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.")
		return true
	end

	local tid = getPlayerByNameWildcard(t[1])
	if(not tid or (isPlayerGhost(tid) and getPlayerGhostAccess(tid) > getPlayerGhostAccess(cid))) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " not found.")
		return true
	end

	if(not t[3]) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, " [" .. t[1] .. " - " .. t[2] .. "] = " .. getPlayerStorageValue(tid, t[2]))
	else
		setPlayerStorageValue(tid, t[2], t[3])
	end

	return true
end

I made one for global storage:
Lua:
function onSay(cid, words, param)
	local t = string.explode(param, ",")
	if(not t[1]) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Reads or sets globalstorage, example: /gstorage 10000, 5.")
	end
	
	if(not t[2]) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, " [" .. t[1] .. "] = " .. getGlobalStorageValue(t[1]))
	else
		if setGlobalStorageValue(t[1], t[2]) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, " [" .. t[1] .. "] value has been set to " .. getGlobalStorageValue(t[1]))
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Incorrect params.")
		end
		return true
	end
	return true
end
 
thanks man for posting script for tfs 0.2.5 it works perfect on 0.2.5 tibia client 9.86
 
And the script I posted is for 0.2.14~ so it's still useful for some of us. :)

It wasn't that hard to rewrite it :)

/storage as on 0.3.7 rewritten to 0.2 (tested):
Lua:
function onSay(cid, words, param)
if getPlayerAccess(cid) > 0 then
	local t = string.explode(param, ",")
	if(not t[2]) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Usage: " .. words .. " \"Player Name, storage, number to set")
		return true
	end

	local tid = getPlayerByName(t[1])
	if(not tid or (isPlayerGhost(tid) and getPlayerGhostAccess(tid) > getPlayerGhostAccess(cid))) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " not found.")
		return true
	end

	if(not t[3]) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, " [" .. t[1] .. " - " .. t[2] .. "] = " .. getPlayerStorageValue(tid, t[2]))
	else
		setPlayerStorageValue(tid, t[2], t[3])
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Storage: "..t[2]..", "..t[3].." assigned for " ..t[1]..".")
	end
end
	return true
end
 
Back
Top Bottom