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

Lua Lua Script Help!

ond

Veteran OT User
Joined
Mar 24, 2008
Messages
2,775
Solutions
25
Reaction score
483
Location
Sweden
Hello, I wonder if someone could help me with my lua function. The NPC is supposed to take bones(id 2230) and when the NPC have collected 20 bones, he will say:
Code:
You have collected all the 20 bones needed. Excellent! Now let\'s talk about further missions if you are interested.

But if the player only have collected, let's say 14 bones, the NPC should tell him:
Code:
Excellent! You have collected 14 bones. Just report about your mission again if you find more.

And then, when the NPC got 6 more bones, the NPC should say:
Code:
You have collected all the 20 bones needed. Excellent! Now let\'s talk about further missions if you are interested.

Would be awesome if someone could help me out with this! Thanks in advance!

Here is how far I got before I got stuck (below)

Lua:
elseif talk_state == 14 and msgcontains(msg, 'mission') and getPlayerStorageValue(cid, 5212) == 1 then
BONES = getPlayerItemCount(cid,2230)
if BONES >= 1
if doPlayerRemoveItem(cid, 2813, BONES) == TRUE then
selfSay('You have collected all the 20 bones needed. Excellent! Now let\'s talk about further missions if you are interested.')
talk_state == 15
end
	else
selfSay('')
end
 
Yeah, thanks for pointing that out :p Got any ideas how to make it check how many bones the player has given and how many is left and vice versa? XD
 
Could you perhaps explain further? Or give me an example? As you understand, I'm a real noob at lua... for now XD
 
if we do a killing in the name of script, we would do an onKill script, example:
Code:
function onKill(cid, target)
	if getCreatureName(target) == "SomeCreature"
	then
		--[[
		* \note
		*  We increment the storage here, to find out how many he killed with the NPC
		]]
		setPlayerStorageValue(cid, 5000, getPlayerStorageValue(cid, 5000) + 1)
		--[[
		* \note
		*  Here we check if he has got about 100 kills or bigger then we tell him "Congratz! you finished it!"
		]]
		if getPlayerStorageValue(cid, 5000) >= 100
		then
			doPlayerSendTextMessage(cid, 27, "Congratz! you finished it!")
		end
	end
	return true
end
etc...
 
Something like this then? :p
Lua:
elseif talk_state == 14 and msgcontains(msg, 'mission') and getPlayerStorageValue(cid, 5212) == 1 then
BONES = getPlayerItemCount(cid,2230)
if BONES >= 1
if doPlayerRemoveItem(cid, 2813, BONES) == TRUE then
setPlayerStorageValue(cid, 5213, getPlayerStorageValue(cid, 5213) + 1)
if getPlayerStorageValue(cid, 5000) >= 20
selfSay('You have collected all the 20 bones needed. Excellent! Now let\'s talk about further missions if you are interested.')
talk_state = 15
end
	end
else
selfSay('')
end
 
Back
Top