Forum

> > CS2D > Scripts > Tibia Level Req
Forums overviewCS2D overview Scripts overviewLog in to reply

English Tibia Level Req

4 replies
To the start Previous 1 Next To the start

old Tibia Level Req

sCy
User Off Offline

Quote
I want to make level req in tibia, to make certain that low levels doesnt get into dangerous areas.
Can you check it, it says something like "lua error: "end" expected to close "if" near to "elseif"."

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
NPCs[14].func = function(npc, id, words, state)
	if words == "hi" then
		NPCspeak(npc, "The toll is $10. Do you want to cross this bridge?")
		NPCspeak(npc, "You also have to be at least level 10.")
		PLAYERS[id].tmp.npcstate = {npc, 1}
	elseif contains(words, "bye") then
		NPCspeak(npc, "Not crossing?")
		PLAYERS[id].tmp.npcstate = nil
	elseif state == 1 then
		if contains(words, "yes") then
		if level(id >10) then
		else 
		NPCspeak(npc, "Your level isn't high enough!")
			if addmoney(id, -10) then
				message(id, "You have lost $10.", "255255255")
				parse("setpos " .. id .. " 2288 352")
			else
				NPCspeak(npc, "No money, no crossing.")
			end
		elseif contains(words, "no") then
			NPCspeak(npc, "Not crossing?")
			PLAYERS[id].tmp.npcstate = nil
			end
			end
		end
		end
	end
end
end

old Re: Tibia Level Req

EngiN33R
Moderator Off Offline

Quote
You have a load of extra ends:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
NPCs[14].func = function(npc, id, words, state)
     if words == "hi" then
          NPCspeak(npc, "The toll is $10. Do you want to cross this bridge?")
          NPCspeak(npc, "You also have to be at least level 10.")
          PLAYERS[id].tmp.npcstate = {npc, 1}
     elseif contains(words, "bye") then
          NPCspeak(npc, "Not crossing?")
          PLAYERS[id].tmp.npcstate = nil
     elseif state == 1 then
          if contains(words, "yes") then
          if level(id >10) then
          else
          NPCspeak(npc, "Your level isn't high enough!")
               if addmoney(id, -10) then
                    message(id, "You have lost $10.", "255255255")
                    parse("setpos " .. id .. " 2288 352")
               else
                    NPCspeak(npc, "No money, no crossing.")
               end
          elseif contains(words, "no") then
               NPCspeak(npc, "Not crossing?")
               PLAYERS[id].tmp.npcstate = nil
               end
          end
     end
end

But what is that 'level(id >10)' part about? I suggest you look at some other pieces of code that have level requirements, like equipment maybe.

old Re: Tibia Level Req

sCy
User Off Offline

Quote
Still the same error... Lua trolls me =O


theres the better version:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
NPCs[14].func = function(npc, id, words, state)
		if words == "hi" then
			NPCspeak(npc, "The toll is $10. Do you want to cross this bridge?")
			NPCspeak(npc, "You also have to be at least level 10.")
			PLAYERS[id].tmp.npcstate = {npc, 1}
		elseif contains(words, "bye") then
		NPCspeak(npc, "Not crossing?")
		PLAYERS[id].tmp.npcstate = nil
				elseif state == 1 then
				if contains(words, "yes") then
				if level.PLAYERS[id] > 10 then
					if addmoney(id, -10) then
					message(id, "You have lost $10.", "255255255")
					parse("setpos " .. id .. " 2288 352")
					else
					NPCspeak(npc, "No money, no crossing.")
					end
				else
				NPCspeak(npc, "Your level isn't high enough!")
					elseif contains(words, "no") then
					NPCspeak(npc, "Not crossing?")
					PLAYERS[id].tmp.npcstate = nil
end
end
end
end
end

old Re: Tibia Level Req

EngiN33R
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
NPCs[14].func = function(npc, id, words, state)
	if words == "hi" then
		NPCspeak(npc, "The toll is $10. Do you want to cross this bridge?")
		NPCspeak(npc, "You also have to be at least level 10.")
		PLAYERS[id].tmp.npcstate = {npc, 1}
	elseif contains(words, "bye") then
		NPCspeak(npc, "Not crossing?")
		PLAYERS[id].tmp.npcstate = nil
	elseif state == 1 then
		if contains(words, "yes") then
			if level.PLAYERS[id] > 10 then
				if addmoney(id, -10) then
					message(id, "You have lost $10.", "255255255")
					parse("setpos " .. id .. " 2288 352")
				else
					NPCspeak(npc, "No money, no crossing.")
				end
			else
				NPCspeak(npc, "Your level isn't high enough!")
			end
		elseif contains(words, "no") then
			NPCspeak(npc, "Not crossing?")
			PLAYERS[id].tmp.npcstate = nil
		end
	end
end

You seem to have put yet another extra end.

old Re: Tibia Level Req

sCy
User Off Offline

Quote
Works.
Also got the level hook working.

PLAYERS[id].Level < 10 was the right one.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview