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

Creaturescript bug ?

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,855
Solutions
18
Reaction score
671
Sorry for language in lua but the script is using local polish words.

PHP:
function onKill(cid, target)

local config = 
{
        ["monster"] = "Orc",
        ["efekt"] = 120,
        ["losowe"] = 0,
        ["ilelosowanych"] = 0,
        ["monstercreate"] = "Orc Warrior"
}
local createmonster =
{
        [1] = "---",
        [2] = "---", 
        [3] = "---"
}
    
if isMonster(target) == true and getCreatureName(target) == config.monster then    
        if config.losowe == 1 then
            local rand = math.random(1,config.ilelosowanych)
            doSummonCreature(createmonster[rand], getThingPos(target))
            doSendMagicEffect(getThingPos(target),config.efekt)
        else
            doSummonCreature(config.monstercreate, getThingPos(target))
            doSendMagicEffect(getThingPos(target),config.efekt)
        end
end
return true
end

When 1 player kill Orc, the orc transform into Orc Warrior - Its ok !
When 2 players kill Orc, the orc transform into TWO Orc warrior's - Its fail
When 3 players kill Orc, the orc transform into THREE Orc warrior's - Its fail

Anyone can optimalize the creaturescript code so as to: one,two,three... players can kill Orc and the Orc will be transformed into Orc Warrior ?

Rep++ I needed fast :)
 
I believe it needs compilation, since the event handle is managed by each player, so if 100 players kills the same monster, it'll call the onKill script for each one of it handles.

Or you can use "globalstorage".
 
I don't get what you want to do with this script..
Only the first should summon a warrior or all or what doesnt work?
 
Try
LUA:
function onKill(cid, target)

local config = 
{
        ["monster"] = "Orc",
        ["efekt"] = 120,
        ["losowe"] = 0,
        ["ilelosowanych"] = 0,
        ["monstercreate"] = "Orc Warrior",
		status = getGlobalStorageValue(2246)
}
local createmonster =
{
        [1] = "---",
        [2] = "---", 
        [3] = "---"
}
if isMonster(target) == true and getCreatureName(target) == config.monster then    
        if config.status == -1 then
		setGlobalStorageValue(2246, 1)
            doSummonCreature(config.monstercreate, getThingPos(target))
            doSendMagicEffect(getThingPos(target),config.efekt)
        end
elseif isMonster(target) == true and getCreatureName(target) == config.monstercreate then
	if config.status = 1 then
			setGlobalStorageValue(2246, -1)
end
return true
end
 
Error:
[11/08/2010 14:23:47] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/mob-1.lua)
[11/08/2010 14:23:47] data/creaturescripts/scripts/mob-1.lua:25: 'then' expected near '='

Please repair it for me if it dont work maybe anyone can tell me how i can add to C++ this thing ?
 
Last edited:
Try this.
Code:
local config = 
{
        ["monster"] = "Orc",
        ["efekt"] = 120,
        ["losowe"] = false,
        ["ilelosowanych"] = 0,
        ["monstercreate"] = "Orc Warrior"
}
local createmonster =
{
        [1] = "---",
        [2] = "---", 
        [3] = "---"
}

local function freeStorage(s)
	setGlobalStorageValue(s, -1)
end
    
function onKill(cid, target)
	if not(isMonster(target) and getCreatureName(target) == config.monster and getGlobalStorageValue(target) < 1) then  
		return true
	end

	setGlobalStorageValue(target, target)
	addEvent(freeStorage, 5000, target)
	if config.losowe then
		doSummonCreature(createmonster[math.random(#createmonster)], getThingPos(target))
	else
		doSummonCreature(config.monstercreate, getThingPos(target))
	end
	doSendMagicEffect(getThingPos(target),config.efekt)
	return true
end
 
There was one = missing, sorry ^_^

LUA:
function onKill(cid, target)
 
local config = 
{
        ["monster"] = "Orc",
        ["efekt"] = 120,
        ["losowe"] = 0,
        ["ilelosowanych"] = 0,
        ["monstercreate"] = "Orc Warrior",
		status = getGlobalStorageValue(2246)
}
local createmonster =
{
        [1] = "---",
        [2] = "---", 
        [3] = "---"
}
if isMonster(target) == true and getCreatureName(target) == config.monster then    
        if config.status == -1 then
		setGlobalStorageValue(2246, 1)
            doSummonCreature(config.monstercreate, getThingPos(target))
            doSendMagicEffect(getThingPos(target),config.efekt)
        end
elseif isMonster(target) == true and getCreatureName(target) == config.monstercreate then
	if config.status == 1 then
			setGlobalStorageValue(2246, -1)
end
end
return true
end
 
Last edited:
Back
Top