Guest User

Untitled

a guest
Feb 16th, 2017
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.64 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3.     File: fn_vehicleGive.sqf
  4.     Author: Bryan "Tonic" Boardwine
  5.  
  6.     Description:
  7.     Transfer the key and the vehicle ownership to another player.
  8.     Player must be within range.
  9. */
  10. private ["_dialog","_list","_plist","_sel","_vehicle","_owners","_index","_unit","_uid"];
  11. disableSerialization;
  12.  
  13. _dialog = findDisplay 2700;
  14. _list = _dialog displayCtrl 2701;
  15. _plist = _dialog displayCtrl 2702;
  16.  
  17. _sel = lbCurSel _list;
  18. if ((_list lbData _sel) isEqualTo "") exitWith {hint localize "STR_NOTF_didNotSelectVehicle";};
  19. _vehicle = _list lbData _sel;
  20. _vehicle = life_vehicles select parseNumber(_vehicle);
  21.  
  22. if ((lbCurSel 2702) isEqualTo -1) exitWith {hint localize "STR_NOTF_didNotSelectPlayer";};
  23. _sel = lbCurSel _plist;
  24. _unit = _plist lbData _sel;
  25. _unit = call compile format ["%1", _unit];
  26. if (isNull _unit || isNil "_unit") exitWith {};
  27. if (_unit == player) exitWith {};
  28.  
  29. _uid = getPlayerUID _unit;
  30. _owners = _vehicle getVariable "vehicle_info_owners";
  31. _index = [_uid,_owners] call TON_fnc_index;
  32. if (_index isEqualTo -1) then  {
  33.     _owners pushBack [_uid,_unit getVariable ["realname",name _unit]];
  34.     _vehicle setVariable ["vehicle_info_owners",_owners,true];
  35. };
  36.  
  37. hint format [localize "STR_NOTF_givenKeysTo",_unit getVariable ["realname",name _unit],typeOf _vehicle];
  38. [_vehicle,_unit,profileName] remoteExecCAll ["TON_fnc_clientGetKey",_unit];
  39.  
  40. // On appelle le transert de l'ownership du véhicule
  41. [_vehicle,_uid] remoteExecCall ["TON_fnc_vehicleGive",RSERV];
  42.  
  43. // logging
  44. diag_log format ["le vehicule est %1, la personne est %2",_vehicle,_uid];
  45.  
  46. // On lâche la clé
  47. [] call life_fnc_keyDrop;
Add Comment
Please, Sign In to add comment