• 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] storage value help

Darkshadows

Lua Scripter
Joined
Sep 15, 2007
Messages
137
Reaction score
1
I believe I have done it once before, but I don't remember how...

something along the lines of a table inside a storage value

for example...
___________________________________________________________________________
table = {7673, 7670, 7680, 7682, 7684, 7686, 7688, 7690, 7992, 7994}

setPlayerStorageValue(cid, 12345, table)

Then it would look something like this...

testing = getPlayerStorageValue(cid, 12345)

if testing[1] == 7673 then
___________________________________________________________________________
etc.
 
Code:
local storages = {
	7673, 7670, 7680, 7682, 7684, 7686, 7688, 7690, 7992, 7994
	}

for i = 1, table.maxn(storages) do
	setPlayerStorageValue(cid, 12345, i)
end

local testing = getPlayerStorageValue(cid, 12345)

if testing == storages[1] then
	print('oi')
elseif testing == storages[2] then
	print('oi2')
--and so on....
end
???????
 
Not working ;/ i got this to test it...

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

local storages = {
	7673, 7670, 7680, 7682, 7684, 7686, 7688, 7690, 7992, 7994
	}
for i = 1, table.maxn(storages) do
	setPlayerStorageValue(cid, 12345, i)
end

local testing = getPlayerStorageValue(cid, 12345)

if testing == storages[1] then
doPlayerSay(cid,working,1)
end
end

and its not giving any errors...
 
Not working ;/ i got this to test it...

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

local storages = {
	7673, 7670, 7680, 7682, 7684, 7686, 7688, 7690, 7992, 7994
	}
for i = 1, table.maxn(storages) do
	setPlayerStorageValue(cid, 12345, i)
end

local testing = getPlayerStorageValue(cid, 12345)

if testing == storages[1] then
doPlayerSay(cid,working,1)
end
end

and its not giving any errors...

Tell me exactly how do you want this to be working...
Values in table have to be storageid or storagevalue?

Also,
Code:
doPlayerSay(cid,working,1)

working is a string and should be quoted.
 
I need it to assign a table of values to a player where i can retrieve it for a separate script...

fixed the playersay, but still wont work
 
Code:
function onSay(cid, words, param)
	if param == "set" then
		local assignements = {
			[7673] = 1, [7670] = 1, [7680] = 0, [7682] = 1, [7684] = 0,
			[7686] = 1, [7688] = 1, [7690] = 0, [7992] = 0, [7994] = 0
			}
		for storage, value in pairs(assignements) do
			setPlayerStorageValue(cid, storage, value)
		end
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Storages set!")
	elseif param == "check" then
		if getPlayerStorageValue(cid, 7673) == 1 then
			doCreatureSay(cid, "Storage key is 1.", TALKTYPE_SAY)
		end
	end
	return TRUE
end

Like this...?
 
No, its an action. and i need those numbers set to 1 storage value, not multiple :p


Here.. ill tell you the full plan...

I am making "guild buffs" and an npc must set a global storagevalue (for 1 guild...) so say guild 'ownators' bought the buffs of Regen, shielding, meelee, but not distance, and a light value

then the global storage value for the guild must be set to "1, 1, 1, 0, 273(color)"
and the next storage value is the level of buff... "2, 3, 1, 0, 4(intensity of light)"

and since my server doenst have onlogin i will make a switch in town to refresh your buffs when you login or your guild buys more...

im gonna edit this post to not reveal this after i get the code btw...
 
Last edited:
Each storage has its own key...
You can not have 1 storage with few keys.
E.g:
Code:
setPlayerStorageValue(cid, 12345, 1)
setPlayerStorageValue(cid, 12345, 0)
setPlayerStorageValue(cid, 12345, 10)

Would end up with having storage id 12345 with key 10.
 
Global storage value also can have one key only...
Code:
setGlobalStorageValue(12345, 0)
setGlobalStorageValue(12345, -1)
setGlobalStorageValue(12345, 1)

Will end up having key #1.

Be more specific maybe? :S
 
I understand that you overwrite them if you do motiples... but can you not apply a TABLE of values to it?

