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

need help on summon script.

Ecstacy

Mothafuckaaa
Joined
Dec 26, 2008
Messages
3,836
Reaction score
108
Location
The Netherlands
Hey,

I'm experimenting with local t[~],
but it keeps telling me it can't find the monster name.

I don't want the script to be shrinked, but I want to know what I did wrong.

Code:
[12/05/2010 19:01:37] [Error - Action Interface] 
[12/05/2010 19:01:37] data/actions/scripts/other/pokeball.lua:onUse
[12/05/2010 19:01:37] Description: 
[12/05/2010 19:01:37] (luaDoSummonMonster) Creature not found

LUA:
local storage = 50715
local t = {
	[1] = {name='red butterfly'},
	[2] = {name='dragon'},
	[3] = {name='squirrel'}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerStorageValue(cid, storage) < 1 then
		local pick = math.random(1,3)
		doSummonMonster(t[pick].name, getThingPos(cid))
		doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE, 'You have summoned a random monster to help you!')
		doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
		return doRemoveItem(item.uid)
	else
		doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE, 'There has been some error, try to say !resetstorage and see if it works')
		doSendMagicEffect(getThingPos(cid), 2)
	end
	return TRUE
end

Thanks in advance,
unknown666
 
Code:
[LEFT]  [COLOR=#b1b100]local[/COLOR] storage [COLOR=#66cc66]=[/COLOR] 50715
 [COLOR=#b1b100]local[/COLOR] t [COLOR=#66cc66]=[/COLOR] [COLOR=#66cc66]{[/COLOR]
        [COLOR=#66cc66][[/COLOR][COLOR=#cc66cc]1[/COLOR][COLOR=#66cc66]][/COLOR] [COLOR=#66cc66]=[/COLOR] [COLOR=#66cc66]{[/COLOR]name[COLOR=#66cc66]=[/COLOR][COLOR=#ff0000]'red butterfly'[/COLOR][COLOR=#66cc66]}[/COLOR],
        [COLOR=#66cc66][[/COLOR][COLOR=#cc66cc]2[/COLOR][COLOR=#66cc66]][/COLOR] [COLOR=#66cc66]=[/COLOR] [COLOR=#66cc66]{[/COLOR]name[COLOR=#66cc66]=[/COLOR][COLOR=#ff0000]'dragon'[/COLOR][COLOR=#66cc66]}[/COLOR],
        [COLOR=#66cc66][[/COLOR][COLOR=#cc66cc]3[/COLOR][COLOR=#66cc66]][/COLOR] [COLOR=#66cc66]=[/COLOR] [COLOR=#66cc66]{[/COLOR]name[COLOR=#66cc66]=[/COLOR][COLOR=#ff0000]'squirrel'[/COLOR][COLOR=#66cc66]}[/COLOR]
 [COLOR=#66cc66]}[/COLOR]
 
 [COLOR=#b1b100]function[/COLOR] onUse[COLOR=#66cc66]([/COLOR]cid, item, fromPosition, itemEx, toPosition[COLOR=#66cc66])[/COLOR]
        [COLOR=#b1b100]if[/COLOR] getPlayerStorageValue[COLOR=#66cc66]([/COLOR]cid, storage[COLOR=#66cc66])[/COLOR] [COLOR=#66cc66]<[/COLOR] 1 [COLOR=#b1b100]then[/COLOR]
                [COLOR=#b1b100]local[/COLOR] pick [COLOR=#66cc66]=[/COLOR] [COLOR=#b1b100]math.random[/COLOR][COLOR=#66cc66]([/COLOR][COLOR=#cc66cc]1[/COLOR],[COLOR=#cc66cc]3[/COLOR][COLOR=#66cc66])[/COLOR]
                doSummonMonster[COLOR=#66cc66]([/COLOR]t[COLOR=#66cc66][[/COLOR]pick[COLOR=#66cc66]][/COLOR].name, [COLOR=Blue]getCreaturePosition[/COLOR][COLOR=#66cc66]([/COLOR]cid[COLOR=#66cc66])[/COLOR][COLOR=#66cc66])[/COLOR]
                doPlayerSendTextMessage[COLOR=#66cc66]([/COLOR]cid,MESSAGE_STATUS_CONSOLE_BLUE, [COLOR=#ff0000]'You have summoned a random monster to help you!'[/COLOR][COLOR=#66cc66])[/COLOR]
                doSendMagicEffect[COLOR=#66cc66]([/COLOR][COLOR=Blue]getCreaturePosition[/COLOR][COLOR=#66cc66]([/COLOR]cid[COLOR=#66cc66])[/COLOR], CONST_ME_GIFT_WRAPS[COLOR=#66cc66])[/COLOR]
                [COLOR=#b1b100]return[/COLOR] doRemoveItem[COLOR=#66cc66]([/COLOR]item.uid[COLOR=#66cc66])[/COLOR]
        [COLOR=#b1b100]else[/COLOR]
                doPlayerSendTextMessage[COLOR=#66cc66]([/COLOR]cid,MESSAGE_STATUS_CONSOLE_BLUE, [COLOR=#ff0000]'There has been some error, try to say !resetstorage and see if it works'[/COLOR][COLOR=#66cc66])[/COLOR]
                doSendMagicEffect[COLOR=#66cc66]([/COLOR][COLOR=Blue]getCreaturePosition[/COLOR][COLOR=#66cc66]([/COLOR]cid[COLOR=#66cc66])[/COLOR], 2[COLOR=#66cc66])[/COLOR]
        [COLOR=#b1b100]end[/COLOR]
        [COLOR=#b1b100]return[/COLOR] TRUE
 [COLOR=#b1b100]end
[/COLOR][/LEFT]
marked the changed things blue (getCreaturePosition instead of getThingPos)
 
Code:
local storage = 50715
local t = {
        {"red butterfly"},
        {"dragon"},
        {"squirrel"},
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
        if getPlayerStorageValue(cid, storage) < 1 then
                local r = t[math.random(#t)]
                doSummonMonster(r, getCreaturePosition(cid))
                doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE, 'You have summoned a random monster to help you!')
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
                return doRemoveItem(item.uid)
        else
                doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE, 'There has been some error, try to say !resetstorage and see if it works')
                doSendMagicEffect(getCreaturePosition(cid), 2)
        end
        return TRUE
end
? :p
if it doesn't work, try change doSummonMonster(r, to doSummonMonster(r[1],
 
Back
Top