AshleyMosey 2 Posted April 13, 2020 Im just wanting to save the _side of a player into a database when they join the server on Altis life, so if the join independents opfor or blufor I want to be able to write this data to the side field, if already added the side field into the altis life table so it's ready to go on that end I just dont know how to script it so it save the data needed, any help would be amazing thanks Share this post Link to post Share on other sites
Chewz 23 Posted April 14, 2020 Can you please explain this again, the English used makes very little sense and it's extremely hard to understand what you're trying to achieve. What is your database setup? Do you have 3 separate tables for each side? Or 3 different columns for each side? Share this post Link to post Share on other sites
AshleyMosey 2 Posted April 14, 2020 Ok so im helping a friend with an Altis life server he's using the AsYetUntitled Framework for his missions. This SQL Table with the added field of Side at the bottom looks like this: https://pastebin.com/DGKXdn0N iv got a script ready to detect the side the player is on but I don't know how to write the relevant extDB3 stuff to write it to the DB so for now just post hints 0 Advanced issue found ▲ 0 Advanced issue found ▲ Spoiler initPlayerLocal.sqf addMissionEventHandler ["PreloadFinished", {preloadFinished = true;}]; [] execVM "getside.sqf"; getplayerside.sqf waitUntil {!isNil "preloadFinished"}; switch (side player) do { case west: { hint "You are on the West side"; }; case east: { hint "You are on the East side"; }; case independent: { hint "You are on the Indipendent side"; }; default { hint "You are renegate"; }; }; onPlayerRespawn.sqf waitUntil {!isNil "preloadFinished"}; switch (side player) do { case west: { hint "You are on the West side"; }; case east: { hint "You are on the East side"; }; case independent: { hint "You are on the Indipendent side"; }; default { hint "You are renegate"; }; }; the reason we need this info on the SQL is for a discord bot Share this post Link to post Share on other sites
Chewz 23 Posted April 14, 2020 Hi, So, storing the side on the database doesn't really matter, because this database stores data from all three sides relating to the player (I presume, because you have separate columns for the different player licenses and stats, and apart from the side column at the bottom there's no indication that this is stored otherwise. civ_licenses TEXT NOT NULL, cop_licenses TEXT NOT NULL, med_licenses TEXT NOT NULL, civ_gear TEXT NOT NULL, cop_gear TEXT NOT NULL, med_gear TEXT NOT NULL, civ_stats VARCHAR(25) NOT NULL DEFAULT '"[100,100,0]"', cop_stats VARCHAR(25) NOT NULL DEFAULT '"[100,100,0]"', med_stats VARCHAR(25) NOT NULL DEFAULT '"[100,100,0]"', Just so I can get a full understanding of what you are trying to achieve, what data you are trying to display from the Discord bot? Chewz Share this post Link to post Share on other sites
AshleyMosey 2 Posted April 14, 2020 Those wouldn't work I dont think, I need to get more info from my friend but I think what the bot dose is assign channel permissions/rolls depending on if your opfor, blufor or independent and it would need to be updated when the player backs out and swaps sides as this would not be a full disconnect just a side change so he said the easiest way for him would be to just have the side field be populated with the side the player is on and change it if the player swaps sides Share this post Link to post Share on other sites
GMT-HD 0 Posted April 14, 2020 The only way the bot will know what the player side they are on if the table in the database is updated, just I don;t know how to update the database from the script Share this post Link to post Share on other sites
Chewz 23 Posted April 14, 2020 (edited) Okay, so the side field would be populated with the last side played on. Okay, so go to the life_server and navigate to life_server\functions\mysql\fn_queryRequest.sqf for life_server Inside this file, navigate down to lines 99, 127 and 156. Below all of these lines, add the following code: Life_Server\Functions\MySQL\fn_queryRequest - Line 99 [_uid, _side, "Player is Police", 8] call DB_fnc_updatePartial; Life_Server\Functions\MySQL\fn_queryRequest - Line 127 [_uid, _side, "Player is Civilian", 8] call DB_fnc_updatePartial; Life_Server\Functions\MySQL\fn_queryRequest - Line 156 [_uid, _side, "Player is Medic", 8] call DB_fnc_updatePartial; Next, we need to head to life_server\functions\mysql\fn_updatePartial.sqf, and navigate down to line 81. Insert the following code: Life_Server\Functions\MySQL\fn_updatePartial - Line 81 case 8: { _sideToInsert = (_this select 2); // We don't need to worry about checking this. _Query = format ["UPDATE TABLE `players` SET Side = '%1' WHERE pid='%2'", _sideToInsert, _uid]; }; Now we need to repeat for Headless Client configuration, no navigate to life_hc\mysql\general\fn_queryRequest.sqf Inside this file, go to line 93, 122 and 150. Below all of these lines, add the following code: Life_Server\Functions\MySQL\fn_queryRequest - Line 93 [_uid, _side, "Player is Police", 8] call HC_fnc_updatePartial; Life_Server\Functions\MySQL\fn_queryRequest - Line 122 [_uid, _side, "Player is Civilian", 8] call HC_fnc_updatePartial; Life_Server\Functions\MySQL\fn_queryRequest - Line 150 [_uid, _side, "Player is Medic", 8] call HC_fnc_updatePartial; Next, we need to head to life_hc\mysql\general\fn_updatePartial.sqf, and navigate down to line 83. Insert the following code: Life_Server\Functions\MySQL\fn_updatePartial - Line 83 case 8: { _sideToInsert = (_this select 2); // We don't need to worry about checking this. _Query = format ["UPDATE TABLE `players` SET Side = '%1' WHERE pid='%2'", _sideToInsert, _uid]; }; This should hopefully work, updating the side they join when their stats are loaded, whether you use a headless client or not. Hopefully this covers your requirements? Thanks Chewz Edited April 14, 2020 by Chewz I accidentally overrode the _side variable that is already defined. To Avoid any potential conflict / issues (it shouldn't cause any) I have changed the variable defines from _side to _sideToInsert for the fn_updatePartial files Share this post Link to post Share on other sites
AshleyMosey 2 Posted April 14, 2020 This looks spot on thank you so much only think is can think is can it incert west east and Independent instead of cop med and civil? I'll test out with my friend and get back to you, also will this update if the player changes sides on the fly too Share this post Link to post Share on other sites
Chewz 23 Posted April 14, 2020 18 minutes ago, AshleyMosey said: This looks spot on thank you so much only think is can think is can it incert west east and Independent instead of cop med and civil? I'll test out with my friend and get back to you, also will this update if the player changes sides on the fly too Hi, Yes, you can change the data inserted into the database. If you just want to insert their side as expressed by ArmA (is equal to type sideUnknown) you can do this very easily. Instead of inserting the code into each line in the fn_queryRequest files as I originally specified, you can do this instead: Life_Server\Functions\MySQL\fn_queryRequest - Line 161 [_uid, _side, str(_side), 8] call HC_fnc_updatePartial; Life_HC\Functions\MySQL\fn_queryRequest - Line 155 [_uid, _side, str(_side), 8] call HC_fnc_updatePartial; This will translate the side of the player into a string and then insert it into the database rather than 'Player is Police' etc.. Thanks Chewz Share this post Link to post Share on other sites
GMT-HD 0 Posted April 14, 2020 @Chewz Thank you so much I have added [_uid, _side, str(_side), 8] call HC_fnc_updatePartial; and added case 8: { _sideToInsert = (_this select 2); // We don't need to worry about checking this. _query = format ["UPDATE players SET side = '%1' WHERE pid='%2'", _sideToInsert, _uid]; }; And when joining the server, the tabe side doesn't update Thank you again PS you was talking about [ life_hc\mysql\general\fn_queryRequest.sqf ] I don't have life_hc Share this post Link to post Share on other sites
Chewz 23 Posted April 14, 2020 10 minutes ago, GMT-HD said: @Chewz Thank you so much I have added [_uid, _side, str(_side), 8] call HC_fnc_updatePartial; and added case 8: { _sideToInsert = (_this select 2); // We don't need to worry about checking this. _query = format ["UPDATE players SET side = '%1' WHERE pid='%2'", _sideToInsert, _uid]; }; And when joining the server, the tabe side doesn't update Thank you again PS you was talking about [ life_hc\mysql\general\fn_queryRequest.sqf ] I don't have life_hc Hi Apologies, I named the function wrong! I did HC_ instead of DB_ try this instead [_uid, _side, str(_side), 8] call DB_fnc_updatePartial; Share this post Link to post Share on other sites
GMT-HD 0 Posted April 14, 2020 7 minutes ago, Chewz said: Hi Apologies, I named the function wrong! I did HC_ instead of DB_ try this instead [_uid, _side, str(_side), 8] call DB_fnc_updatePartial; Thank you but still nothing changed. This is my code,Life_Server\Functions\MySQL\fn_queryRequest: https://pastebin.com/tNDWcvwbLife_Server\Functions\MySQL\fn_updatePartial: https://pastebin.com/ZM40jyzJ Share this post Link to post Share on other sites
Chewz 23 Posted April 14, 2020 35 minutes ago, GMT-HD said: Thank you but still nothing changed. This is my code,Life_Server\Functions\MySQL\fn_queryRequest: https://pastebin.com/tNDWcvwbLife_Server\Functions\MySQL\fn_updatePartial: https://pastebin.com/ZM40jyzJ Hi Try this for fn_queryRequest: https://pastebin.com/MBTUbiZD The fn_updatePartial looks good though! Chewz Share this post Link to post Share on other sites
GMT-HD 0 Posted April 15, 2020 17 hours ago, Chewz said: Hi Try this for fn_queryRequest: https://pastebin.com/MBTUbiZD The fn_updatePartial looks good though! Chewz Thank you so much! it works well Share this post Link to post Share on other sites