Sell or Service your last driven vehicle

  • Offline CREAMPIE
  • Armaholic
  • Veteran
  • ******
  • Posts: 1075
  • ^_^;;

Sell or Service your last driven vehicle

« posted: Jan 27, 2015, 06:04 PM »
I got tired of using the silly sell vehicle pads and chopshop triggers  so i combined them with the Vehicle Store NPCs , who now offer to buy  or service your last driven vehicle :) I've also modified the wording in my playeractions for NPC owners as well.

Currently working on Stratis 1.1, but can easily be ported i guess ..

server\functions\setupStoreNPC.sqf

   
Code: [Select]
        _npc addAction ["<img image='client\icons\money.paa'/> Sell Crate", "client\systems\selling\sellCrateItems.sqf", [false, false, true], 0.99, false, true, "", STORE_ACTION_CONDITION + " && " + SELL_CRATE_CONDITION];
_npc addAction ["<img image='client\icons\money.paa'/> Sell Crate Contents", "client\systems\selling\sellCrateItems.sqf", [], 0.98, false, true, "", STORE_ACTION_CONDITION + " && " + SELL_CONTENTS_CONDITION];
_npc addAction ["<img image='client\icons\money.paa'/> Sell Vehicle", "client\systems\selling\sellVehicle.sqf", [], 0.97, false, true, "", STORE_ACTION_CONDITION + " && " + SELL_VEH_CONTENTS_CONDITION];
_npc addAction ["<img image='client\icons\money.paa'/> Sell Vehicle Contents", "client\systems\selling\sellVehicleItems.sqf", [], 0.97, false, true, "", STORE_ACTION_CONDITION + " && " + SELL_VEH_CONTENTS_CONDITION];
_npc addAction ["<img image='client\icons\repair.paa'/> Service Vehicle", "client\systems\selling\serviceVehicle.sqf", [], 0.97, false, true, "", STORE_ACTION_CONDITION + " && " + SELL_VEH_CONTENTS_CONDITION];

client\systems\selling\serviceVehicle.sqf
Code: [Select]
// ******************************************************************************************
// * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com *
// ******************************************************************************************
// @file Name: serviceVehicle.sqf
// @file Author:
//  @file edited: CRE4MPIE
//  @credits to: Cael817, Lodac, Wiking, Gigatek (original auth of chopshop)


#include "sellIncludesStart.sqf";

storeSellingHandle = _this spawn
{
#define CHOPSHOP_PRICE_RELATIONSHIP 4
#define VEHICLE_MAX_SELLING_DISTANCE 50

private ["_vehicle","_type", "_price", "_confirmMsg", "_playerMoney", "_text"];

_storeNPC = _this select 0;
_vehicle = objectFromNetId (player getVariable ["lastVehicleRidden", ""]);
_type = typeOf _vehicle;
_playerMoney = player getVariable "cmoney";
_price = 500;
_objClass = typeOf _vehicle;
_objName = getText (configFile >> "CfgVehicles" >> _objClass >> "displayName");

if (isNull _vehicle) exitWith
{
playSound "FD_CP_Not_Clear_F";
["Your previous vehicle does not exist anymore.", "Error"] call  BIS_fnc_guiMessage;
};

if (_vehicle distance _storeNPC > VEHICLE_MAX_SELLING_DISTANCE) exitWith
{
playSound "FD_CP_Not_Clear_F";
[format ['"%1" is further away than %2m from the store.', _objname, VEHICLE_MAX_SELLING_DISTANCE], "Error"] call  BIS_fnc_guiMessage;
};



{
if (_type == _x select 1) then
{
_price = _x select 2;
_price = _price / CHOPSHOP_PRICE_RELATIONSHIP;
};

} forEach (call allVehStoreVehicles);

if (_price > _playerMoney) exitWith
{
playSound "FD_CP_Not_Clear_F";
[format ['You do not have enough money to service the %1', _objname], "Error"] call  BIS_fnc_guiMessage;
};

if (!isNil "_price") then
{
// Add total sell value to confirm message
_confirmMsg = format ["Servicing your %1 will cost you $%2 <br/>", _objName, _price];
_confirmMsg = _confirmMsg + format ["<br/><t font='EtelkaMonospaceProBold'>1</t> x %1", _objName];

// Display confirm message
if ([parseText _confirmMsg, "Confirm", "SERVICE", true] call BIS_fnc_guiMessage) then
{

  _vehicle setVehicleAmmo 1;
  _vehicle setFuel 1;
  _vehicle setDamage 0;
 
player setVariable["cmoney",(player getVariable "cmoney")-_price,true];
[format ['Your %1 has been rearmed, repaired and refuelled!', _objname, VEHICLE_MAX_SELLING_DISTANCE], "THANK YOU"] call  BIS_fnc_guiMessage;

if (["A3W_playerSaving"] call isConfigOn) then
{
[] spawn fn_savePlayerData;
};
};
} else {
hint parseText "<t color='#ffff00'>An unknown error occurred.</t><br/>Cancelled.";
playSound "FD_CP_Not_Clear_F";
};
};

