ynpMOOSE

How to get a list of all player owned vehicle IDs

5 posts in this topic

We're in the process of implementing some vehicle protections on our server to prevent mass vehicle destruction when players aren't around to protect their own vehicles, while trying to balance total server vehicle count.

Currently, we've written a script where, on server restart:

  • Locked vehicles within a territory, where the vehicle owner is authorized to build, are invincible until unlocked. Once unlocked, the vehicle is vulnerable until server restart. (that goes for your own cars or your friends cars that you touch.)
  • ANY vehicles in the wild or in an unauthorized territory are vulnerable.
  • ANY unlocked vehicles are vulnerable.
  • All vehicles in trader are unlocked on restart. (per last Exile update)

The next phase I'm working on is where I'm stuck. The plan is that all vehicles in your authorized territories are invincible on restart as above, but only until the vehicle owner logs in. If the vehicle owner logs into the server, ALL their owned vehicles are now vulnerable. If you use someone else's vehicles, those become vulnerable too (already part of the above, but we need to not break this). Any friends cars untouched are safe.

I can't figure out how to retrieve a list of vehicle IDs owned by a specific player userID, or even just a list of all vehicles that I could then parse by player ID. Any help is appreciated.

Thanks,
Moose

Share this post


Link to post
Share on other sites

I think I'm almost there. Does anyone know if the Exile DB vehicle ID matches the A3 vehicle object ID (even after server restart), making the code snip below viable? I'm thinking the answer is probably no. If so, how can I match up a list of known Exile vehicle IDs to the A3 object IDs?

Code Snip:

    {
        {
                _vehicleObject = _x;    //Set the vehicle ID to modify
                _vehicleObject allowDamage true;   //Make vehicle vulnerable
        } forEach _ownedVehicleIDs;   //Repeat for each owned vehicle, IDs are retrieved from Exile Db by user
    };

Edited by ynpMOOSE

Share this post


Link to post
Share on other sites
Advertisement

Maybe this way instead?  But seems very inefficient since it has to loop through every vehicle on the server. Is there any way to do a restricted ForEach, something like:  "ForEach vehicles where ExileOwnerID = uID;"

 

        {
                _vehicleObject = _x;    //Select the vehicle ID to modify
                _vehicleOwner = _vehicleObject getVariable "ExileOwnerUID";   //get vehicle owner ID
                if _vehicleOwner = _uid;   //execute only if player logging in is the owner
                {
                    _vehicleObject allowDamage true;   //Make vehicle vulnerable
                };
        } forEach vehicles;   //Repeat for each vehicle

1 person likes this

Share this post


Link to post
Share on other sites

Vehicles are not stored in db with any player uids. You would need to modify the on purchase code to store another variable in the db and create a new column that is the purchasers ID. Then you can get the information you want. 

Share this post


Link to post
Share on other sites
11 hours ago, happydayz said:

Vehicles are not stored in db with any player uids. You would need to modify the on purchase code to store another variable in the db and create a new column that is the purchasers ID. Then you can get the information you want. 

There is already an account_uID in the vehicles table that identifies the owner.

I've written this in ExileServer_object_player_database_load.sqf and it seems to work in my initial testing. The only concern is that calling allMissionObjects with hundreds of vehicles on the server might be slow, even if I've restricted the call to car/air/ship types. Our admin team will test this on our dev server today.

 

  1.     _vehObjects = allMissionObjects "Car" + allMissionObjects "Air" + allMissionObjects "Ship";
  2.     _ownerCheck = _player getVariable "ExileOwnerUID";
  3.     {
  4.     _vehicleOwner = _x getVariable "ExileOwnerUID";   //get vehicle owner ID
  5.     if (_ownerCheck isEqualTo _vehicleOwner) then
  6.         {
  7.         _x allowDamage true;  //Allow damage if vehicle is owned
  8.         };
  9.     } forEach _vehObjects;
Edited by ynpMOOSE

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.