Пример использования событий onStartNewGame, onSaveGame и onLoadGame, добавленных в версии .023.

CollectVehicles.lua

script_name('CollectVehicles')
script_author('FYP')
script_version_number(1)
 
local blacklist = {435, 441, 449, 450, 464, 465, 501, 528, 537, 538, 564, 569, 570, 584, 590, 591, 594, 606, 607, 608, 610, 611}
 
--- Main
function main()
  playerMadeProgress(1000)
  if isSampLoaded() then return end
  local incar = false
  while true do
    wait(0)
    if isPlayerPlaying(PLAYER_HANDLE) then
      if doesCharExist(PLAYER_PED) and not isCharDead(PLAYER_PED) then
        if isCharInAnyCar(PLAYER_PED) and not incar then
          on_player_got_into_vehicle(storeCarCharIsInNoSave(PLAYER_PED))
          incar = true
        elseif incar then
          incar = false
        end
      end
    end
  end
end
 
function on_player_got_into_vehicle(veh)
  local model = getCarModel(veh)
  if list_find(blacklist, model) then
    return
  end
  if not list_find(collected_vehicles, model) then
    table.insert(collected_vehicles, model)
    local total = 212 - #blacklist
    local coll = #collected_vehicles
    setGxtEntry('_NEWVEH', string.format('~w~New vehicle~n~~y~%d~w~/~y~%d', coll, total))
    printBig('_NEWVEH', 100, 2)
    if coll == total then
      setGxtEntry('CVBONUS', 'All vehicles collected!~n~~w~$20000~n~Respect +')
      printBigQ('CVBONUS', 500, 1)
      awardPlayerMissionRespect(100)
      givePlayerMoney(PLAYER_HANDLE, 20000)
      playMissionPassedTune(2)
    elseif select(2, math.modf(coll / 20)) == 0 then
      setGxtEntry('CVBONUS', string.format('%d of %d vehicles collected!~n~~w~Respect +', coll, total))
      printBigQ('CVBONUS', 100, 1)
      awardPlayerMissionRespect(5)
    end
  end
end
 
--- Events
function onStartNewGame(mpack)
  collected_vehicles = {}
end
 
function onLoadGame(data)
  data = data or {}
  collected_vehicles = data.vehicles or {}
end
 
function onSaveGame(data)
  return {vehicles = collected_vehicles}
end
 
 
--- Functions
function list_find(list, value)
  for i,v in ipairs(list) do
    if v == value then return i end
  end
  return nil
end