I need someone awake and full of coffee to spot what digit is missing here…
I got a server running, sql, everything run smooth… now im trying to learn to make my own mod and learning interaction between server and client…
I took something simple that esx does, showAdvancedNotification and try to call it from within my own code and invested many hours looking at something not working… and trying all sort of codes.
Its a bit messy but if someone can explain me why i cant see the notification… i’ll saves a visit to the mental institute.
__resource.lua
server_scripts {
'server/main.lua'
}
client_scripts {
'config.lua',
'client/main.lua'
}
server\main.lua
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
RegisterServerEvent('esx_burn:tellALLPlayers')
AddEventHandler('esx_burn:tellALLPlayers', function() -- error #1 found!
local xPlayer = ESX.GetPlayerFromId(source)
for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
--TriggerClientEvent('esx:showAdvancedNotification', xPlayer.source, _U('Jessica'), _U('I need some weed babe!'), _U('work: ', xPlayer.job), 'CHAR_STRIPPER_JULIET', 9)
TriggerClientEvent('esx_burn:MsgPlaya', xPlayer.source, _U('Unknown'), _U('Ill kill you motherfucker!!'), _U('you dead homey'), 'CHAR_LESTER_DEATHWISH', 9)
end
end)
and the client\main.lua
local Keys = {
["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
}
ESX = nil
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)
RegisterNetEvent('esx_burn:wanted')
AddEventHandler('esx_burn:wanted', function(wantedlevel)
SetPlayerWantedLevel(PlayerId(), tonumber(wantedlevel), false)
SetPlayerWantedLevelNow(PlayerId(), false)
end)
RegisterNetEvent('esx_burn:MsgPlaya')
AddEventHandler('esx_burn:MsgPlaya', function(title, subject, msg, icon, iconType)
-- Get the ped headshot image.
local handle = RegisterPedheadshot(PlayerPedId())
while not IsPedheadshotReady(handle) or not IsPedheadshotValid(handle) do
Citizen.Wait(0)
end
local txd = GetPedheadshotTxdString(handle)
-- Add the notification text
SetNotificationTextEntry("STRING")
AddTextComponentSubstringPlayerName("This is the private message!")
-- Set the notification icon, title and subtitle.
--local title = GetPlayerName(PlayerId())
local subtitle = "Private Message"
local flash = false -- Flash doesn't seem to work no matter what.
SetNotificationMessage(txd, txd, flash, iconType, title, subtitle)
-- Draw the notification
local showInBrief = true
local blink = false -- blink doesn't work when using icon notifications.
DrawNotification(blink, showInBrief)
-- Cleanup after yourself!
UnregisterPedheadshot(handle)
end)
--[[
local function MsgPlayer() -- TEST LOCAL
-- Get the ped headshot image.
local handle = RegisterPedheadshot(PlayerPedId())
while not IsPedheadshotReady(handle) or not IsPedheadshotValid(handle) do
Citizen.Wait(0)
end
local txd = GetPedheadshotTxdString(handle)
-- Add the notification text
SetNotificationTextEntry("STRING")
AddTextComponentSubstringPlayerName("This is the private message!")
-- Set the notification icon, title and subtitle.
local title = GetPlayerName(PlayerId())
local subtitle = "Private Message"
local iconType = 2
--[[ iconType = ...
1 → Chat Box
2 → Email
3 → Add Friend Request
7 → Right Jumping Arrow
8 → RP Icon
9 → $ Icon
]]
local flash = false -- Flash doesn't seem to work no matter what.
SetNotificationMessage(txd, txd, flash, iconType, title, subtitle)
-- Draw the notification
local showInBrief = true
local blink = false -- blink doesn't work when using icon notifications.
DrawNotification(blink, showInBrief)
-- Cleanup after yourself!
UnregisterPedheadshot(handle)
end)
]]--
Citizen.CreateThread(function() --cant do shit here, dunno why, nothing happen
while true do
Citizen.Wait(1)
if IsPedInAnyVehicle(GetPlayerPed(-1)) then --PlayerId()
Citizen.Wait(1)
--TriggerClientEvent('esx_burn:MsgPlaya', xPlayer.source, _U('Jessica'), _U('received_paycheck'), _U('Bitch im pregnant'), 'CHAR_STRIPPER_JULIET', 9)
MsgPlayer()
print('Inside a car!')
else
print('Not in a car!')
end
if IsControlPressed(0, Keys['F9']) then -- F9
MsgPlayer()
end
if IsControlPressed(0, Keys['F10']) then -- F10
esx_burn:tellALLPlayers()
end
end
end)