Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 22/01/24 in all areas

  1. This reply is actually beautiful and could quite easily be it's own little thread, you have explained it much better than I ever could have there and showed the right way to achieve things like this. One of the biggest headaches I faced as a new coder many years ago was super duper nesting myself and creating messes.
    2 points
  2. It helps if you write every table modification inside of a new function. This way you keep your code more readable. The following examples are re-written code. You could use this as a start, but make sure to test it, because I didn't test it for you. local farm = createFarm(123, 1, 1, 1) local horse = createHorse(player, horseId) local farm = getFarmFromID (123) -- If the farm does exist if farm then addHorseToFarm(horse, farm) end local horseCollection = {} -- all horses local farmCollection = {} -- all farms ---@param player userdata ---@param horseId integer ---@return table function createHorse(player, horseId) local horse = { id = horseId } horseCollection[horseId] = horse return horse end ---@param farmId integer ---@param x number ---@param y number ---@param z number ---@return table function createFarm (farmId, x, y, z) local marker = createMarker(x, y, z) local farm = { marker = marker, id = farmId, location = { x, y, z }, owner = nil, creator = nil, creationTime = getTickCount(), price = 0, horses = {} } farmCollection[farmId] = farm return farm end ---@param farmId integer ---@return table|false function getFarmFromID (farmId) return farmCollection[farmId] or false end ---@param farm table ---@param player userdata ---@return table function setFarmCreator (farm, player) farm.creator = player return farm end ---@param horse table ---@param farm table function addHorseToFarm (horse, farm) table.insert(farm, horse) end ---@param horse table ---@param farm table ---@return boolean function isHorseInFarm(horse, farm) for i=1, #farm do if farm[i] == horse then return true end end return false end ---@param farmId integer ---@return boolean function doesFarmExist(farmId) return farmCollection[farmId] and true or false end
    1 point
  3. Olá @Sphynx, creio que já deve ter solucionado, nesse caso, como você quer desenvolver um Chat Local, o que você pode usar para "cancelar" o chat nativo é: onPlayerChat + cancelEvent Como vai funcionar: Quando um player usar o chat nativo(global), a mensagem será cancelada, sendo assim meio que anulado o mesmo; Daí é só você configurar o novo chat a seu gosto
    1 point
×
×
  • Create New...