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

Lua One of my first scripts, please help me.

Synergy

New Member
Joined
Nov 24, 2011
Messages
334
Reaction score
0
Alright so I'm learning how to script and I got this to work before, but it was really simple then and now I want it to look like this but it's not working.

Whats wrong with this script?
And try to teach me how to fix it.


Code:
function onSay(cid, words, param)
	if getPlayerLevel(cid) >= 8 and getPlayerVocation(cid) then
               doPlayerSetVocation(cid, 1)
	       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations! You are now a wizard.")
               end
               else
               doPlayerSendCancel(cid, "You're not ready yet.") 
               else
               doPlayerSendCancel(cid, "You already have a vocation.")           	
               return true
              end
             return false
           end


Errors:

"end" expected near something..
 
LUA:
function onSay(cid, words, param) 
		if getPlayerLevel(cid) >= 8 and getPlayerVocation(cid) then
			if getPlayerPromotionLevel(cid) == 1 then
				doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid)+1)
				doSendMagicEffect(getPlayerPosition(cid), 30)
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations! You are now a wizard")
			else
			doPlayerSendCancel(cid, "You are already have a vocation.")
			end
	return true
end
 
LUA:
function onSay(cid, words, param)
    if getPlayerLevel(cid) >= 8 and getPlayerVocation(cid) == 0 then -- here we have to check if the player has a vocation.
        doPlayerSetVocation(cid, 1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations! You are now a wizard.")
    --end This "end: is not needed here
    elseif getPlayerLevel(cid) < 8 then --we use elseif to check another statement, here we check if the player is les then level 8.
        doPlayerSendCancel(cid, "You're not ready yet.") 
    else
        doPlayerSendCancel(cid, "You already have a vocation.")                  
    --return true  this is not neede here.
    end
return true -- this was changed to true, no actual need to return false.
end

Read the comments in the script, they are after the '--'(this is how you comment inside a script.).
 
LUA:
function onSay(cid, words, param)
    if getPlayerLevel(cid) >= 8 and getPlayerVocation(cid) == 0 then -- here we have to check if the player has a vocation.
        doPlayerSetVocation(cid, 1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations! You are now a wizard.")
    --end This "end: is not needed here
    elseif getPlayerLevel(cid) < 8 then --we use elseif to check another statement, here we check if the player is les then level 8.
        doPlayerSendCancel(cid, "You're not ready yet.") 
    else
        doPlayerSendCancel(cid, "You already have a vocation.")                  
    --return true  this is not neede here.
    end
return true -- this was changed to true, no actual need to return false.
end

Read the comments in the script, they are after the '--'(this is how you comment inside a script.).




Alright! Thanks, taught me a couple of things.


Next thing, I changed the message to popupfyi.

This is how it looks now:
Code:
function onSay(cid, words, param)
    if getPlayerLevel(cid) >= 8 and getPlayerVocation(cid) == 0 then
        doPlayerSetVocation(cid, 1)
        doPlayerPopupFYI(cid, Congratulations, You are now a wizard.\nYou can now perform magical abilities.\nWizards can wield powerful wands as weapons.\nWands can be bought at magic shops.\nGood luck.)
    elseif getPlayerLevel(cid) < 8 then
        doPlayerSendCancel(cid, "You're not ready yet.") 
    else
        doPlayerSendCancel(cid, "You already have a vocation.")                  
    end
return true
end



And this is my error:


Code:
:4: '>' expected near 'are'

Whats the problem now?
 
Code:
function onSay(cid, words, param)
    if getPlayerLevel(cid) >= 8 and getPlayerVocation(cid) == 0 then
        doPlayerSetVocation(cid, 1)
        doPlayerPopupFYI(cid, "Congratulations, You are now a wizard.")
    elseif getPlayerLevel(cid) < 8 then
        doPlayerSendCancel(cid, "You're not ready yet.") 
    else
        doPlayerSendCancel(cid, "You already have a vocation.")                  
    end
return true
end
 
Alright! Thanks, taught me a couple of things.


Next thing, I changed the message to popupfyi.

This is how it looks now:
Code:
function onSay(cid, words, param)
    if getPlayerLevel(cid) >= 8 and getPlayerVocation(cid) == 0 then
        doPlayerSetVocation(cid, 1)
        doPlayerPopupFYI(cid, [COLOR="#FF0000"]"[/COLOR]Congratulations, You are now a wizard.\nYou can now perform magical abilities.\nWizards can wield powerful wands as weapons.\nWands can be bought at magic shops.\nGood luck.[COLOR="#FF0000"]"[/COLOR])
    elseif getPlayerLevel(cid) < 8 then
        doPlayerSendCancel(cid, "You're not ready yet.") 
    else
        doPlayerSendCancel(cid, "You already have a vocation.")                  
    end
return true
end



And this is my error:


Code:
:4: '>' expected near 'are'

Whats the problem now?
you forgot to wrap the message inside the ""(Quotation Marks)
 
Back
Top