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

Kill Monsters = setStorageValue

Reyn

On to the next One
Joined
May 15, 2010
Messages
259
Reaction score
1
Location
Germany ;3
Hei all :eek:
i'm looking for a script which works like this:
If I kill 1-100 (math. random) Demons it gives me a storage Value ... and it shouldnt be repeatable.. If possible after finishing this quest there should appear a FYI which says (you just killed a lot of Demons, you can do the demon quest now) or sth. xDD but isn't needed!
it shouldnt be startet with a quest npc or so... it should just appear after killing that amount of monsters
I hope someone can help me!
REgards,
Reyn
EDIT: It should work for tfs 0.3.6pl1
EDITEDIT: i got this script already (original by Teckman or so) just edited a bit
Code:
function onKill(cid, target) 

local config = { 
monstername = "demon", -- monster name 
needeedkills = 5, -- kills needed to complete quest 
effect = 15, -- effect used after completing quest 
storage = 10001, -- storage of kills 
hunterstorage = 9999, -- storage of completed quest 
pos = getPlayerPosition(cid) -- replacement for cid is target 
} 
        if(isMonster(target) == TRUE) then 
            if getCreatureName(target) == config.monstername then 
                if getPlayerStorageValue(cid, config.storage) == config.needeedkills-1 and getPlayerStorageValue(cid,config.hunterstorage) == -1 then 
                    doCreatureSay(cid, ""..config.monstername.." just joined your Team.", TALKTYPE_ORANGE_1) 
                    setPlayerStorageValue(cid,config.hunterstorage,1) 
                    doSendMagicEffect(config.pos, config.effect)  
                elseif getPlayerStorageValue(cid, config.storage) < config.needeedkills-1 then 
                    setPlayerStorageValue(cid, config.storage,(getPlayerStorageValue(cid, config.storage))+1) 
                end 
            end 
        end 
    return TRUE 
end
but anyhow it doesnt work for me :S no errors in console it just doesnt give me the Message if i killed 5 demons PLUS there is no math.random at the kills :S
 
Last edited:
Well this isnt exactly what i searched for :s
First of all it doesnt have a math. random like i said ..
and like i said
it shouldnt be started with a quest npc or so... it should just appear after killing that amount of monsters
i mean that i dont need to accept that quest or so ....
because i want it like this:
if i kill a math. random of 1-100 demons it "joins" (storage value) my team and i can summon it with a talkaction, but cant summon it if it hasn't joined my team yet... i did the summon talkaction already, but the missing part is THIS script x.x

PS: the script doesn't need to have LOCALs i can edit it other way too
 
Last edited:
didnt get my question?
Well f.e.
I kill a random amount of (math. random 1-100) Demons... then a message appears and tells Congratulations... blablabla... + it gives me a storage value.. BUT it should appear with just killing the monsters... Not ACCEPTING a quest or so..
get it now? :S sry for bad english
 
Is this what you want?
try this.
changed creaturescript
Lua:
function onKill(cid, target) 

local config = { 
monstername = "demon", -- monster name 
needeedkills = getPlayerStorageValue(cid,10000), -- kills needed to complete quest 
effect = 15, -- effect used after completing quest 
storage = 10001, -- storage of kills 
hunterstorage = 10002 -- storage of completed quest 
} 
        if(isMonster(target) == TRUE) then 
            if getCreatureName(target) == config.monstername then 
                if getPlayerStorageValue(cid,10000) == -1 then
                    setPlayerStorageValue(cid,10000,math.random(1,100))
                    setPlayerStorageValue(cid, config.storage,(getPlayerStorageValue(cid, config.storage))+1) 
                elseif getPlayerStorageValue(cid, config.storage) == config.needeedkills-1 and getPlayerStorageValue(cid,config.hunterstorage) == -1 then 
                    doPlayerPopupFYI(cid,"You just killed a lot of Demons, you can do the demon quest now.")
                    setPlayerStorageValue(cid,config.hunterstorage,1) 
                    doSendMagicEffect(getPlayerPosition(cid), config.effect)  
                elseif getPlayerStorageValue(cid, config.storage) < config.needeedkills-1 and getPlayerStorageValue(cid,config.hunterstorage) == -1 then 
                    setPlayerStorageValue(cid, config.storage,(getPlayerStorageValue(cid, config.storage))+1) 
                end 
            end 
        end 
    return TRUE 
end
report errors cuz its not tested and rep++ if i helped :)
table version not tested
Lua:
function onKill(cid, target) 
 
