Elioriel

fn_keyGive.sqf

Jan 13th, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 1.57 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3.     File: fn_keyGive.sqf
  4.     Author: Bryan "Tonic" Boardwine
  5.  
  6.     Description:
  7.     Gives a copy of the key for the selected vehicle to the selected 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 lbText _sel) == "You don't own any vehicles") exitWith {hint "You didn't select a vehicle.";};
  19. _vehicle = _list lbData _sel;
  20. _vehicle = life_vehicles select parseNumber(_vehicle);
  21.  
  22. _sel = lbCurSel _plist;
  23. _unit = _plist lbData _sel;
  24. if(_unit == "targetkeygive") then {
  25.     _unit = cursorObject;
  26. } else {
  27.     _unit = call compile format["%1",_unit];
  28. };
  29. if(isNull _unit OR isNil "_unit") exitWith {hint "La cible n'est pas un joueur !";ctrlShow[2703,true];};
  30. if(_unit == player) exitWith {hint "La cible n'est pas un joueur !";ctrlShow[2703,true];};
  31. if(!isPlayer _unit) exitWith {hint "La cible n'est pas un joueur !";ctrlShow[2703,true];};
  32. if(player distance _unit > 20) exitWith {hint "Cette personne est trop loin";ctrlShow[2703,true];};
  33.  
  34. _uid = getPlayerUID _unit;
  35. _owners = _vehicle GVAR "vehicle_info_owners";
  36. _index = [_uid,_owners] call TON_fnc_index;
  37. if(EQUAL(_index,-1)) then  {
  38.     _owners pushBack [_uid,_unit GVAR ["realname",name _unit]];
  39.     _vehicle SVAR ["vehicle_info_owners",_owners,true];
  40. };
  41.  
  42. hint format["Vous avez donnez les clefs de %1 à quelqu'un",typeOf _vehicle];
  43. [_vehicle,_unit,profileName] remoteExecCAll ["TON_fnc_clientGetKey",_unit];
Add Comment
Please, Sign In to add comment