Serverwide Message

I’m currently in the process of making a script for RP servers. This script will alert cops that someone has just attempted to steal a car and give them the location. I’m very new to writing scripts for GTA and I’m quite new to Lua in general.

I’ve come up with the below script so far, I’m just curious as to whether there is a way to create a serverwide message, I’ve looked in the Natives Database and I cannot see anything that would help me achieve it. Where I have put comments is what I am intending on writing, however I’m working on several other scripts at the same time.

Any advise, is helpful advice :smiley:

RegisterNetEvent('lupo:genie')
AddEventHandler('lupo:genie', function()
    
  local playerPed = GetPlayerped(-1)
  math.randomseed(100)
  local luckyNumber = math.random()
  
  if(isPedTryingToEnterALockedVehicle(1)) then
    if luckyNumber <= 20 then
      
      -- Send message to server alerting that %playername has just tried to steal a vehicle on %streetname, %district
      
    else
      
      if luckyNumber >= 95 then
      -- Select target vehicle and unlock it, advising the player attempting to get in the vehicle that they have managed to force the door open.
      
  end
end
end
end)

I have no idea why/how I managed to post that while not being logged into my account. This is me ^

Strange.

You really should have found this by searching the wiki or these forums. :slightly_smiling_face:
Send an event to the server from the player that is trying to steal.
Then get the player name with GET_PLAYER_NAME.
Then send from the server:

TriggerClientEvent("chatMessage", -1, "^3[ALERT]", {255, 255, 255}, playername.." tried to steal shit.")

The -1 is to send it server-wide.

2 Likes

mon amis, you’re a gentleman.

I did search the forums, but I couldn’t get any results with the keywords I was using. Thanks :slight_smile:

2 Likes