Jump to content

Question about LUA


Recommended Posts

  • Premium

Hi, i try modified quest for Shop with the new currency but When i click on item in NPC shop it dont work and item cant buy. Sysser and syslog write me this: 

Nov 15 20:27:46 :: QUEST ScriptButton pid 4 idx 0
SYSERR: Nov 15 20:27:50 :: RunState: LUA_ERROR: [string "achievement_rivalia"]:2: attempt to concatenate local `coins' (a table value) WITH ERRORCODE 1
SYSERR: Nov 15 20:27:50 :: RunState: LUA_STATE: index 0 ref 3
SYSERR: Nov 15 20:27:50 :: WriteRunningStateToSyserr: LUA_ERROR: quest achievement_rivalia.start click

Quest look like:

quest achievement_rivalia begin
	state start begin
		----------------------------------------------------------------------------------------------------
		-- SKLEP                                                                                          --
		----------------------------------------------------------------------------------------------------
		when 20095.chat."Sklep" begin
			cmdchat("SetIsNpc")
			npc.open_shop(16)
			setskin(NOWINDOW)
			cmdchat("SetPrice 200|200|200|200|200|0|0|100|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0")
		end
		when login begin
            loop_timer("casovac", 10)
        end
     
        when casovac.timer begin
            local coins = mysql_query("SELECT coins from account.account WHERE id="..pc.get_account_id().." LIMIT 1;")
            cmdchat("setPP "..coins)
			cmdchat("SetQuestIndex "..q.getcurrentquestindex())
		end
		when button or info begin
			local items = {
				[0]={71124, 1, 200},
				[1]={71125, 1, 200},
				[2]={71126, 1, 200},
				[3]={71127, 1, 200},
				[4]={71128, 1, 200},
			}
			local slot = tonumber(achievement_rivalia.GetInput("GetInput"))
            local coins = mysql_query("SELECT coins from account.account WHERE id="..pc.get_account_id().." LIMIT 1;")
			if coins >= items[slot][3] then
				local nastavit_mince = mysql_query("UPDATE account.account SET coins ='"..(coins.coins[1]-items[slot][3]).."' WHERE name ='"..pc.get_account_id().."' LIMIT 1")
				cmdchat("setPP "..coins)
				pc.give_item2(items[slot][1], items[slot][2])
			else
				cmdchat("NieMamPP")
			end
		end
		function GetInput(value)
			cmdchat("GetInputStart")
			local ret = input(cmdchat(value))
			cmdchat("GetInputStop")
			return ret
		end
	end
end

Any idea how to fix it? Thanks

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Premium

Thanks for that, next is here: 

SYSERR: Nov 15 21:30:08 :: RunState: LUA_ERROR: [string "achievement_rivalia"]:10: attempt to compare number with table WITH ERRORCODE 1
SYSERR: Nov 15 21:30:08 :: RunState: LUA_STATE: index 0 ref 3
SYSERR: Nov 15 21:30:08 :: WriteRunningStateToSyserr: LUA_ERROR: quest achievement_rivalia.start click
Link to comment
Share on other sites

  • Premium

Wow now its work fine :D You are the best, just the last question how to modified this: 

local nastavit_mince = mysql_query("UPDATE account.account SET coins ='"..(coins.coins[1]-items[slot][3]).."' WHERE name ='"..pc.get_account_id().."' LIMIT 1")

Because system isnt subtract coins so i have still same count of coins..? :D

 

/Solved - WHERE name -> WHERE id

Link to comment
Share on other sites

Try that

quest achievement_rivalia begin
    state start begin
        ----------------------------------------------------------------------------------------------------
        -- SKLEP                                                                                          --
        ----------------------------------------------------------------------------------------------------
        when 20095.chat."Sklep" begin
            cmdchat("SetIsNpc")
            npc.open_shop(16)
            setskin(NOWINDOW)
            cmdchat("SetPrice 200|200|200|200|200|0|0|100|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0")
        end
        when login begin
            loop_timer("casovac", 10)
        end
      
        when casovac.timer begin
            local coins = mysql_query("SELECT coins from account.account WHERE id="..pc.get_account_id().." LIMIT 1;")
            cmdchat("setPP "..coins.coins[1])
            cmdchat("SetQuestIndex "..q.getcurrentquestindex())
        end
        when button or info begin
            local items = {
                [0]={71124, 1, 200},
                [1]={71125, 1, 200},
                [2]={71126, 1, 200},
                [3]={71127, 1, 200},
                [4]={71128, 1, 200},
            }
            local slot = tonumber(achievement_rivalia.GetInput("GetInput"))
            local coins = mysql_query("SELECT coins from account.account WHERE id="..pc.get_account_id().." LIMIT 1;")
            if tonumber(coins.coins[1]) >= items[slot][3] then
                local nastavit_mince = mysql_query("UPDATE account.account SET coins = coins - "..items[slot][3].." WHERE name ='"..pc.get_account_id().."' LIMIT 1")
                cmdchat("setPP "..coins.coins[1])
                pc.give_item2(items[slot][1], items[slot][2])
            else
                cmdchat("NieMamPP")
            end
        end
        function GetInput(value)
            cmdchat("GetInputStart")
            local ret = input(cmdchat(value))
            cmdchat("GetInputStop")
            return ret
        end
    end
end
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Similar Content

  • Activity

    1. 3

      Crystal Metinstone

    2. 3

      Feeding game source to LLM

    3. 113

      Ulthar SF V2 (TMP4 Base)

    4. 3

      Feeding game source to LLM

    5. 0

      Target Information System

    6. 3

      Feeding game source to LLM

    7. 2

      anti exp explanation pls

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.