BetterDeadThanZed

[RELEASE] Prevent players from purchasing vehicles without the right respect

7 posts in this topic

5 hours ago, BetterDeadThanZed said:

It won't fix the problem of people being able to attempt to buy a vehicle without the right respect.

Wich means, they lose the money but don't get the vehicle?

Share this post


Link to post
Share on other sites
Advertisement
5 hours ago, BetterDeadThanZed said:

It's been a bug for a while, that players could buy vehicles without the respect. This script fixes that. I did not write this script. It was given to me by a community member and he asked me to post it. 

Create a file called  ExileServer_system_trading_network_purchaseVehicleRequest.sqf and put it in your mission file, in a folder called overwrites. The following code goes in that file:

  Reveal hidden contents


/**
 * ExileServer_system_trading_network_purchaseVehicleRequest
 *
 * Exile Mod
 * www.exilemod.com
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_sessionID","_parameters","_vehicleClass","_pinCode","_playerObject","_salesPrice","_playerMoney","_position","_vehicleObject","_logging","_traderLog","_responseCode", "_playerRespect", "_quantity", "_requiredRespect"];
_sessionID = _this select 0;
_parameters = _this select 1;
_vehicleClass = _parameters select 0;
_pinCode = _parameters select 1;
try 
{
	_playerObject = _sessionID call ExileServer_system_session_getPlayerObject;
	if (isNull _playerObject) then
	{
		throw 1;
	};
	if !(alive _playerObject) then
	{
		throw 2;
	};
	if (_playerObject getVariable ["ExileMutex",false]) then
	{
		throw 12;
	};
	_playerObject setVariable ["ExileMutex", true];
	if !(isClass (missionConfigFile >> "CfgExileArsenal" >> _vehicleClass) ) then
	{
		throw 3;
	};
	_salesPrice = getNumber (missionConfigFile >> "CfgExileArsenal" >> _vehicleClass >> "price");
	if (_salesPrice <= 0) then
	{
		throw 4;
	};
	_playerMoney = _playerObject getVariable ["ExileMoney", 0];
	if (_playerMoney < _salesPrice) then
	{
		throw 5;
	};
	//* Patched in RESPECT check from _purchaseVechicleRequest  Prevents PIN number exploit, but returns an error.
	_playerRespect = _playerObject getVariable ["ExileScore", 0];
	_quality = getNumber(missionConfigFile >> "CfgExileArsenal" >> _vehicleClass >> "quality");
	_requiredRespect = getNumber(missionConfigFile >> "CfgTrading" >> "requiredRespect" >> format["Level%1",_quality]);
	if (_playerRespect < _requiredRespect) then
	{
		throw 14;
	};
	if !((count _pinCode) isEqualTo 4) then
	{
		throw 11;
	};
	if (_vehicleClass isKindOf "Ship") then 
	{
		_position = [(getPosATL _playerObject), 100, 20] call ExileClient_util_world_findWaterPosition;
		_vehicleObject = [_vehicleClass, _position, (random 360), false, _pinCode] call ExileServer_object_vehicle_createPersistentVehicle;
	}
	else 
	{
		_position = (getPos _playerObject) findEmptyPosition [10, 250, _vehicleClass];
		if (_position isEqualTo []) then 
		{
			throw 13;
		};
		_vehicleObject = [_vehicleClass, _position, (random 360), true, _pinCode] call ExileServer_object_vehicle_createPersistentVehicle;
	};	
	_vehicleObject setVariable ["ExileOwnerUID", (getPlayerUID _playerObject)];
	_vehicleObject setVariable ["ExileIsLocked",0];
	_vehicleObject lock 0;
	_vehicleObject call ExileServer_object_vehicle_database_insert;
	_vehicleObject call ExileServer_object_vehicle_database_update;
	_playerMoney = _playerMoney - _salesPrice;
	_playerObject setVariable ["ExileMoney", _playerMoney, true];
	format["setPlayerMoney:%1:%2", _playerMoney, _playerObject getVariable ["ExileDatabaseID", 0]] call ExileServer_system_database_query_fireAndForget;
	[_sessionID, "purchaseVehicleResponse", [0, netId _vehicleObject, _salesPrice]] call ExileServer_system_network_send_to;
	_logging = getNumber(configFile >> "CfgSettings" >> "Logging" >> "traderLogging");
	if (_logging isEqualTo 1) then
	{
		_traderLog = format ["PLAYER: ( %1 ) %2 PURCHASED VEHICLE %3 FOR %4 POPTABS | PLAYER TOTAL MONEY: %5",getPlayerUID _playerObject,_playerObject,_vehicleClass,_salesPrice,_playerMoney];
		"extDB2" callExtension format["1:TRADING:%1",_traderLog];
	};
}
catch 
{
	_responseCode = _exception;
	[_sessionID, "purchaseVehicleResponse", [_responseCode, "", 0]] call ExileServer_system_network_send_to;
};
if !(isNull _playerObject) then 
{
	_playerObject setVariable ["ExileMutex", false];
};
true

 

In your mission file's config.cpp, go to the Class CfgExileCustomCode section and add this:


ExileServer_system_trading_network_purchaseVehicleRequest = "custom\ExileServer_system_trading_network_purchaseVehicleRequest.sqf"

This will simply prevent them from buying the vehicle without the right respect. It won't fix the problem of people being able to attempt to buy a vehicle without the right respect.

sorry, had to ask...wonder if you mean a folder named "custom"

 in a folder called overwrites

= "custom\ExileServer_system...

  • Like 1

Share this post


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

sorry, had to ask...wonder if you mean a folder named "custom"

just a typo, just create the file where you like and just be sure you have the location called right

"custom\ExileServer_system_trading_network_purchaseVehicleRequest.sqf" (would be the file in folder "custom")
"overwrites\ExileServer_system_trading_network_purchaseVehicleRequest.sqf" (would be the file in folder "overwrites")
"ExileServer_system_trading_network_purchaseVehicleRequest.sqf" (would be the file straight in mission.pbo, maindir)
Edited by WURSTKETTE

Share this post


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

Wich means, they lose the money but don't get the vehicle?

No. They don't lose money. What I mean is that they can still attempt to buy the vehicle. 

1 hour ago, yukihito23 said:

sorry, had to ask...wonder if you mean a folder named "custom"

 in a folder called overwrites

= "custom\ExileServer_system...

You can call it custom, overwrites, flyingpigs, whatever you like.

  • Like 2

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.