function workTags(text,message)
if text == nil then return 'text==nil' end
message = message == nil and true or message
local t = tags
if j.binds[activePieMenu] ~= nil and j.binds[activePieMenu].customTags ~= nil then
for k,v in ipairs(j.binds[activePieMenu].customTags) do
t[v.tag:gsub('%{',''):gsub('%}','')] = v.replacement
end
end
for k,v in pairs(t) do
for ll in text:gmatch('%{(%S+)%}') do
local b = pcall(function() return (ll~=nil and #ll > 2 and ((ll:match("^(%w+)")):lower() ~= nil) and (ll:match("^(%w+)")):lower() == k ) end)
if b then
if ll~=nil and #ll > 2 and ((ll:match("^(%w+)")):lower() ~= nil) and (ll:match("^(%w+)")):lower() == k then
if type(v) == 'function' and ll:find("%(%S+%)") then
local arg = ll:match('^'..k..'%((%S+)%)$')
local err = ''
arg,err = workTags(arg,message)
if arg == false or v(arg) == 'NO GSUB' then return false,err end
if tostring(v(arg)):find("^ERROR") then
if message then
sampAddChatMessage(('%s error {AB000C}%s'):format(ll,(v(arg)):match("^ERROR (.+)")) )
end
return false,(v(arg)):match("^ERROR (.+)")
end
text = text:gsub('%{'..removePattern(ll)..'%}',(type(v(arg)) == 'table' and table.concat(v(arg),',') or v(arg)))
else
text = text:gsub('%{'..removePattern(ll)..'%}',(tostring(v)))
end
end
end
end
end
return text
end
tags = {
carcolor = function(carid)
local h = carExits(carid)
if tostring(h):find('^ERROR') then return h end
return getCarColorName(h)
end,
nearcaridonscreen = function(_) return getNearCarOnScreen() end,
carid = function(id)
if not tonumber(id) then return 'ERROR player id == nil' end
local id = tonumber(id)
local b,h = true,PLAYER_PED
if id ~= tags.myid then
b,h = sampGetCharHandleBySampPlayerId(id)
end
if not doesCharExist(h) then return 'ERROR char not exits' end
if not isCharInAnyCar(h) then return 'ERROR char not is in car' end
return select(2,sampGetVehicleIdByCarHandle(storeCarCharIsInNoSave(h)))
end,
carmodel = function(carid)
local h = carExits(carid)
if tostring(h):find('^ERROR') then return h end
return getCarModel(h)
end,
carpos = function(carid)
local h = carExits(carid)
if tostring(h):find('^ERROR') then return h end
local x,y,z = getCarCoordinates(h)
return {x,y,z}
end,
carname = function(carid)
local h = carExits(carid)
if tostring(h):find('^ERROR') then return h end
return (carsName[getCarModel(h)-399] == nil and 'ERROR unknown car name' or carsName[getCarModel(h)-399])
end,
getcarpassengersnickname = function(carid)
local h = carExits(carid)
if tostring(h):find('^ERROR') then return h end
local text = 'none'
for k,v in ipairs(getAllChars()) do
if doesCharExist(v) and v ~= playerPed then
if isCharInCar(v,h) then
local nick = sampGetPlayerNickname(select(2,sampGetPlayerIdByCharHandle(v)))
if text == 'none' then text = '' end
text = text .. (nick:match('^(%w)')):upper() .. '.' .. (nick:match('^%w+_(%w+)$')) .. ','
end
end
end
return text:gsub(",$",'')
end,
getcarpassengersid = function(carid)
local h = carExits(carid)
if tostring(h):find('^ERROR') then return h end
for k,v in ipairs(getAllChars()) do
if doesCharExist(v) and v ~= playerPed then
if isCharInCar(v,h) then
return select(2,sampGetPlayerIdByCharHandle(v))
end
end
end
return -1
end,
--
nearpedidonscreen = function(_) return getNearPedOnScreen() end,
pedpos = function(id)
local h = charExits(id)
if tostring(h):find('^ERROR') then return h end
local x,y,z = getCharCoordinates(h)
return {x,y,z}
end,
direction = function(id)
local h = charExits(id)
if tostring(h):find('^ERROR') then return h end
return direction(h)
end,
--
getzone = function(arg)
local coords = coordsConv(arg)
if type(coords) == 'string' and coords:find('^ERROR') then return coords end
return getZone(unpack(coords))
end,
getcity = function(arg)
local coords = coordsConv(arg)
if type(coords) == 'string' and coords:find('^ERROR') then return coords end
return getCity(unpack(coords))
end,
nick = function(arg)
local id = tonumber(arg)
if not tonumber(id) then return 'ERROR player id == nil' end
if (tags.myid ~= id) and not sampIsPlayerConnected(tonumber(id)) then return "ERROR player disconnected" end
return sampGetPlayerNickname(id)
end,
name = function(id)
if not tonumber(id) then return 'ERROR player id == nil' end
if (tags.myid ~= tonumber(id)) and not sampIsPlayerConnected(tonumber(id)) then return "ERROR player disconnected" end
return sampGetPlayerNickname(tonumber(id)):match("^(%w+)_%w+$")
end,
surname = function(id)
if not tonumber(id) then return 'ERROR player id == nil' end
if (tags.myid ~= tonumber(id)) and not sampIsPlayerConnected(tonumber(id)) then return "ERROR player disconnected" end
return sampGetPlayerNickname(tonumber(id)):match("^%w+_(%w+)$")
end,
square = function(arg)
local coords = coordsConv(arg)
if type(coords) == 'string' and coords:find('^ERROR') then return coords end
return square(unpack(coords))
end,
sendkey = function(arg)
if not arg:find('%S+,%d+') then return 'ERROR invalid args "key,delay"' end
local bw = pcall(function() wait(0) end)
if bw then
local key,w = arg:match("(%S+),(%d+)")
for k,v in pairs(vkeys) do
if k:sub(1, 3) == 'VK_' and key:upper() == k:upper() then
setVirtualKeyDown(v,true)
wait(tonumber(w))
setVirtualKeyDown(v,false)
end
end
end
return 'NO GSUB'
end,
}