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

[help] Kill monster > set storagevalue

Serginov

Onkonkoronkonk
Joined
Jun 28, 2008
Messages
1,321
Reaction score
18
Location
Sweden - Dalarna
I don't remember who made this script but I need help with it because it doesn't work for me..
Here it goes:
PHP:
function onKill(cid, target)
local monstername = "Ungreez" -- Put the Monster name in there which has to be defeated
	if (isPlayer(target) ~= TRUE) then
		if (getCreatureName(target) == monstername) then
			setPlayerStorageValue(cid,21902,1)
		else
			return FALSE
		end
	else
		return FALSE
	end
	return TRUE
end
and:
PHP:
	<event type="kill" name="Ungreez" script="ungreez.lua"/>

Yes, i have
PHP:
  <script>
	<event name="Ungreez"/>
</script>
in the monster file under </flags>


When I kill Ungreez I don't get the storagevalue.
So could someone help me with this script or make a new one?


Thanks in advance
 
remove this from monster.
<script>
<event name="Ungreez"/>
</script>


and there is a script:

PHP:
function onKill(cid, target) 
    if isPlayer(cid) == 1 and isCreature(target) == 1 then
        if getCreatureName(target) == "Ungreez" then
            setPlayerStorageValue(cid,21902,1) 
        end 
    end 
    return TRUE 
end
 
You shouldn't have to check if you killed the monster, the monster should have an ondeath, make the monster launch the script and make the ondeath in the event, more is not neccesary, then just make it add a storage value in the ondeath.

Example:
Code:
function onDeath(cid, corpse, killer)
	if getPlayerVocation(killer) >= 0 then
		if isPlayer(killer) == TRUE then
      		if getPlayerStorageValue(killer, 1203) == 0 then
				doPlayerSendTextMessage(killer,22,"You have started slaying hatchlings, continue to recieve a reward.")
			else
				doPlayerSendTextMessage(killer,22,"You have killed "..getPlayerStorageValue(killer, 1203).." hatchlings.")
			end
		setPlayerStorageValue(killer, 1203, getPlayerStorageValue(killer, 1203)+1)
		end

	end
end

In my case, i have a NPC that checks the storagevalue later, and gives a reward depending on how many hatchlings the player have killed.

Just remember to have
Code:
<script>
<event name="NameOfTheCreatureScript"/>
</script>
in the monster file.

And in creatureevent.xml
Code:
	<event type="death" name="CreatureScriptName" script="CreatureScriptName.lua"/>

Moderation:
Moved thread to Request & Support!
 
Last edited:
Btw Znote, since I assmue you use that script on your own server, there's a little bug should be

doPlayerSendTextMessage(killer,22,"You have killed "..getPlayerStorageValue(killer, 1203)+1.." hatchlings.")

for the correct count :D
 
Back
Top