• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Help me with my script please?!?

Skylinx

Game Programmer
Joined
Nov 26, 2008
Messages
399
Reaction score
15
Location
TORONTO, CANADA
[10/12/2008 19:30:31] Warning: [Event::loadScript] Can not load script. data/creaturescripts/scripts/firstitems.lua
[10/12/2008 19:30:31] data/creaturescripts/scripts/firstitems.lua:16: 'end' expected (to close 'if' at line 12) near 'else'

Why's it friggin saying that? I've tried putting what it says, and idk wtf is wrong!
Can someone please my firstitems.lua script to a correct format?
PHP:
local firstItems =
{
	2050,
	2382
}

function onLogin(cid)
	if getPlayerStorageValue(cid, 30001) == -1 then
		for i = 1, table.maxn(firstItems) do
			doPlayerAddItem(cid, firstItems[i], 1)
		end
		if getPlayerSex(cid) == 0 then
			doPlayerAddItem(cid, 2651, 1)
		else
			doPlayerAddItem(cid, 2650, 1)
		else
			doPlayerAddItem(cid, 2648, 1)
		else
			doPlayerAddItem(cid, 2458, 1)
		else
			doPlayerAddItem(cid, 2643, 1)
		else
			doPlayerAddItem(cid, 2398, 1)
		end
		end
		local bag = doPlayerAddItem(cid, 1987, 1)
                doAddContainerItem(bag, 2666, 3)
		doAddContainerItem(bag, 2190, 1)
		doAddContainerItem(bag, 2389, 50)
		doAddContainerItem(bag, 2182, 1)
		doAddContainerItem(bag, 2160, 1)
		doAddContainerItem(bag, 2367, 1)
		doAddContainerItem(bag, 2428, 1)

		setPlayerStorageValue(cid, 30001, 1)
	end
 	return TRUE
end

I made the script my self, but I dont understand what's wrong? o_o
 
You cannot use several else's after eachother like that as it wouldn't understand when it should give that certain item to someone.
PHP:
local firstItems =
{
    2050,
    2382
}

function onLogin(cid)
    if getPlayerStorageValue(cid, 30001) == -1 then
        for i = 1, table.maxn(firstItems) do
            doPlayerAddItem(cid, firstItems[i], 1)
        end
        if getPlayerSex(cid) == 0 then
        -- FEMALES
            doPlayerAddItem(cid, 2651, 1)
        elseif getPlayerSex(cid) == 1 then
            -- MALES
            doPlayerAddItem(cid, 2650, 1)
        elseif isSorcerer(cid) then
            -- SORCERERS
            doPlayerAddItem(cid, 2648, 1)
        elseif isDruid(cid) then
            -- DRUIDS
            doPlayerAddItem(cid, 2458, 1)
        elseif isPaladin(cid) then
            -- PALADINS
            doPlayerAddItem(cid, 2643, 1)
        else
            -- REST OF VOCATIONS
            doPlayerAddItem(cid, 2398, 1)
        end
        local bag = doPlayerAddItem(cid, 1987, 1)
        doAddContainerItem(bag, 2666, 3)
        doAddContainerItem(bag, 2190, 1)
        doAddContainerItem(bag, 2389, 50)
        doAddContainerItem(bag, 2182, 1)
        doAddContainerItem(bag, 2160, 1)
        doAddContainerItem(bag, 2367, 1)
        doAddContainerItem(bag, 2428, 1)

        setPlayerStorageValue(cid, 30001, 1)
    end
    return TRUE
end
 
You cannot use several else's after eachother like that as it wouldn't understand when it should give that certain item to someone.
PHP:
local firstItems =
{
    2050,
    2382
}

function onLogin(cid)
    if getPlayerStorageValue(cid, 30001) == -1 then
        for i = 1, table.maxn(firstItems) do
            doPlayerAddItem(cid, firstItems[i], 1)
        end
        if getPlayerSex(cid) == 0 then
        -- FEMALES
            doPlayerAddItem(cid, 2651, 1)
        elseif getPlayerSex(cid) == 1 then
            -- MALES
            doPlayerAddItem(cid, 2650, 1)
        elseif isSorcerer(cid) then
            -- SORCERERS
            doPlayerAddItem(cid, 2648, 1)
        elseif isDruid(cid) then
            -- DRUIDS
            doPlayerAddItem(cid, 2458, 1)
        elseif isPaladin(cid) then
            -- PALADINS
            doPlayerAddItem(cid, 2643, 1)
        else
            -- REST OF VOCATIONS
            doPlayerAddItem(cid, 2398, 1)
        end
        local bag = doPlayerAddItem(cid, 1987, 1)
        doAddContainerItem(bag, 2666, 3)
        doAddContainerItem(bag, 2190, 1)
        doAddContainerItem(bag, 2389, 50)
        doAddContainerItem(bag, 2182, 1)
        doAddContainerItem(bag, 2160, 1)
        doAddContainerItem(bag, 2367, 1)
        doAddContainerItem(bag, 2428, 1)

        setPlayerStorageValue(cid, 30001, 1)
    end
    return TRUE
end

I think it should be something like this:
Code:
local firstItems =
{
    2050,
    2382
}

function onLogin(cid)
    if getPlayerStorageValue(cid, 30001) == -1 then
        for i = 1, table.maxn(firstItems) do
            doPlayerAddItem(cid, firstItems[i], 1)
        end
        if getPlayerSex(cid) == 0 then
        -- FEMALES
            doPlayerAddItem(cid, 2651, 1)
        elseif getPlayerSex(cid) == 1 then
            -- MALES
            doPlayerAddItem(cid, 2650, 1)
	        if isSorcerer(cid) then
				-- SORCERERS
				doPlayerAddItem(cid, 2648, 1)
			elseif isDruid(cid) then
				-- DRUIDS
				doPlayerAddItem(cid, 2458, 1)
			elseif isPaladin(cid) then
				-- PALADINS
				doPlayerAddItem(cid, 2643, 1)
			else
				-- REST OF VOCATIONS
				doPlayerAddItem(cid, 2398, 1)
			end
		end	
        local bag = doPlayerAddItem(cid, 1987, 1)
        doAddContainerItem(bag, 2666, 3)
        doAddContainerItem(bag, 2190, 1)
        doAddContainerItem(bag, 2389, 50)
        doAddContainerItem(bag, 2182, 1)
        doAddContainerItem(bag, 2160, 1)
        doAddContainerItem(bag, 2367, 1)
        doAddContainerItem(bag, 2428, 1)

        setPlayerStorageValue(cid, 30001, 1)
    end
    return TRUE
end

You code checks if its a male/female/voc so he dont know what to do if its male+ have a voc I guess.
 
Yes I know, what I did was basically teaching him how to use if/elseif/else statements. : )
 
Back
Top