• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

my lua advances

Stax

Learning Lua
Joined
Jul 12, 2010
Messages
19
Reaction score
0
Location
Puerto Rico
hello, i just started learning lua and though i would post my advances on scripting. if you know how i can improve dont mind telling me. i take critism, help anything that can make me a better scripter ,but please dont be harsh in your cristism like "you suck ass" or stuff like that^_^
heres my first script
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
          if (skill == SKILL_LEVEL and newLevel>oldLevel) then
                  if getPlayerLevel (cid) == 50 then
                      doPlayerSendTextMessage(cid,21,"Congratulations!")
           elseif getPlayerLevel (cid) < 50 then
                  doPlayerSendTextMessage(cid,21,"Hurry up and get level 50!")

           end
     end
end
special thanks to Quas for helping me with some lua stuff
 
Last edited:
First and foremost, work on your tabbing. A clean code is a happy code.

Lua:
function onAdvance(cid, skill, oldLevel, newLevel) 
	if (skill == SKILL_LEVEL and newLevel>oldLevel) then 
		if getPlayerLevel (cid) == 50 then 
			doPlayerSendTextMessage(cid,21,"Congratulations!") 
		elseif getPlayerLevel (cid) < 50 then 
			doPlayerSendTextMessage(cid,21,"Hurry up and get level 50!") 
		end 
	end 
end

btw you can use [ lua ] [/ lua ] tags. I didn't revise your script but tabbing makes it easier to see where the ends are at and what function/statement they belong to.
 
First and foremost, work on your tabbing. A clean code is a happy code.

Lua:
function onAdvance(cid, skill, oldLevel, newLevel) 
	if (skill == SKILL_LEVEL and newLevel>oldLevel) then 
		if getPlayerLevel (cid) == 50 then 
			doPlayerSendTextMessage(cid,21,"Congratulations!") 
		elseif getPlayerLevel (cid) < 50 then 
			doPlayerSendTextMessage(cid,21,"Hurry up and get level 50!") 
		end 
	end 
end

btw you can use [ lua ] [/ lua ] tags. I didn't revise your script but tabbing makes it easier to see where the ends are at and what function/statement they belong to.

thank you il use it nxt time
 
First and foremost, work on your tabbing. A clean code is a happy code.

true, true
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
    if skill == SKILL_LEVEL then
        if getPlayerLevel(cid) == 50 then
            doPlayerSendTextMessage(cid,21,'Congratulations!')
        elseif getPlayerLevel(cid) < 50 then
            doPlayerSendTextMessage(cid,21,'Hurry up and get level 50!')
        end
    end
    return true
end
too bad otland lua tags destroy the tabs
 
doesn't destroy them it just has a very wide width...instead of standard tab width (8whitespace?) its longer... ahwell.
 
i hopes it gets fixed in vubulletin update
along with new sql and xml tags
 
Yeah would be nice..anywho, responding to your visitor message Stax, I don't really have the time to explain how to tab and I'm not the best teacher, I've written a tutorial before but I have to see where I put it.
 
go through the request section and try to help people, its a win win situation.
 
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
    if skill == SKILL_LEVEL then
	local msg = 'Hurry up and get level 50!'
        if newLevel == 50 then
            msg = 'Congratulations!'
        end
    end
    return doPlayerSendTextMessage(cid, 21, msg)
end

Its not proofed though, if a player jumps to level 51 from 49 then it will skip the message..but for low level ots this shouldn't be possible? Anyway to combat that you would just need to set a storage value.
 
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
    if skill == SKILL_LEVEL then
	local msg = 'Hurry up and get level 50!'
        if newLevel == 50 then
            msg = 'Congratulations!'
        end
    end
    return doPlayerSendTextMessage(cid, 21, msg)
end

Its not proofed though, if a player jumps to level 51 from 49 then it will skip the message..but for low level ots this shouldn't be possible? Anyway to combat that you would just need to set a storage value.
If newLevel is higher than 50, you will get the message "Hurry up and get level 50!", so it's wrong.


Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
    if skill == SKILL_LEVEL and getPlayerStorageValue(cid, 1234) < 1 then
        if newLevel >= 50 then
            doPlayerSendTextMessage(cid, 21, 'Congratulations!')
            doPlayerSetStorageValue(cid, 1234, 1)
        else
            doPlayerSendTextMessage(cid, 21, 'Hurry up and get level 50!')
        end
    end
    return true
end
 
Yeah so? That's how he had it before, I was just remaking his script....
 
ok guys dont fight:$
new script
Lua:
local playerTown = getPlayerTown(cid)
          local playerPos = getCreaturePosition(cid)
             if(item.actionid == 2001 then
                 if playerTown == 1 then
                          doSendAnimatedText(playerPos, 'You may pass', TEXTCOLOR_ORANGE)
              elseif playerTown == 2 then
                     doSendAnimatedText(playerPos, 'You must be a residence to pass', TEXTCOLOR_ORANGE)
              end
end
i dont think it works though :/
 
Last edited:
He's just being a dick don't mind him.
ok.
_______________
new script
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
	if (skill_LEVEL and newLevel>oldLevel) then
		if getPlayerLevel(cid) == 50 then
			doAddContainerItem(2001, 2160,10)
	return TRUE
end
 
Back
Top