• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[TalkAct/CreatureScri] Creature Kill Counter [1.0]

Eldin

Eldin Projects
Joined
Jun 12, 2008
Messages
1,334
Reaction score
615
Location
Sweden
Just tryed to add a Creature Kill Counter for my TFS 1.0 server.
Original Script:
http://otland.net/threads/creature-kill-count-system.177678/

CreatureScripts.xml
Code:
<event type="kill" name="MonsterCounter" script="MonsterCounter.lua"/>

MonsterCounter.lua
Code:
function onKill(cid, target)
if (isCreature(target)) then
setPlayerStorageValue(cid, getCreatureByName(target) + 1)
end
return true
end

and...

talkactions.xml
Code:
<talkaction words="!monsters" script="monsters.lua"/>

and tryed with

<talkaction words="!monsters" separator=" " script="Monsters.lua"/>

Monsters.lua
Code:
function onSay(cid, words, param)
if (param == "") then
return false
end

t = string.explode(param, ",")
t[1] = monster


if (isCreature(monster)) then
if getPlayerStorageValue(monster) > 0 then
local amount = getPlayerStorageValue(param)
local text = "You have killed " .. amount .. " " .. param .."!"

doShowTextDialog(cid, 2175, text)
else
doPlayerSendCancel(cid, "You have not killed any of these monsters.")
return false
end

else
doPlayerSendCancel(cid, "You need to type a monster name.")
return false
end
end

Error:
First had an error Before the last "else" but removed an "end", dunno if that was the right call.
Got Another error now...

Code:
attempt to call field 'explode' <a nil value>
stack traceback: [C] etc...

What do I do now? :)

Kind Regards,
Eldin.
 
Why do you keep posting your problems here? You should be posting in the support board.

We need to see that 'etc' part from the error to see what function is failing.
 
Replace
Code:
t = string.explode(param, ",")
with
Code:
t = param:split(",")
 
Why do you keep posting your problems here? You should be posting in the support board.

We need to see that 'etc' part from the error to see what function is failing.

The reason im posting them here is simply because I thought it was the right board.
I read the Stickys in the Support Board aswell as this board and concluded this was the right Place to be.

The reason im creating alot of threads is because of the few answers I get when creating one big thread and updating it.
Now people can look at the one the Think they can help at ASWELL as working scripts coming out for TFS 1.0.

The reason that I didn't add the entire error is because it says the same Words over and over, but I'll do it next time.

NOW TO THE TOPIC:
I tryed what you said Ninja, now it says "You need to type a monster name."
No other error, I removed an "END" above that last else because it stated an error. Maybe add Another instead of removing one?

Kind Regards,
Eldin.
 
Last edited:
use param:split as ninja said, but add this function at your global.lua (i had the same problem)
Code:
string.split = function(str, sep)
  local res = {}
  for v in str:gmatch("([^" .. sep .. "]+)") do
  res[#res + 1] = v
  end
  return res
end
this solved my problem and so will yours :D
 
Back
Top