From ca039806809d0114e398822080a0f108b00cdd69 Mon Sep 17 00:00:00 2001 From: kibook Date: Thu, 22 Jul 2021 20:00:43 -0400 Subject: [PATCH] Add attack ped option --- client.lua | 9 +++++++++ permissions.cfg | 1 + server.lua | 1 + ui/index.html | 3 +++ ui/script.js | 11 +++++++++++ 5 files changed, 25 insertions(+) diff --git a/client.lua b/client.lua index 9c74709..c7d8ee8 100644 --- a/client.lua +++ b/client.lua @@ -103,6 +103,7 @@ Permissions.properties.ped.scale = false Permissions.properties.ped.configFlags = false Permissions.properties.ped.goToWaypoint = false Permissions.properties.ped.goToEntity = false +Permissions.properties.ped.attack = false Permissions.properties.vehicle = {} Permissions.properties.vehicle.repair = false @@ -1713,6 +1714,14 @@ RegisterNUICallback('repairVehicle', function(data, cb) cb({}) end) +RegisterNUICallback('attackPed', function(data, cb) + if Permissions.properties.ped.attack and CanModifyEntity(data.handle) then + RequestControl(data.handle) + TaskCombatPed(data.handle, data.ped) + end + cb {} +end) + function ConvertDatabaseToMapEditorXml(creator, database) local xml = '\n\n\t\n' diff --git a/permissions.cfg b/permissions.cfg index ae99c8c..3c627c0 100644 --- a/permissions.cfg +++ b/permissions.cfg @@ -73,6 +73,7 @@ add_ace builtin.everyone spooner allow #add_ace builtin.everyone spooner.properties.ped.configFlags allow # Allow changing ped config flags #add_ace builtin.everyone spooner.properties.ped.goToWaypoint allow # Allow making ped go to waypoint #add_ace builtin.everyone spooner.properties.ped.goToEntity allow # Allow making ped to go entity +#add_ace builtin.everyone spooner.properties.ped.attack allow # Allow making a ped attack another ped # Vehicle properties #add_ace builtin.everyone spooner.properties.vehicle allow # Allow changing all vehicle properties diff --git a/server.lua b/server.lua index cc11d41..e2b7c27 100644 --- a/server.lua +++ b/server.lua @@ -74,6 +74,7 @@ AddEventHandler('spooner:init', function() permissions.properties.ped.configFlags = IsPlayerAceAllowed(source, 'spooner.properties.ped.configFlags') permissions.properties.ped.goToWaypoint = IsPlayerAceAllowed(source, 'spooner.properties.ped.goToWaypoint') permissions.properties.ped.goToEntity = IsPlayerAceAllowed(source, 'spooner.properties.ped.goToEntity') + permissions.properties.ped.attack = IsPlayerAceAllowed(source, 'spooner.properties.ped.attack') permissions.properties.vehicle = {} permissions.properties.vehicle.repair = IsPlayerAceAllowed(source, 'spooner.properties.vehicle.repair') diff --git a/ui/index.html b/ui/index.html index b4c646d..63e5a8b 100644 --- a/ui/index.html +++ b/ui/index.html @@ -490,6 +490,9 @@
+
+ +
Scale (local)
diff --git a/ui/script.js b/ui/script.js index 0027848..c79dbb1 100644 --- a/ui/script.js +++ b/ui/script.js @@ -2570,4 +2570,15 @@ window.addEventListener('load', function() { openDatabase(resp); }); }); + + document.getElementById('properties-attack').addEventListener('click', function(event) { + let handle = currentEntity(); + + openEntitySelect('ped-options-menu', function(entity) { + sendMessage('attackPed', { + handle: handle, + ped: entity + }); + }, handle); + }); });