Hi I have an script client sided that works wll, the things is that I want to put it in order that when i put de command the picture display in all players screen on the server.
Here I put the client.lua if someone can help me to create the server.lua in order to apper the picture in all players screen,
With that being the case… anyone on your server would be able to turn these on and off… which could lead to some interesting griefing. Would prob be best to make sure the person running the commands has a certain level of trust on the server before being able to run… like mod/admin/super admin.
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
RegisterCommand('alertaverdeon', function(source)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.job.name == 'police' or xPlayer.job.name == 'sheriff' then
TriggerClientEvent('logo:display', -1, true)
end
end)
RegisterCommand('alertaverdeoff', function(source)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.job.name == 'police' or xPlayer.job.name == 'sheriff' then
TriggerClientEvent('logo:display', -1, false)
end
end)
When I get back home I put here the error, other problem is that if I put the command the picturebonly displays for the people that is inside the server in that moment, if someone enters after the command was executed it wouldnt see the picture on his screen except if I put the command again
If esx has been loaded which looks like it has… should be ok… but you could try setting a local to catch the source and then use it… like this
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
RegisterCommand('alertaverdeon', function(source)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
if xPlayer.job.name == 'police' or xPlayer.job.name == 'sheriff' then
TriggerClientEvent('logo:display', -1, true)
end
end)
RegisterCommand('alertaverdeoff', function(source)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
if xPlayer.job.name == 'police' or xPlayer.job.name == 'sheriff' then
TriggerClientEvent('logo:display', -1, false)
end
end)
The script works perfectly thanks, but do you know anyway that if someone joins the server after the command has been executed for displaying the picture, the person that joins after executing the command can see the picture without having to put the command again??
You would need to setup a function for onplayerjoin that syncs the display which i would work completely different then and only use 1 command to toggle it on and off… give me a few mins and I will try and come up with something for you.
ESX = nil
local adverton = false
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
RegisterCommand('alertaverde', function(source)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
if xPlayer.job.name == 'police' or xPlayer.job.name == 'sheriff' then
adverton = not adverton
TriggerClientEvent('logo:display', -1, adverton)
end
end)
RegisterServerEvent('scripnamehere:playerjoined')
AddEventHandler('scripnamehere:playerjoined', function()
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
if xPlayer.job.name == 'police' or xPlayer.job.name == 'sheriff' then
TriggerClientEvent('logo:display', _source, adverton)
end
end)
I have changed from 2 seperate commands to one command with a switch that turns if on/off depeding on the state… i have also added a server event that will send the status of the alert to any players that join by using the playerLoaded function from ESX. hopefully this is what you were looking for.