I have a script to call administrators by phone, but for the administrator to accept he needs to type / ac (call number) I would like to change this command to bind, "Q" to accept and "E" to stop refusing
Some charitable soul to help me?
local staffCall = {}
local staffCount = 0
addEvent( "SendMsgToTeamstaff", true )
addEventHandler( "SendMsgToTeamstaff", root,
function ( )
--if isTimer(timer) then return end
--timer = setTimer(function() end, 10000, 1)
local pX,pY,pZ = getElementPosition(source)
for k,v in ipairs(getElementsByType("player")) do
vX,vY,vZ = getElementPosition(v)
local dist = getDistanceBetweenPoints3D(pX,pY,pZ,vX,vY,vZ)
if dist <= 5 then
if v ~= source then
if getPedWeapon(v) > 0 then
outputChatBox("#D24D57[btc~Items] #ffffffAlguem armado está proximo de você então não pode fazer chamada!", source, 255, 255, 255, true)
return
end
end
end
end
if getElementData(source, "call:staff") then outputChatBox("#dc143c[BRPMTA - ERRO]:#ffffff Você já tem uma chamada em andamento aguarde 1 minuto para fazer novamente.", source, 255, 255, 255, true) return end
outputChatBox("#bebebeVocê chamou o staff, aguarde.", source, 255, 255, 255, true)
exports.btc_hud:dm(" "..getPlayerName(source).." Você chamou o staff, aguarde.", source, 255, 200, 0)
staffCount = staffCount + 1
staffCall[staffCount] = source
setElementData(source, "call:staff", staffCount)
setTimer ( setElementData, 600, 1, source, "call:staff", false)
tirarchamadostaffCall = setTimer(function()
staffCall[staffCount] = nil
end, 25000, 1 )
local x, y, z = getElementPosition(source)
setElementData(source, "call:staffposx", x)
setElementData(source, "call:staffposy", y)
setElementData(source, "call:staffposz", z)
for theKey,player in ipairs (getElementsByType("player")) do
if getElementData(player, "char:adminduty") == 1 then
outputChatBox("#bebebe"..getPlayerName(source).." chamou o staff utilize /ac " .. staffCount .. " para aceitar o pedido", player, 255, 255, 255, true)
displayServerMessage(player, ""..getPlayerName(source).." chamou o staff utilize /ac " .. staffCount .. " para aceitar o pedido", "warning")
end
end
end )
ChamadasS = {}
function aceitarstaff(thePlayer, commandName, acceptID)
if getElementData(thePlayer, "char:adminduty") == 1 then
if (acceptID) then
local acceptID = tonumber(acceptID)
if staffCall[acceptID] then
exports.btc_hud:dm("Você aceitou o chamado " .. acceptID .. "", thePlayer, 255, 200, 0)
exports.btc_hud:dm("O staff "..getPlayerName(thePlayer).." aceitou sua chamada", staffCall[acceptID], 255, 200, 0)
--if isTimer(chamadostaffCall) then
-- killTimer(chamadostaffCall)
--end
if isTimer(tirarchamadostaffCall) then
killTimer(tirarchamadostaffCall)
end
for theKey,player in ipairs (getElementsByType("player")) do
if getElementData(player, "char:adminduty") == 1 then
outputChatBox(" ", player, 255, 255, 255, true)
outputChatBox("#dc143c[BRPMTA - CHAMADA] #bebebeStaff "..getPlayerName(thePlayer).." aceitou o chamado " .. staffCount .. "", player, 255, 255, 255, true)
outputChatBox(" ", player, 255, 255, 255, true)
--setChamada (thePlayer)
end
end
setChamada (thePlayer)
local x, y, z = getElementData(staffCall[acceptID], "call:staffposx"), getElementData(staffCall[acceptID], "call:staffposy"), getElementData(staffCall[acceptID], "call:staffposz")
setElementPosition(thePlayer, x, y, z)
setElementData(thePlayer, "call:staff", nil)
--triggerClientEvent(thePlayer, "createstaffMarker", thePlayer, thePlayer, acceptID, staffCall[acceptID], x, y, z)
staffCall[acceptID] = nil
--staffCount = staffCount - 1
else
outputChatBox("#dc143c[BRPMTA - ERRO]:#ffffff Não existe essa chamada ou a chamada já foi aceita.", thePlayer, 255, 255, 255, true)
end
end
end
end
addCommandHandler("ac", aceitarstaff)