geekm0nkey

New Table (Player Tracker)

20 posts in this topic

So I have the need to create a new table, a combination of 2 other tables and their features. I need to create a table that increments like the "player_history", yet contains more information like "players". Here is what I have so far, yet it keeps throwing a "undefined variable" error? Anyone care to point out my obvious failure!

code added to exile.ini

Spoiler

[insertPlayerTracker]
SQL1_1 = INSERT INTO player_tracker SET account_uid = ?, name = ?, position_x = ?, position_y = ?, position_z = ?, locker = ?, money = ?, score = ?, current_weapon = ?, uniform = ?, backpack = ?, vest = ?
Number Of Inputs = 12
SQL1_INPUTS = 1,2,3,4,5,6,7,8,9,10,11,12

content of the playertracker.sqf located in the mission file. called in init.sqf - [] execVM "addons\playertracker.sqf";                             // send player updates to DB

Spoiler

if hasInterface then
{
    if isMultiplayer then
    {
        waitUntil { if ( not ( isNull ( findDisplay 46 ) ) AND ( ( typeOf player ) isEqualTo "Exile_Unit_Player" ) ) then { true } else { uiSleep 0.5; false } };
        
        private ["_uid","_name","_pos","_lockerMoney","_playerMoney","_playerScore","_current_weapon","_uniform","_backpack","_vest"];
        
        while {true} do
        {
            diag_log format ["PlayerTracker - Found player %1, adding entry to DB", player];

            _uid = getPlayerUID player;
            _name = name player;
            _pos = getPos player;

            _lockerMoney = player getVariable ["ExileLocker",0];
            _playerMoney = player getVariable ["ExileMoney",0];
            _playerScore = player getVariable ["ExileScore",0];

            _current_weapon = currentWeapon player;
            _uniform = uniform player;
            _backpack = backpack player;
            _vest = vest player;

            format["insertPlayerTracker:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12", _uid, _name, _pos select 0, _pos select 1, _pos select 2, _lockerMoney, _playerMoney, _playerScore, _current_weapon, _uniform, _backpack, _vest] call ExileServer_system_database_query_fireAndForget;
            uisleep 300;
        };
    };
};

Thanks.

Share this post


Link to post
Share on other sites
56 minutes ago, geekm0nkey said:

So I have the need to create a new table, a combination of 2 other tables and their features. I need to create a table that increments like the "player_history", yet contains more information like "players". Here is what I have so far, yet it keeps throwing a "undefined variable" error? Anyone care to point out my obvious failure!

code added to exile.ini

  Reveal hidden contents

[insertPlayerTracker]
SQL1_1 = INSERT INTO player_tracker SET account_uid = ?, name = ?, position_x = ?, position_y = ?, position_z = ?, locker = ?, money = ?, score = ?, current_weapon = ?, uniform = ?, backpack = ?, vest = ?
Number Of Inputs = 12
SQL1_INPUTS = 1,2,3,4,5,6,7,8,9,10,11,12

content of the playertracker.sqf located in the mission file. called in init.sqf - [] execVM "addons\playertracker.sqf";                             // send player updates to DB

  Hide contents

if hasInterface then
{
    if isMultiplayer then
    {
        waitUntil { if ( not ( isNull ( findDisplay 46 ) ) AND ( ( typeOf player ) isEqualTo "Exile_Unit_Player" ) ) then { true } else { uiSleep 0.5; false } };
        
        private ["_uid","_name","_pos","_lockerMoney","_playerMoney","_playerScore","_current_weapon","_uniform","_backpack","_vest"];
        
        while {true} do
        {
            diag_log format ["PlayerTracker - Found player %1, adding entry to DB", player];

            _uid = getPlayerUID player;
            _name = name player;
            _pos = getPos player;

            _lockerMoney = player getVariable ["ExileLocker",0];
            _playerMoney = player getVariable ["ExileMoney",0];
            _playerScore = player getVariable ["ExileScore",0];

            _current_weapon = currentWeapon player;
            _uniform = uniform player;
            _backpack = backpack player;
            _vest = vest player;

            format["insertPlayerTracker:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12", _uid, _name, _pos select 0, _pos select 1, _pos select 2, _lockerMoney, _playerMoney, _playerScore, _current_weapon, _uniform, _backpack, _vest] call ExileServer_system_database_query_fireAndForget;
            uisleep 300;
        };
    };
};

