Everything works fine except the message from whoever killed you.
when someone kills you, write:
“invalid” killed the name of the dead user.
client.lua
RegisterNetEvent('showNotification')
AddEventHandler('showNotification', function(text)
ShowNotification(text)
end)
function ShowNotification(text)
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(0,1)
end
Citizen.CreateThread(function()
alreadyDead = false
while true do
Citizen.Wait(50)
local playerPed = GetPlayerPed(-1)
if IsEntityDead(playerPed) and not alreadyDead then
killer = GetPedKiller(playerPed)
killername = false
for id = 0, 64 do
if killer == GetPlayerPed(id) then
killername = GetPlayerName(id)
end
end
if killer == playerPed then
TriggerServerEvent('playerDied',0,0)
elseif killername then
TriggerServerEvent('playerDied',killername,1)
else
TriggerServerEvent('playerDied',0,2)
end
alreadyDead = true
end
if not IsEntityDead(playerPed) then
alreadyDead = false
end
end
end)
server.lua
AddEventHandler('playerConnecting', function()
TriggerClientEvent('showNotification', -1,"~g~".. GetPlayerName(source).."~w~ se unió.")
end)
AddEventHandler('playerDropped', function()
TriggerClientEvent('showNotification', -1,"~r~".. GetPlayerName(source).."~w~ se fue.")
end)
RegisterServerEvent('playerDied')
AddEventHandler('playerDied',function(killer,reason)
if killer == "Invalid" then
reason = 2
end
if reason == 0 then
TriggerClientEvent('showNotification', -1,"~o~".. GetPlayerName(source).."~w~ se suicidó. ")
elseif reason == 1 then
TriggerClientEvent('showNotification', -1,"~o~".. killer .. "~w~ mató a ~o~"..GetPlayerName(source).."~w~.")
else
TriggerClientEvent('showNotification', -1,"~o~".. GetPlayerName(source).."~w~ se murió.")
end
end)
where this error?
thanks