Jump to content
  • 0

Question about LUA


Necro

Question

  • VIP

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
  • Answers 5
  • Created
  • Last Reply

Top Posters For This Question

Popular Days

Top Posters For This Question

5 answers to this question

Recommended Posts

  • 0
  • VIP

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
  • 0
  • VIP

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
  • 0

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • 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.