AddEventHandler('chatMessage', function(source, n, message)
  local args = stringsplit(message, " ")
  if (args[1] == "/spawn") then
    CancelEvent()
    if (args[2] ~= nil) then
      local playerID = tonumber(source)
      local vehicleName = tostring(args[2])
      TriggerClientEvent('VehicleSpawn', playerID, vehicleName)
    else
      local event = 'chatMessage'
      local eventTarget = source
      local messageSender = "SYSTEM"
      local messageSenderColor = {200, 0, 0}
      local message = "Usage: /spawn <Vehicule Gratuit> dilettante"
      TriggerClientEvent(event, eventTarget, messageSender, messageSenderColor, message)
    end
  end
end)

function stringsplit(self, delimiter)
  local a = self:Split(delimiter)
  local t = {}

  for i = 0, #a - 1 do
     table.insert(t, a[i])
  end

  return t
end