• 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 PlayerStorage functions getplayerstorage and setplayer storage

izaak

New Member
Joined
Feb 1, 2009
Messages
161
Reaction score
3
hi iam wondering if any can give me the function getPlayerStorage and SetPlayerStorage

the function with the sql query
so i can understand the reason why it can read from the databse and write the Key and the value at the same time

because i cant find it in my doc, or in any of my server folders.

so i hope anyone dous have them because i really need them for a project that im working on i wil ofcourse reward you with reputation :D
 
im trying to create a costom storage value but it keeps returning false or nil
so in order to be able to make it work then i have to understand how it works and i can undeerstand it if i get the functions
 
this is how they work i mean how the commands are able to send there values to the database
in the database = player_storage table with column - key , value , Player_id
thats what i mean im sorry for not explaining it better but what i want to know is
how do they send the storage values to the columns?
 
Last edited:
i mean in the table in youre database is a table call player_storage and inside that player_storage table are all the playerstorages that you give youre player when he opens a quest box , or when he comples a quest

what i need to know is how dous the command getplayerstorage reads this storage , and how dous setplayerstore write the value to the table
 
i know but it also writes inside the database , open youre server database and goto player_storage
then u see all youre player id's , there storage value , and amound
storage , player id 1 , storage 3000 , amount 1
thats how it remembers that u already done a quest or not
but in tfs they have included into the server engine itself so im asking for the clean sql query
in the talkaction its showing you how to use the command and how it works for a talk action
not how the storage is send to the sql database and how the information is taken from the database.
i want to be able to understand how i can make my own storage value for my project
and im trying every sql tutorial i can find but all the aql qery's end up giving me a sql syntax error
so thats why iam requesting the query's of these 2 functions i was reading the link u gave me but it didnt show me what i want to know, but thank you for the link though i know ur trying to help me and i apreciate it i jsut really need the sql querys for these 2 storages
 
because i need to keep my costom storage value up to date inside of the database to be able to get my project to work
 
[cpp]
int32_t LuaScriptInterface::luaGetCreatureStorage(lua_State* L)
{
//getCreatureStorage(cid, key)
uint32_t key = popNumber(L);
ScriptEnviroment* env = getEnv();
if(Creature* creature = env->getCreatureByUID(popNumber(L)))
{
std::string strValue;
if(creature->getStorage(key, strValue))
{
int32_t intValue = atoi(strValue.c_str());
if(intValue || strValue == "0")
lua_pushnumber(L, intValue);
else
lua_pushstring(L, strValue.c_str());
}
else
lua_pushnumber(L, -1);
}
else
{
errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
lua_pushboolean(L, false);
}

return 1;
}

int32_t LuaScriptInterface::luaDoCreatureSetStorage(lua_State* L)
{
//doCreatureSetStorage(cid, key[, value])
std::string value;
bool nil = true;
if(lua_gettop(L) > 2)
{
if(!lua_isnil(L, -1))
{
value = popString(L);
nil = false;
}
else
lua_pop(L, 1);
}

uint32_t key = popNumber(L);
ScriptEnviroment* env = getEnv();
if(Creature* creature = env->getCreatureByUID(popNumber(L)))
{
if(!nil)
nil = creature->setStorage(key, value);
else
creature->eraseStorage(key);

lua_pushboolean(L, nil);
}
else
{
errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
lua_pushboolean(L, false);
}

return 1;
}
[/cpp]

/0.3.6pl1/luascript.cpp
 
this is also not the 1 thats sending the storage value to the database

i need the part where the storaga value is send to the database and taken from the database
the database.query
 
This gets the storage form db :
Lua:
    db.getResult("SELECT `value` FROM `player_storage` WHERE `player_id` = '"..getPlayerGUID(whatever).."' AND `key` = '"..whatever.."'  LIMIT 1;"):getDataInt('value')   -- return the value for

And sure some checks is made to check if this isnt null (not exist) then it return -1.


Same with the send part , if the storage exist in table then the query should be like that:
Lua:
db.executeQuery("UPDATE `player_storage` SET `value` = '"..value.."' WHERE `player_id` = '"..getPlayerGUID(whatever).."' AND `key` = '"..whatever.."' ;")
and it should create the table with playerid and the key if there isnt
 
Back
Top