Global Linkshell
Global Linkshell
So I just finished setting up my server, I am updating FFXI right now.
How hard is it/would it be, to create a global linkshell, that is auto-given to ANY new account/charactor? I really only intend to have a few friends on my server so its not going to be anything crazy, but I just thought it'd be neat.
How hard is it/would it be, to create a global linkshell, that is auto-given to ANY new account/charactor? I really only intend to have a few friends on my server so its not going to be anything crazy, but I just thought it'd be neat.
Re: Global Linkshell
It'd probably be best to do with a SQL trigger since you have to copy the "signature" which defines the linkshell name for the item. To start you off, I can say you can look at the char_insert trigger that is already there. That is called when someone creates a new character. Simply add an "INSERT INTO char_inventory ..blah..blah" line as appropriate.
-- Whasf
Re: Global Linkshell
I am agreement with this with some of the servers being more personal to home and not as large as some of the others would like to be able to do this as well.
When i checked the triggers in SQL this is what i found; is there anyone here who knows how to finish this so can complete when a new account is created the linkshell is automatically in their inventory.
When i checked the triggers in SQL this is what i found; is there anyone here who knows how to finish this so can complete when a new account is created the linkshell is automatically in their inventory.
Code: Select all
CREATE TRIGGER char_insert
BEFORE INSERT ON chars
FOR EACH ROW
BEGIN
INSERT INTO `char_equip` SET `charid` = NEW.charid;
INSERT INTO `char_exp` SET `charid` = NEW.charid;
INSERT INTO `char_jobs` SET `charid` = NEW.charid;
INSERT INTO `char_points` SET `charid` = NEW.charid;
INSERT INTO `char_profile` SET `charid` = NEW.charid;
INSERT INTO `char_storage` SET `charid` = NEW.charid;
INSERT INTO `char_inventory` SET `charid` = NEW.charid;
END $$
-
- Developer
- Posts: 539
- Joined: Sun Jul 22, 2012 12:17 am
Re: Global Linkshell
Lemme make a linkshell...
Eh, clearly I screwed up somewhere. I got this far, but it doesn't actually work:
Eh, clearly I screwed up somewhere. I got this far, but it doesn't actually work:
Code: Select all
INSERT INTO `char_inventory` (charid, slot, itemid, quantity, signature) VALUES (NEW.charid, 1, 515, 1, "¹ûn´L3");
Test Server: Hanekawa | Fantasy World: Naito
An occasionally updated list of what works
Bugs reports go here. | Project chat here.
Things I've found, but don't plan to work on.
An occasionally updated list of what works
Bugs reports go here. | Project chat here.
Things I've found, but don't plan to work on.
Re: Global Linkshell
Old post, but Has anyone been successful with this from triggers.sql?
Re: Global Linkshell
i think the current solution people use is to give one in the character creation script
Re: Global Linkshell
See : viewtopic.php?f=20&t=2256
in luabaseenity.cpp
in luabaseenitity.h
In player.lua char create section or a GM command or wherever
Note: doesn't check if inventory was full, you'd need to do that in lua or adjust further, not a problem if only used in player.lua to give pearl to new players since they'll always have room.
in luabaseenity.cpp
Code: Select all
inline int32 CLuaBaseEntity::addLSpearl(lua_State* L)
{
DSP_DEBUG_BREAK_IF(m_PBaseEntity->objtype == TYPE_NPC);
std::string linkshellName = lua_tostring(L, 1);
const char* Query = "SELECT name FROM linkshells WHERE name='%s'";
int32 ret = Sql_Query(SqlHandle, Query, linkshellName);
if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0 && Sql_NextRow(SqlHandle) == SQL_SUCCESS)
{
CCharEntity* PChar = (CCharEntity*)m_PBaseEntity;
std::string qStr = ("UPDATE char_inventory SET signature='");
qStr += linkshellName;
qStr += "' WHERE charid = " + std::to_string(PChar->id);
qStr += " AND itemId = 515 AND signature = ''";
Sql_Query(SqlHandle, qStr.c_str());
Query = "SELECT linkshellid,color FROM linkshells WHERE name='%s'";
ret = Sql_Query(SqlHandle, Query, linkshellName);
if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0 && Sql_NextRow(SqlHandle) == SQL_SUCCESS)
{
CItem* PItem = itemutils::GetItem(515);
// Update item with name & color //
int8 EncodedString[16];
EncodeStringLinkshell((int8*)linkshellName, EncodedString);
PItem->setSignature(EncodedString);
((CItemLinkshell*)PItem)->SetLSID(Sql_GetUIntData(SqlHandle, 0));
((CItemLinkshell*)PItem)->SetLSColor(Sql_GetIntData(SqlHandle, 1));
uint8 invSlotID = charutils::AddItem(PChar, LOC_INVENTORY, PItem, 1);
lua_pushboolean(L, true);
return 1;
}
}
lua_pushboolean(L, false);
return 1;
}
Code: Select all
int32 addLS(lua_State* L); // Adds LS to player
Code: Select all
player:addLSpearl("linkshell name")
Note: doesn't check if inventory was full, you'd need to do that in lua or adjust further, not a problem if only used in player.lua to give pearl to new players since they'll always have room.
Code: Select all
if (player:getFreeSlotsCount() > 0) then
if (player:addLSpearl("linkshell name")) then
player:PrintToPlayer("LinkPearl given, don't forget to equip it. ");
else
player:PrintToPlayer("An error occurred. Does the LS exist? ");
end
else
player:PrintToPlayer("Item could not be given: free up some inventory space and try again. ");
end
Last edited by TeoTwawki on Wed Feb 21, 2018 11:36 pm, edited 3 times in total.
Hi, I run The Demiurge server.
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - Martin Golding
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - Martin Golding
DO NOT PRIVATE MESSAGE ME ABOUT BUGSPLS USE [ code ] CODE TAGS [ /code ] WHEN POSTING CODE
Re: Global Linkshell
Awesome, appreciate the help! Thanks