#include "sellIncludesEnd.sqf";


client\systems\selling\sellVehicle.sqf

Code: [Select]
// ******************************************************************************************
// * This project is licensed under the GNU Affero GPL v3. Copyright © 2014 A3Wasteland.com *
// ******************************************************************************************
// @file Name: sellVehicle.sqf
// @file Author: AgentRev
//  @file edited: CRE4MPIE
//  @credits to: Cael817, Lodac, Wiking, Gigatek (original auth of chopshop)


#include "sellIncludesStart.sqf";

storeSellingHandle = _this spawn
{
#define CHOPSHOP_PRICE_RELATIONSHIP 2
#define VEHICLE_MAX_SELLING_DISTANCE 50

private ["_vehicle","_type", "_price", "_confirmMsg", "_playerMoney", "_text"];

_storeNPC = _this select 0;
_vehicle = objectFromNetId (player getVariable ["lastVehicleRidden", ""]);
_type = typeOf _vehicle;
_playerMoney = player getVariable "cmoney";
_price = 500;
_objClass = typeOf _vehicle;
_objName = getText (configFile >> "CfgVehicles" >> _objClass >> "displayName");

if (isNull _vehicle) exitWith
{
playSound "FD_CP_Not_Clear_F";
["Your previous vehicle does not exist anymore.", "Error"] call  BIS_fnc_guiMessage;
};

if (_vehicle distance _storeNPC > VEHICLE_MAX_SELLING_DISTANCE) exitWith
{
playSound "FD_CP_Not_Clear_F";
[format [' The "%1" is further away than %2m from the store.', _objname, VEHICLE_MAX_SELLING_DISTANCE], "Error"] call  BIS_fnc_guiMessage;
};

if !(player getVariable ["lastVehicleOwner", false]) exitWith
{
playSound "FD_CP_Not_Clear_F";
[format ['You are not the owner of the "%1"', _objName, VEHICLE_MAX_SELLING_DISTANCE], "Error"] call  BIS_fnc_guiMessage;
};

{
if (_type == _x select 1) then
{
_price = _x select 2;
_price = _price / CHOPSHOP_PRICE_RELATIONSHIP;
};

} forEach (call allVehStoreVehicles);

if (!isNil "_price") then
{
// Add total sell value to confirm message
_confirmMsg = format ["Selling  the %1 will give you $%2<br/>", _objName, _price];
_confirmMsg = _confirmMsg + format ["<br/><t font='EtelkaMonospaceProBold'>1</t> x %1", _objName];

// Display confirm message
if ([parseText _confirmMsg, "Confirm", "SELL", true] call BIS_fnc_guiMessage) then
{

sleep (1 + (random 4));

if (_vehicle distance _storeNPC > VEHICLE_MAX_SELLING_DISTANCE) exitWith
{
playSound "FD_CP_Not_Clear_F";
[format ['The %1 has already been sold!', _objname, VEHICLE_MAX_SELLING_DISTANCE], "Error"] call  BIS_fnc_guiMessage;
};

deleteVehicle _vehicle;

player setVariable["cmoney",(player getVariable "cmoney")+_price,true];
[format ['The %1 has been sold!', _objname, VEHICLE_MAX_SELLING_DISTANCE], "THANK YOU"] call  BIS_fnc_guiMessage;

if (["A3W_playerSaving"] call isConfigOn) then
{
[] spawn fn_savePlayerData;
};
};
} else {
hint parseText "<t color='#ffff00'>An unknown error occurred.</t><br/>Cancelled.";
playSound "FD_CP_Not_Clear_F";
};
};

