Skip to content

Commit

Permalink
Add attack ped option
Browse files Browse the repository at this point in the history
  • Loading branch information
kibook committed Jul 23, 2021
1 parent 7a176dd commit ca03980
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = '<?xml version="1.0"?>\n<Map>\n\t<MapMeta Creator="' .. creator .. '"/>\n'

Expand Down
1 change: 1 addition & 0 deletions permissions.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
3 changes: 3 additions & 0 deletions ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,9 @@
<div class="property">
<button id="properties-go-to-entity">Go To Entity</button>
</div>
<div class="property">
<button id="properties-attack">Attack</button>
</div>
<div class="property local">
<div class="label">Scale (local)</div>
<input type="number" id="properties-scale" min="0.1" max="10.0" step="0.1" value="1.0">
Expand Down
11 changes: 11 additions & 0 deletions ui/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit ca03980

Please sign in to comment.