[Release] Apartment [MySQL & Async](08/17/2017)

thx for share guys :wink: you rock

#work on lalife

1 Like

on n3mtv script it seems to not work.

Maybe someone can help?

Getting this error when opening the apartmenet menu:

im trying to use the MySQL Version of it:


Thank you very much

1 Like

The withdraw dirty money doesn’t work for me, i use LaLife ressource. Someone can help me ? Just this doesn’t work. @Madriax

Garagem system pleaseee :D, with mod save.

1 Like

CoucbDB pleass? <3 @Madriax

I’m getting the same error, also using MySQL.

Hate to be a pain if you’ve already uploaded it, but have you finished your version of CouchDB 2?

Async version working perfect, except for the depositing/retrieving of money. Thanks for releasing this I’m looking forward to future updates.

try to replace this event for fix dirty money cash

RegisterServerEvent("apart:takedirtycash")
AddEventHandler('apart:takedirtycash', function(cash, apart)
  TriggerEvent('es:getPlayerFromId', source, function(user)
    local player = user.identifier
    local money = 0
    if mode == "Async" then
      MySQL.Async.fetchAll("SELECT dirtymoney FROM user_appartement WHERE name = @nom", {['@nom'] = apart}, function (result)
          if (result) then
            money = result[1].dirtymoney
            if (tonumber(cash) <= tonumber(money) and tonumber(cash) > 0) then
              user:addDMoney((cash))
              local newmoney = money - cash
              MySQL.Async.execute("UPDATE user_appartement SET `dirtymoney`=@cash WHERE name = @nom",{['@cash'] = newmoney, ['@nom'] = apart}, function(data)
              end)
            else
              -- TriggerClientEvent("es_freeroam:notify", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --(FOR FREEROAM)
              TriggerClientEvent("citizenv:notif", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --WITH LALIFE SCRIPTS
            end
          end
      end)
    elseif mode == "MySQL" then
      local executed_query = MySQL:executeQuery("SELECT dirtymoney FROM user_appartement WHERE name = @nom", {['@nom'] = apart})
      local result = MySQL:getResults(executed_query, {'dirtymoney'})
      if (result) then
        money = result[1].dirtymoney
        if (tonumber(cash) <= tonumber(money) and tonumber(cash) > 0) then
          user:addDMoney((cash))
          local newmoney = money - cash
          MySQL:executeQuery("UPDATE user_appartement SET `dirtymoney`=@cash WHERE name = @nom",{['@cash'] = newmoney, ['@nom'] = apart})
        else
          -- TriggerClientEvent("es_freeroam:notify", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --(FOR FREEROAM)
          TriggerClientEvent("citizenv:notif", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --WITH LALIFE SCRIPTS
        end
      end
    end

    TriggerClientEvent('apart:getCash', source, money, dirtymoney)
  end)
end)

Thank you it works :smile:

1 Like

thx! but dirtymoney and so doesn’t work, but we can now buy a house

deposit dirty money no works

RegisterServerEvent("apart:depositdirtycash")
AddEventHandler('apart:depositdirtycash', function(cash, apart)
  TriggerEvent('es:getPlayerFromId', source, function(user)
    local player = user.identifier
    local money = 0
    if (tonumber(user:getDMoney()) >= tonumber(cash) and tonumber(cash) > 0) then
      if mode == "Async" then
        MySQL.Async.fetchAll("SELECT dirtymoney FROM user_appartement WHERE name = @Nom", {['@Nom'] = apart}, function (result)
            if (result) then
              money = result[1].dirtymoney
              user:removeDMoney((cash))
              local newmoney = money + cash
              MySQL.Async.execute("UPDATE user_appartement SET `dirtymoney`=@cash WHERE name = @Nom",{['@cash'] = newmoney, ['@Nom'] = apart}, function(data)
              end)
            end
        end)
      elseif mode == "MySQL" then
        local executed_query = MySQL:executeQuery("SELECT dirtymoney FROM user_appartement WHERE name = @Nom", {['@Nom'] = apart})
        local result = MySQL:getResults(executed_query, {'dirtymoney'})
        if (result) then
          money = result[1].dirtymoney
          user:removeDMoney((cash))
          local newmoney = money + cash
          MySQL:executeQuery("UPDATE user_appartement SET `dirtymoney`=@cash WHERE name = @Nom",{['@cash'] = newmoney, ['@Nom'] = apart})
        end
      end

      TriggerClientEvent('apart:getCash', source, money, dirtymoney)
    else
       else
      -- TriggerClientEvent("es_freeroam:notify", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --(FOR FREEROAM)
      TriggerClientEvent("citizenv:notify", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --WITH LALIFE SCRIPTS
    end
  end)
end)

Try this.

The Blips is not nice^^.
You can Change whit ah isBuy = 1 set Blip 40 else blip 375 or so^^

It would be nice if someone, anyone could make this work couchdb.

How we can deposit cash or dirty money i’m not finding menu ? I looked at my script , everything seems to be fine…

Edit : I found the menu…for a newbie it should be known that it was direct to the elevator… But my script to deposit clean and dirty money doesn’t work .

watch my previous coms

Just to be sure , my file to modify is the client appartment ? . And the only coms that I found about you is to takedirtycash not deposit … doesn’t seem to be difficult to modify script line .

in apart_serveur change registerevent takedirtycash in my coms for fix take dirtycash
and coms @Hawk_bs for fix deposit dirtycash

When I copy those lines , I get error creating script environment for resource apartments : Unexpected token ‘else’, ‘end’ expected

Her is my script :

RegisterServerEvent("apart:depositcash")
AddEventHandler('apart:depositcash', function(cash, apart)
  TriggerEvent('es:getPlayerFromId', source, function(user)
    local player = user.identifier
    local money = 0
    if (tonumber(user:getMoney()) >= tonumber(cash) and tonumber(cash) > 0) then
      if mode == "Async" then
        MySQL.Async.fetchAll("SELECT money FROM user_appartement WHERE name = @Nom", {['@Nom'] = apart}, function (result)
            if (result) then
              money = result[1].money
              user:removeMoney((cash))
              local newmoney = money + cash
              MySQL.Async.execute("UPDATE user_appartement SET `money`=@cash WHERE name = @Nom",{['@cash'] = newmoney, ['@Nom'] = apart}, function(data)
              end)
            end
        end)
      elseif mode == "MySQL" then
        local executed_query = MySQL:executeQuery("SELECT money FROM user_appartement WHERE name = @Nom", {['@Nom'] = apart})
        local result = MySQL:getResults(executed_query, {'money'})
        if (result) then
          money = result[1].money
          user:removeMoney((cash))
          local newmoney = money + cash
          MySQL:executeQuery("UPDATE user_appartement SET `money`=@cash WHERE name = @Nom",{['@cash'] = newmoney, ['@Nom'] = apart})
        end
      end

      TriggerClientEvent('apart:getCash', source, money, money)
    else
       else
      -- TriggerClientEvent("es_freeroam:notify", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --(FOR FREEROAM)
      TriggerClientEvent("citizenv:notify", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --WITH LALIFE SCRIPTS
    end
  end)
end)

RegisterServerEvent("apart:depositdirtycash")
AddEventHandler('apart:depositdirtycash', function(cash, apart)
  TriggerEvent('es:getPlayerFromId', source, function(user)
    local player = user.identifier
    local money = 0
    if (tonumber(user:getDMoney()) >= tonumber(cash) and tonumber(cash) > 0) then
      if mode == "Async" then
        MySQL.Async.fetchAll("SELECT dirtymoney FROM user_appartement WHERE name = @Nom", {['@Nom'] = apart}, function (result)
            if (result) then
              money = result[1].dirtymoney
              user:removeDMoney((cash))
              local newmoney = money + cash
              MySQL.Async.execute("UPDATE user_appartement SET `dirtymoney`=@cash WHERE name = @Nom",{['@cash'] = newmoney, ['@Nom'] = apart}, function(data)
              end)
            end
        end)
      elseif mode == "MySQL" then
        local executed_query = MySQL:executeQuery("SELECT dirtymoney FROM user_appartement WHERE name = @Nom", {['@Nom'] = apart})
        local result = MySQL:getResults(executed_query, {'dirtymoney'})
        if (result) then
          money = result[1].dirtymoney
          user:removeDMoney((cash))
          local newmoney = money + cash
          MySQL:executeQuery("UPDATE user_appartement SET `dirtymoney`=@cash WHERE name = @Nom",{['@cash'] = newmoney, ['@Nom'] = apart})
        end
      end

      TriggerClientEvent('apart:getCash', source, money, dirtymoney)
    else
       else
      -- TriggerClientEvent("es_freeroam:notify", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --(FOR FREEROAM)
      TriggerClientEvent("citizenv:notify", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --WITH LALIFE SCRIPTS
    end
  end)
end)

RegisterServerEvent("apart:takecash")
AddEventHandler('apart:takecash', function(cash, apart)
  TriggerEvent('es:getPlayerFromId', source, function(user)
    local player = user.identifier
    local money = 0
    if mode == "Async" then
      MySQL.Async.fetchAll("SELECT money FROM user_appartement WHERE name = @nom", {['@nom'] = apart}, function (result)
          if (result) then
            money = result[1].money
            if (tonumber(cash) <= tonumber(money) and tonumber(cash) > 0) then
              user:addMoney((cash))
              local newmoney = money - cash
              MySQL.Async.execute("UPDATE user_appartement SET `money`=@cash WHERE name = @nom",{['@cash'] = newmoney, ['@nom'] = apart}, function(data)
              end)
            else
              -- TriggerClientEvent("es_freeroam:notify", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --(FOR FREEROAM)
              TriggerClientEvent("citizenv:notif", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --WITH LALIFE SCRIPTS
            end
          end
      end)
    elseif mode == "MySQL" then
      local executed_query = MySQL:executeQuery("SELECT money FROM user_appartement WHERE name = @nom", {['@nom'] = apart})
      local result = MySQL:getResults(executed_query, {'money'})
      if (result) then
        money = result[1].money
        if (tonumber(cash) <= tonumber(money) and tonumber(cash) > 0) then
          user:addMoney((cash))
          local newmoney = money - cash
          MySQL:executeQuery("UPDATE user_appartement SET `money`=@cash WHERE name = @nom",{['@cash'] = newmoney, ['@nom'] = apart})
        else
          -- TriggerClientEvent("es_freeroam:notify", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --(FOR FREEROAM)
          TriggerClientEvent("citizenv:notif", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --WITH LALIFE SCRIPTS
        end
      end
    end

    TriggerClientEvent('apart:getCash', source, money, money)
  end)
end)

RegisterServerEvent("apart:takedirtycash")
AddEventHandler('apart:takedirtycash', function(cash, apart)
  TriggerEvent('es:getPlayerFromId', source, function(user)
    local player = user.identifier
    local money = 0
    if mode == "Async" then
      MySQL.Async.fetchAll("SELECT dirtymoney FROM user_appartement WHERE name = @nom", {['@nom'] = apart}, function (result)
          if (result) then
            money = result[1].dirtymoney
            if (tonumber(cash) <= tonumber(money) and tonumber(cash) > 0) then
              user:addDMoney((cash))
              local newmoney = money - cash
              MySQL.Async.execute("UPDATE user_appartement SET `dirtymoney`=@cash WHERE name = @nom",{['@cash'] = newmoney, ['@nom'] = apart}, function(data)
              end)
            else
              -- TriggerClientEvent("es_freeroam:notify", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --(FOR FREEROAM)
              TriggerClientEvent("citizenv:notif", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --WITH LALIFE SCRIPTS
            end
          end
      end)
    elseif mode == "MySQL" then
      local executed_query = MySQL:executeQuery("SELECT dirtymoney FROM user_appartement WHERE name = @nom", {['@nom'] = apart})
      local result = MySQL:getResults(executed_query, {'dirtymoney'})
      if (result) then
        money = result[1].dirtymoney
        if (tonumber(cash) <= tonumber(money) and tonumber(cash) > 0) then
          user:addDMoney((cash))
          local newmoney = money - cash
          MySQL:executeQuery("UPDATE user_appartement SET `dirtymoney`=@cash WHERE name = @nom",{['@cash'] = newmoney, ['@nom'] = apart})
        else
          -- TriggerClientEvent("es_freeroam:notify", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --(FOR FREEROAM)
          TriggerClientEvent("citizenv:notif", source, "CHAR_SIMEON", 1, "Stephane", false, txt[lang]['nocash']) --WITH LALIFE SCRIPTS
        end
      end
    end

    TriggerClientEvent('apart:getCash', source, money, dirtymoney)
  end)
end)

Edit by Havoc: Please use code tags for code… Thanks