#include "sellIncludesEnd.sqf";





- from the grassy knoll -

Re: Sell last driven vehicle

« Reply #1 posted: Jan 27, 2015, 06:24 PM »
Nice. Will test on my Altis server.
  • Offline bolox
  • Mercenary
  • *****
  • Posts: 276

Re: Sell last driven vehicle

« Reply #2 posted: Jan 27, 2015, 06:43 PM »
Strange addition,who would have thought of an idea like that.Im adding this,very interesting
Our 250 popular player rust server 1rule- Dont be a dick
www.nomercykillers.com

Re: Sell last driven vehicle

« Reply #3 posted: Jan 27, 2015, 07:32 PM »
nice i was looking how to sell vehicles this is the best way i can think of

added to server will give feedback later
  • Offline LouD
  • Silent but deadly ;)
  • Moderator
  • Veteran
  • ******
  • Posts: 1415

Re: Sell last driven vehicle

« Reply #4 posted: Jan 27, 2015, 09:14 PM »
I got rid of the sell pads aswell. I implemented sell trucks like TOP has and I have implemented change ownership trucks :)

This however will take some changing to your mission. Some commits have come after this one to fix small errors.
https://github.com/LouDnl/ArmA3_Wasteland.Altis/commit/66ff3c14d6d7a40b0118b2f93923e377db9b532f

Re: Sell last driven vehicle

« Reply #5 posted: Jan 28, 2015, 12:55 AM »
Thanks CREAMPIE!

I added this to our server today, everything seems to be good, will keep you posted if there are any issues that we find.
  • Offline CREAMPIE
  • Armaholic
  • Veteran
  • ******
  • Posts: 1075
  • ^_^;;

Re: Sell last driven vehicle

« Reply #6 posted: Jan 28, 2015, 05:58 AM »
Updated the OP.
- from the grassy knoll -

Re: Sell last driven vehicle

« Reply #7 posted: Jan 28, 2015, 06:07 AM »
is it possible to add rearm last vehicle in stores

would be good to have the option so players have to pay for more ammunition
  • Offline CREAMPIE
  • Armaholic
  • Veteran
  • ******
  • Posts: 1075
  • ^_^;;

Re: Sell last driven vehicle

« Reply #8 posted: Jan 28, 2015, 06:22 AM »
is it possible to add rearm last vehicle in stores

would be good to have the option so players have to pay for more ammunition

My next change will have repair / re-arm in :)
- from the grassy knoll -

Re: Sell last driven vehicle

« Reply #9 posted: Jan 28, 2015, 06:26 AM »
excellent can not wait
  • Offline CREAMPIE
  • Armaholic
  • Veteran
  • ******
  • Posts: 1075
  • ^_^;;

Re: Sell last driven vehicle

« Reply #10 posted: Jan 28, 2015, 07:46 AM »
Updated the OP.
- from the grassy knoll -
  • Offline LouD
  • Silent but deadly ;)
  • Moderator
  • Veteran
  • ******
  • Posts: 1415

Re: Sell or Service your last driven vehicle

« Reply #11 posted: Jan 28, 2015, 09:13 AM »
Do you check if the seller was the driver of the vehicle? There might be a duping bug when 4 players from the same vehicle try to sell the same vehicle.

Re: Sell or Service your last driven vehicle

« Reply #12 posted: Jan 28, 2015, 09:30 AM »
added will check and get back to you thanks again

Re: Sell or Service your last driven vehicle

« Reply #13 posted: Jan 28, 2015, 11:39 AM »
works great thank you  :D
  • Offline CREAMPIE
  • Armaholic
  • Veteran
  • ******
  • Posts: 1075
  • ^_^;;

Re: Sell or Service your last driven vehicle

« Reply #14 posted: Jan 28, 2015, 01:08 PM »
Do you check if the seller was the driver of the vehicle? There might be a duping bug when 4 players from the same vehicle try to sell the same vehicle.

Probably a good idea - thanks :)
- from the grassy knoll -