such as storage[1]-[5] are all applied to 1 storage?

in that case maybe something along the lines of this...

guild_id = getPlayerStorageValue(cid, 112233) --make the guildmaster assign ths depending on which guild...
base_storage = 12345
guild_storage = base_storage + (guild_id * 10)

if getGlobalStorageValue(guild_storage + 0) == 1 then
regen = createConditionObject()
setCombatParam(regen, CONDITION_PARAM_MANAGAIN, CONDITION_PARAM_MANATICKS)

cept im not sure how to assign the regen amounts... to 5 mana every 5 secs or something to that affect


but i can make it less storage values by doing it as levels.. regen level, meelee level, shielding level, distance level, light color, light intensity... so in that code its saying if the first guild storage value is 1 (regen lvl 1) then do that... and i would use elseif = 2 etc. for other lvls of regen and then same for the others... or perhaps 5 manaregain * level and ticks remain the same i dunno...
 
Last edited:
I understand that you overwrite them if you do motiples... but can you not apply a TABLE of values to it?

such as storage[1]-[5] are all applied to 1 storage?

Do you mean like this?

Code:
getGlobalStorageValue(500,1)
getGlobalStorageValue(502,1)
getGlobalStorageValue(503,1)
getGlobalStorageValue(504,1)

or do you mean this?

Code:
getGlobalStorageValue(500,1)
getGlobalStorageValue(500,2)
getGlobalStorageValue(500,3)
getGlobalStorageValue(500,4)

1st would be possible and you could use the function i made therefore.

2nd does not work because the last set value would be remembered.


link for the function: function

kind regards, Evil Hero
 
nm... i got it :)

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

guild_id = getPlayerStorageValue(cid, 112233) --make the guildmaster assign ths depending on which guild...
base_storage = 12345
guild_storage = base_storage + (guild_id * 10)

if getGlobalStorageValue(guild_storage + 0) == 1 then
regen = createConditionObject()
setCombatParam(regen, CONDITION_PARAM_MANAGAIN, (5 * getGlobalStorageValue(guild_storage + 0)))
setCombatParam(regen, CONDITION_PARAM_MANATICKS, 5)
setCombatParam(regen, CONDITION_PARAM_HEALTHGAIN, (5 * getGlobalStorageValue(guild_storage + 0)))
setCombatParam(regen, CONDITION_PARAM_HEALTHTICKS, 5)
end
end

storagevalues cannot hold letters right? so i cant do something along the lines of
setGlobalStorageValue(112233, 'Ownators')

and then i would have an npc make the levels of regen/meelee/dist/shield/light go up...


But... how do i apply the condition to "cid" and how do i apply how long the condition will last?


O, and for the guild_id... how do i make/edit a seperate file? so the guildmaster when he founds a guild would add to a file that
guild_id_1 = 'ownators'
guild_id_2 = 'devastators'
and so on as he creates guilds...
 
Last edited:
doAddCondition(cid, condition)
setConditionParam(condition, CONDITION_PARAM_TICKS, time) -- 1000 = 1 second
 
Ok, thanks for helping with that... 1 more thing though ;/

I got this...

logs = io.open("./data/logs/guilds.txt", "a")
logs:write("testing\n")
logs:close()
but i get an error saying
attempt to index global 'io' <a nil value>

how am i supposed to edit/retrieve info from a file?

dofile("./data/logs/guilds.txt")
but what would i have in the file to return a number based on guild??

something like this?..
HTML:
guilds = {['ownators'] = 1, ['devastators'] = 2}
if getPlayerGuildName(cid) == guilds[1] then
return 1
elseif getPlayerGuildName(cid) == guilds[2] then
return 2
end

? cept in that case i would have to make tons of [#] for new guilds

Edit:nm... got it :) now i just need to edit the file...

HTML:
guilds.log
guilds = {['ownators'] = 1, ['devastators'] = 2}

HTML:
    dofile("./data/logs/guilds.log")
if guilds[getPlayerGuildName(cid)]~= nil then
guild_id = guilds[getPlayerGuildName(cid)]
end
doPlayerSay(cid, guild_id, 1)
 
Last edited:
Back
Top