Thanks.

Maybe the code is meant to be run on the server, and then a player object also needs to be defined server side? It sounds like you need to take a look at how Exile server and client interaction is handled before posting for help :o

B+ for effort tho.

Edited by Cloud22
  • Like 1

Share this post


Link to post
Share on other sites
Advertisement
12 hours ago, Cloud22 said:

Maybe the code is meant to be run on the server, and then a player object also needs to be defined server side? It sounds like you need to take a look at how Exile server and client interaction is handled before posting for help :o

B+ for effort tho.

sigh..

Edited by geekm0nkey

Share this post


Link to post
Share on other sites

You won't be able to call ExileServer_system_database_query_fireAndForget client side. You will need to use existing network messages, or create new ones to send the information from client to server, then server to database

Share this post


Link to post
Share on other sites
4 hours ago, dekela said:

You won't be able to call ExileServer_system_database_query_fireAndForget client side. You will need to use existing network messages, or create new ones to send the information from client to server, then server to database

OK then maybe I'm missing something.. I have a script that writes to the database from client side? Or what I presume is client side. It's called exactly like the one I want.. In fact I used it as a template. The script simple writes the seconds left till restart to a new table. I assumed I could use the same technique. 

Edited by geekm0nkey

Share this post


Link to post
Share on other sites

i could be wrong, trust me, network messages are not my strong point. but it was my understanding that ExileServer_blah_blah is called server side, and ExileClient_blah_blah is called client side

Share this post


Link to post
Share on other sites
1 hour ago, dekela said:

i could be wrong, trust me, network messages are not my strong point. but it was my understanding that ExileServer_blah_blah is called server side, and ExileClient_blah_blah is called client side

This is a script I am using to track restart time on my website.

Spoiler

if (!isServer) exitWith {};

while {true} do
{
    //Start lines added for Time Until Restart database update
    _restartTime = 240; // change to your restart time in minutes.
    _uptime = call ExileServer_util_time_uptime;
    _timeTilRestart = _restartTime - _uptime;
    _restartTimerID = 1;
    format["updateTimeUntilRestart:%1:%2",_timeTilRestart,_restartTimerID] call ExileServer_system_database_query_fireAndForget;
    uisleep 60;
    //End lines added for Time Until Restart database update
};

which is called using. init.sqf as...

Spoiler

if (isServer) then {
    [] execVM "addons\timetorestartdb.sqf"; // send time to restart to DB
};

My assumption was that simply changing the exile.ini, added the fields i want to capture and calling in the same manner would work.. I think it will. I just need to trouble shoot the variables i'm using.. My end game is to capture a snapshot of the player every 5 minutes, what they have, what they are in, where the are.. etc.. That way I have one place to go look when players come at me with... "lost all my respect" "lost xyz item" "game glitched caused me to crash my xyx" instead of looking over logs, and other db entries. and trying to figure it out.

Share this post


Link to post
Share on other sites
14 hours ago, Cloud22 said:

Maybe the code is meant to be run on the server, and then a player object also needs to be defined server side? It sounds like you need to take a look at how Exile server and client interaction is handled before posting for help :o

B+ for effort tho.

For once, you may be on to something.. I had to refer back to the mod I released.. PVP map markers. How i got that to work was to do a foreach allPlayers and then create markers. I guess to get this done, Ill have to do something similar.

Update: Yes, this worked.. Was able to get it to collect data and write to the database. Now I just need to have it collect as much information as available.

Spoiler


