• 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 Not work

esker

New Member
Joined
Oct 11, 2009
Messages
17
Reaction score
0
hello
i need a script to when you kill a monster execute this
doPlayerSetStorageValue(cid, 65000, getPlayerStorageValue(cid, 65000) + 1)

I tried it

function onDeath(cid, lastHitKiller, mostDamageKiller)
doPlayerSetStorageValue(mostDamageKiller, 65001, getPlayerStorageValue(cid, 65001) + 1)
end
return TRUE
<event type="death" name="troll" event="script" value="troll.lua"/>
did not work
the error :
[Error - CreatureScript Interface]
data/creaturescripts/scripts/troll.lua:onDeath
Description:
(luaDoCreatureSetStorage) Creature not found

pls help me
 
wrong, use on kill,
try this:
Code:
function onKill(cid, target, lastHit)
	if getCreatureName(target) == "Troll" then
		if lastHit == cid then
			return doPlayerSetStorageValue(cid, 65001, getPlayerStorageValue(cid, 65001)+1)	
		end
	return true
	end
end
Don't really know if it will work
 
why lasthit? ;$
supposing that at onKill event is the one who attacks with last hit and kills the creatur
LUA:
local storage = 65001

function onKill(cid, target, lastHit)
    if isPlayer(cid) and isMonster(target) and getCreatureName(string.lower(target)) == 'troll' then
        doCreatureSetStorage(cid, storage, getCreatureStorage(cid, storage)+1)
    end
return true
end




 
it's
LUA:
<event type="kill" name="troll" event="script"  value="troll.lua"/>

and login.lua
LUA:
 registerCreatureEvent(cid,'troll')
this
<script>
<event name="troll"/>
</script>
is not needed
 
20:17 Elemental Wizard: Current 0 troll killed, you need to kill 100.

has no errors in console .....


i have this script in a lever
function onUse(cid, item, fromPosition, itemEx, toPosition)
doPlayerSetStorageValue(cid, 65000, getPlayerStorageValue(cid, 65000) + 1)

end
he work
 
....
storage?

LUA:
local storage =  65000

function onKill(cid, target, lastHit)
    if isPlayer(cid) and isMonster(target) and getCreatureName(string.lower(target)) == 'troll' then
        doCreatureSetStorage(cid, storage, getCreatureStorage(cid, storage)+1)
    end
return true
end
 
Eeeh! Why do you need that lever for?? To get how many creatures that player
has killed?? because for what I can see that script is adding +1 to the
storage every time you use it!
 
in the creaturescript change
doCreatureSetStorage for doPlayerSetStorageValue and
getCreatureStorage for getPlayerStorageValue
does that make a diff? ;x

PHP:
    //getCreatureStorage(uid, key)
    lua_register(m_luaState, "getCreatureStorage", LuaScriptInterface::luaGetCreatureStorage);

    //doCreatureSetStorage(uid, key, value)
    lua_register(m_luaState, "doCreatureSetStorage", LuaScriptInterface::luaDoCreatureSetStorage);
 
Back
Top