local config = { 
monstername = {"demon","Demon"}, -- monster name max 99 monsters in table
effect = 15, -- effect used after completing quest 
hunterstorage = 10200 -- storage of completed quest + 1 for demon, +2 for the next monster you put in the table
} 
        if(isMonster(target) == TRUE) then 
		  for i = 0,#config.monstername do
            if getCreatureName(target) == config.monstername[i] then 
                if getPlayerStorageValue(cid, 10100+i) == -1 and getPlayerStorageValue(cid,config.hunterstorage+i) == -1 then
                    setPlayerStorageValue(cid,1000+i,math.random(1,100))
                    setPlayerStorageValue(cid, 10100+i,(getPlayerStorageValue(cid, 10100+i))+1) 
                elseif getPlayerStorageValue(cid, 10100+i) == getPlayerStorageValue(cid,10000+i)-1 and getPlayerStorageValue(cid,config.hunterstorage+i) == -1 then 
                    doPlayerPopupFYI(cid,"You just killed a lot of ".. getCreatureName(target) ..", you can do the ".. getCreatureName(target) .." quest now.")
                    setPlayerStorageValue(cid,config.hunterstorage+i,1) 
                    doSendMagicEffect(getPlayerPosition(cid), config.effect)  
                elseif getPlayerStorageValue(cid, 10100+i) < getPlayerStorageValue(cid,10000+i)-1 and getPlayerStorageValue(cid,config.hunterstorage+i) == -1 then 
                    setPlayerStorageValue(cid, 10100+i,(getPlayerStorageValue(cid, 10100+i))+1) 
                end 
            end 
          end 
		end
    return TRUE 
end
 
Last edited:
ah, changed it to what i think he wants.
now the player get a random amout of needed kills when he first kill a demon and it start automaticly.
after he kills all needed kills he gets a fyi(popup) massage and a storagevalue.
did i get it wrong again?
 
The First one doesn't work for me :S no error, there just wont appear the message and i aint gettin the storage value (do i need npc for that? i hope not >.<)
and the second one neither
it gives me this error :
Code:
[16/08/2010 13:28:28] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/test.lua:13: ')' expected near '.10100'
[16/08/2010 13:28:28] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/test.lua)
[16/08/2010 13:28:28] data/creaturescripts/scripts/test.lua:13: ')' expected near '.10100'
This is my creatureevents.xml
Code:
    	<event type="kill" name="test" event="script" value="test.lua"/>
added this to login.lua
Code:
	registerCreatureEvent(cid, "test")
and this to my monster below flags
Code:
<script>
	<event name="test"/>
</script>
Hope you could help me out again :S
 
:S the FYI is just not appearing and i aint getting any storage Value ;/
No errors in console this time but just not working....
i added it to login.lua, to demon.xml and to creatureevents.xml :S what am i doing wrong?
 
Rep++ :p
ok here it is, go to creatureevent make new lua ....
[ but like that the quest that they will be able to make after they kill the monster have to check if they have queststorage == 1 to start it]

Lua:
--[[example :   
          ["monster name"] = { storage = emty storage, kill = emty storage, queststorage = quest that will be enabled, popup = msg in popup}
]]--
local monster = { ["rat"] = {storage = 19009,kill = 19019, queststorage = 1212, popup = "You have killed many rats you can go make rat quest now."},
                  ["demon"] = {storage = 19008,kill = 19029, queststorage = 1213, popup = "You have killed many demon you can go make rat quest now."}
                }
function onKill(cid,target)
  local m = monster[string.lower(getCreatureName(target))]
        if(not m) then
                return true
        end
		if getPlayerStorageValue(cid,m.kill) >= 400 then
		  return true
		end
		if getPlayerStorageValue(cid,m.kill) < 0 then
		   setPlayerStorageValue(cid,m.kill,math.random(1,100))
		   setPlayerStorageValue(cid,m.storage,1)
		   return true
		end
		if getPlayerStorageValue(cid,m.storage) > 0 and getPlayerStorageValue(cid,m.storage)  == getPlayerStorageValue(cid,m.kill) then
		    doPlayerPopupFYI(cid, m.popup)
			setPlayerStorageValue(cid,m.queststorage,1)
			setPlayerStorageValue(cid,m.kill,400)
		   return true
		end
		 setPlayerStorageValue(cid,m.storage,getPlayerStorageValue(cid,m.storage)+1)
		 doSendAnimatedText(getPlayerPosition(cid),getPlayerStorageValue(cid, m.storage).."", math.random(01,255))
 return true
end

and then in creature.xml
Code:
 <event type="kill" name="Attk" event="script" value="xxxx.lua"/>

in login.lua
Code:
registerCreatureEvent(cid, "Attk")
 
Last edited:
i dont understand what u mean by
[ but like that the quest that they will be able to make after they kill the monster have to check if they have queststorage == 1 to start it]
??
EDIT: Perfectly working like i wanted *_* Thanks , rep++ :D
 
Last edited:
i mean players will be able make a quest when they finish killing the monster???
if so then in the quest[to take prize or start it i donno] you must check if the queststorage[that was in script] == 1 :)
 
Back
Top