ynpMOOSE

function to get all player owned vehicle objects

7 posts in this topic

Would it be possible to create a function to return all owned vehicle objects by player? It needs to be an array of objects. This is open up a lot of potential mods, XM8 apps, etc.

Share this post


Link to post
Share on other sites

The developers don't need to add this functionality since it already exists. Every car that the player buys is tied to their UID. Below is a POC, by no means working. 

/* SQL START */
[allOwnedCars]
SQL1_1 = SELECT class FROM vehicle WHERE account_uid = ?
Number of Inputs = 1
SQL1_INPUTS = 1
OUTPUT = 1
/* SQL END */

// SQF START
_player = _sessionId call ExileServer_system_session_getPlayerObject;
_playerUID = getPlayerUID _player;
_carArray = format["allOwnedCars:%1",_playerUID] call ExileServer_system_database_query_selectSingle;
// SQF END

I'd suggest reading up on extDB2 and how Exile handles its data. 

Share this post


Link to post
Share on other sites
Advertisement

Thanks for the info. Any tips on where to learn about extDB2?

The only issue with what you wrote is that it gets me the list of vehicles from the database, but the vehicle objects from the mission are needed to perform actions on those vehicles. That's where I kept getting stuck without having to check all mission vehicles and compare the player to the vehicle owner.

Edited by ynpMOOSE

Share this post


Link to post
Share on other sites

I ended up having to do something like this, which seems highly inefficient:

 

  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;

Share this post


Link to post
Share on other sites

https://github.com/Torndeco/extDB2 is everything about extDB2. I learned everything by reading Exile's code. 

a2a3681f8d9743d368abf58c5000ed4f.png
https://gyazo.com/a2a3681f8d9743d368abf58c5000ed4f

I didn't realize that Exile_Bike_QuadBike_Black wasn't a classname. Kappa. 

3 hours ago, ynpMOOSE said:

The only issue with what you wrote is that it gets me the list of vehicles from the database,

What I wrote for you will query the database to return all vehicle classnames that are owned by a playerUID that you define. 

3 hours ago, ynpMOOSE said:

vehicle objects from the mission are needed to perform actions on those vehicles. That's where I kept getting stuck without having to check all mission vehicles and compare the player to the vehicle owner.

What do you mean "vehicle objects" from the mission? Nothing is tied to non-persistent vehicles hence why they are non-persistent. 

Share this post


Link to post
Share on other sites

It doesn't get a lot simpler than that... He pretty much just wrote it for you... xD

1 person likes this

Share this post


Link to post
Share on other sites

Maybe I'm missing something, or misunderstanding the Arma/Exile vehicle system.  I'm trying to learn, so please bear with me. I completely understand the SQL query, which is returning a list of owned vehicle classes name; however, how to do you correlate that list to the in-game vehicles?  My understanding is that the in-game vehicles are referenced by their vehicle object. So, in a case like my script (which does work, albeit inefficiently) I had to call this (_vehObjects = allMissionObjects "Car" + allMissionObjects "Air" + allMissionObjects "Ship";) to retrieve all the in-game vehicle objects, so I could compare the in-game vehicle ExileOwnerID variable to the current player, then set the allowDamage property (core Arma, not Exile nor in the db).  I'm not understanding how a list of class names gets me to where I need to be, there has to be another step better than my sloppy method. :)

Thanks,
Moose

Share this post


Link to post
Share on other sites
Advertisement

  • Recently Browsing   0 members

    No registered users viewing this page.