while {true} do
{    
    private ["_justPlayers", "_uid","_name","_pos","_lockerMoney","_playerMoney","_playerScore","_current_weapon","_uniform","_backpack","_vest"];
    _justPlayers = allPlayers - entities "HeadlessClient_F";
    
    if (count _justPlayers > 0) then
    {
        {
            _uid = getPlayerUID _x;
            _name = name _x;
            _pos = getPos _x;

            _lockerMoney = _x getVariable ["ExileLocker",0];
            _playerMoney = _x getVariable ["ExileMoney",0];
            _playerScore = _x getVariable ["ExileScore",0];

            _current_weapon = currentWeapon _x;
            _uniform = uniform _x;
            _backpack = backpack _x;
            _vest = vest _x;

            format["insertPlayerTracker:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12", _uid, _name, _pos select 0, _pos select 1, _pos select 2, _lockerMoney, _playerMoney, _playerScore, _current_weapon, _uniform, _backpack, _vest] call ExileServer_system_database_query_fireAndForget;
        }forEach _justPlayers;
    };
    uisleep 300;
};

 

 

Edited by geekm0nkey

Share this post


Link to post
Share on other sites
1 hour ago, geekm0nkey said:

For once, you may be on to something.. I had to refer back to the mod I released.. PVP map markers. How i got that to work was to do a foreach allPlayers and then create markers. I guess to get this done, Ill have to do something similar.

Update: Yes, this worked.. Was able to get it to collect data and write to the database. Now I just need to have it collect as much information as available.

  Hide contents


while {true} do
{    
    private ["_justPlayers", "_uid","_name","_pos","_lockerMoney","_playerMoney","_playerScore","_current_weapon","_uniform","_backpack","_vest"];
    _justPlayers = allPlayers - entities "HeadlessClient_F";
    
    if (count _justPlayers > 0) then
    {
        {
            _uid = getPlayerUID _x;
            _name = name _x;
            _pos = getPos _x;

            _lockerMoney = _x getVariable ["ExileLocker",0];
            _playerMoney = _x getVariable ["ExileMoney",0];
            _playerScore = _x getVariable ["ExileScore",0];

            _current_weapon = currentWeapon _x;
            _uniform = uniform _x;
            _backpack = backpack _x;
            _vest = vest _x;

            format["insertPlayerTracker:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12", _uid, _name, _pos select 0, _pos select 1, _pos select 2, _lockerMoney, _playerMoney, _playerScore, _current_weapon, _uniform, _backpack, _vest] call ExileServer_system_database_query_fireAndForget;
        }forEach _justPlayers;
    };
    uisleep 300;
};

 

 

Having a loop reduces performance. Do yourself a favor and add it to an already existing loop or do it event based plz. And I’m sure if you actually made the “pvp map markers” you would understand by now how exile works. Pointless to try and copy paste and pass it as your own as somewhat unique content (I guess this) which shows your actual knowledge of SQF and optimization. Nonetheless, C- for effort man.

Edited by Cloud22

Share this post


Link to post
Share on other sites
33 minutes ago, Cloud22 said:

Having a loop reduces performance. Do yourself a favor and add it to an already existing loop or do it event based plz. And I’m sure if you actually made the “pvp map markers” you would understand by now how exile works. Pointless to try and copy paste and pass it as your own as somewhat unique content (I guess this) which shows your actual knowledge of SQF and optimization. Nonetheless, C- for effort man.

Dude, what the hell is your damage? You have done absolutely nothing but hurl unfounded accusations at me? Copy and Paste and call it my own? WTF dude, what have I EVER posted that was a copy and paste and called my own.. You really need to check yourself and your poor attitude at the door. If this is the best you can do to help someone, please do the community a favor and just sit and read.. And while we are at it sir.... YOU, and commenters like you... Are the reason this community is being dragged down.. No one likes dealing with an arrogant, presumptuous asshole.. (don't know those words, google it!) You may be lonely, mad or just feel superior.. But you only come off as a troll and a jackass looking for attention.. Go find someone else to harass ass.

You my friend get a F- for your attitude and an A+ for being a douche! (which I'm sure your smiling about, due to that is how all small minded trolls act when they manage to get the negative attention they want.)

  • Like 1

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.