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

[Task system] KILLING X PEOPLE GET REWARD

keal

New Member
Joined
Mar 10, 2010
Messages
26
Reaction score
2
Hello
I need script task system, but for killing people.. npc or talkaction
i can't find it here ;(, please help

sorry for my bad english


Best regards :)
 
Code:
function onKill(cid, target, damage, flags)
				if isPlayer(target) then
					if getCreatureStorage(cid, achievements['gladiator'].doneStorage) < 1 then
						if getCreatureStorage(cid, achievements['gladiator'].storage)+1 < achievements['gladiator'].kills then
							doCreatureSetStorage(cid, achievements['gladiator'].storage, math.max(getCreatureStorage(cid, achievements['gladiator'].storage),0)+1)
						else
							doCreatureSetStorage(cid, achievements['gladiator'].doneStorage, 1)
							doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You killed '..achievements['gladiator'].kills..' players and you obtain [gladiator] achievement.')
						end
					end
				end
				return true
			end

Code:
['gladiator'] = {doneStorage = 1310700, storage = 1310800, kills = 200},

Script from otsmateria datapack. Edit it yourself or just edit the mod from materia datapack(download section).
 
Lua:
function onKill(cid, target, damage, flags)
				if isPlayer(target) then
					if getCreatureStorage(cid, achievements['gladiator'].doneStorage) < 1 then
						if getCreatureStorage(cid, achievements['gladiator'].storage)+1 < achievements['gladiator'].kills then
							doCreatureSetStorage(cid, achievements['gladiator'].storage, math.max(getCreatureStorage(cid, achievements['gladiator'].storage),0)+1)
						else
							doCreatureSetStorage(cid, achievements['gladiator'].doneStorage, 1)
							doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You killed '..achievements['gladiator'].kills..' players and you obtain [gladiator] achievement.')
						end
					end
				end
				return true
			end

wat ?

Lua:
local wat, sthk = {
{["kills"] = 5, ["rewardID"] = 2160, ["rewardCount"] = 1},
{["kills"] = 5, ["rewardID"] = 2160, ["rewardCount"] = 5}
}, 29303
local storage = getPlayerStorageValue(cid, sthk)

function onKill(cid, target)
	if storage < 1 then
		setPlayerStorageValue(cid, sthk, 0)
	end
	setPlayerStorageValue(cid, sthk, storage + 1)
	for wut = 1, #wat do
		if storage == wat[wut].kills then
			doPlayerAddItem(cid, wat[wut].rewardID, wat[wut].rewardCount)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You have been rewarded for killing '.. storage ..' players.')
		end
	end
return true
end
 
Last edited:
thanks so much for creatureevent, but how can i connect it with npc or talkaction?
Example : hi -> mission -> npc : ur mission is kill 500 people , back later to raport !
and now will work creatueevent script Erexo , please help..

Best regards
 
NPC:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid)			end
function onCreatureDisappear(cid)			npcHandler:onCreatureDisappear(cid)			end
function onCreatureSay(cid, type, msg)			npcHandler:onCreatureSay(cid, type, msg)		end
function onThink()					npcHandler:onThink()					end

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	local erexo, sthl, sfbp = {10,50,100}, 59349, 24321
	local killValue = erexo[sthl] - getPlayerStorageValue(cid, 29303)
	if(msgcontains(msg, 'mission')) then
		if getPlayerStorageValue(cid, sfbp) < 1 then
			for i = 1, #erexo do
				if getPlayerStorageValue(cid, sthl) < 1 then
					setPlayerStorageValue(cid, sthl, 1)
				end
				
				if getPlayerStorageValue(cid, sthl) == i then
					setPlayerStorageValue(cid, sfbp, 1)
					setPlayerStorageValue(cid, 29303, 0)
					selfSay('Lets see, you want a mission? Oke, kill ' .. erexo[i] .. ' players for me', cid)
					talkState[talkUser] = 0
					return true
				end
				selfSay('I dont have more missions for you.', cid)
				talkState[talkUser] = 0
			end
			
		else
			selfSay('You did not complete my last mission? Go and kill ' .. killValue .. ' players more', cid)
			talkState[talkUser] = 0
		end
	end
	
	return true
end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

script:
Lua:
local wat, sthk = {
{["kills"] = 10, ["rewardID"] = 2160, ["rewardCount"] = 1},
{["kills"] = 50, ["rewardID"] = 2160, ["rewardCount"] = 5},
{["kills"] = 100, ["rewardID"] = 2160, ["rewardCount"] = 15}
}, 29303
local erexo, sthl, sfbp = {10,50,100}, 59349, 24321
local killValue = erexo[sthl] - getPlayerStorageValue(cid, sthk)
local storage = getPlayerStorageValue(cid, sthk)
 
function onKill(cid, target)
	if getPlayerStorageValue(cid, sfbp) == 1 then
			if storage < 1 then
				setPlayerStorageValue(cid, sthk, 0)
			end
			setPlayerStorageValue(cid, sthk, storage + 1)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have killed ' .. storage .. ' players, need [' .. killValue .. '] more.')
			for wut = 1, #wat do
				if storage == wat[wut].kills then
					doPlayerAddItem(cid, wat[wut].rewardID, wat[wut].rewardCount)
					setPlayerStorageValue(cid, sfbp)
					setPlayerStorageValue(cid, sthk, 0)
					setPlayerStorageValue(cid, sthl, getPlayerStorageValue(cid, sthl) + 1)
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have been rewarded for killing '.. storage ..' players.')
				end
			end
	end
return true
end

local erexo, sthl, sfbp = {10,50,100}, 59349, 24321
Frags amount, must be same as amount in script.


Not tested
 
Last edited:
Lua:
local wat, sthk = {
{["kills"] = 10, ["rewardID"] = 2160, ["rewardCount"] = 1},
{["kills"] = 50, ["rewardID"] = 2160, ["rewardCount"] = 5},
{["kills"] = 100, ["rewardID"] = 2160, ["rewardCount"] = 15}
}, 29303
local erexo, sthl, sfbp = {10,50,100}, 59349, 24321
local killValue = erexo[sthl] - getPlayerStorageValue(cid, sthk)
local storage = getPlayerStorageValue(cid, sthk)
 
function onKill(cid, target)
	if getPlayerStorageValue(cid, sfbp) == 1 and isPlayer(cid) == true then
			if storage < 1 then
				setPlayerStorageValue(cid, sthk, 0)
			end
			setPlayerStorageValue(cid, sthk, storage + 1)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have killed ' .. storage .. ' players, need [' .. killValue .. '] more.')
			for wut = 1, #wat do
				if storage == wat[wut].kills then
					doPlayerAddItem(cid, wat[wut].rewardID, wat[wut].rewardCount)
					setPlayerStorageValue(cid, sfbp)
					setPlayerStorageValue(cid, sthk, 0)
					setPlayerStorageValue(cid, sthl, getPlayerStorageValue(cid, sthl) + 1)
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have been rewarded for killing '.. storage ..' players.')
				end
			end
	end
return true
end
You need to check if is player too fixed it so it checks
 
You need to check if is player too fixed it so it checks

Already fixed, Ive chatting with keal on PM :)

@Edit
Final version:
Lua:
local wat, sthk = {
{["kills"] = 10, ["rewardID"] = 2160, ["rewardCount"] = 1},
{["kills"] = 50, ["rewardID"] = 2160, ["rewardCount"] = 5},
{["kills"] = 100, ["rewardID"] = 2160, ["rewardCount"] = 15}
}, 29303
local erexo, sthl, sfbp = {10,50,100}, 59349, 24321
 
function onKill(cid, target)
if isPlayer(target) and isPlayer(cid) then
	if getPlayerStorageValue(cid, sfbp) == 1 then
		if(getPlayerStorageValue(cid, sthk) < 1) then
			setPlayerStorageValue(cid, sthk, 0)
		end
		setPlayerStorageValue(cid, sthk, getPlayerStorageValue(cid, sthk) + 1)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have killed ' .. getPlayerStorageValue(cid, sthk) .. ' players.')
		for wut = 1, #wat do
			if getPlayerStorageValue(cid, sthk) == wat[wut].kills then
				doPlayerAddItem(cid, wat[wut].rewardID, wat[wut].rewardCount)
				setPlayerStorageValue(cid, sfbp)
				setPlayerStorageValue(cid, sthk, 0)
				setPlayerStorageValue(cid, sthl, getPlayerStorageValue(cid, sthl) + 1)
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have been rewarded for killing '.. getPlayerStorageValue(cid, sthk) ..' players.')
			end
		end
	end
end
return true
end
 
Last edited:
NPC:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)                npcHandler:eek:nCreatureAppear(cid)            end
function onCreatureDisappear(cid)            npcHandler:eek:nCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)            npcHandler:eek:nCreatureSay(cid, type, msg)        end
function onThink()                    npcHandler:eek:nThink()                    end

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    local erexo, sthl, sfbp = {10,50,100}, 59349, 24321
    local killValue = erexo[sthl] - getPlayerStorageValue(cid, 29303)
    if(msgcontains(msg, 'mission')) then
        if getPlayerStorageValue(cid, sfbp) < 1 then
            for i = 1, #erexo do
                if getPlayerStorageValue(cid, sthl) < 1 then
                    setPlayerStorageValue(cid, sthl, 1)
                end
               
                if getPlayerStorageValue(cid, sthl) == i then
                    setPlayerStorageValue(cid, sfbp, 1)
                    setPlayerStorageValue(cid, 29303, 0)
                    selfSay('Lets see, you want a mission? Oke, kill ' .. erexo[I] .. ' players for me', cid)
                    talkState[talkUser] = 0
                    return true
                end
                selfSay('I dont have more missions for you.', cid)
                talkState[talkUser] = 0
            end
            
        else
            selfSay('You did not complete my last mission? Go and kill ' .. killValue .. ' players more', cid)
            talkState[talkUser] = 0
        end
    end
    
    return true
end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

script:
Lua:
local wat, sthk = {
{["kills"] = 10, ["rewardID"] = 2160, ["rewardCount"] = 1},
{["kills"] = 50, ["rewardID"] = 2160, ["rewardCount"] = 5},
{["kills"] = 100, ["rewardID"] = 2160, ["rewardCount"] = 15}
}, 29303
local erexo, sthl, sfbp = {10,50,100}, 59349, 24321
local killValue = erexo[sthl] - getPlayerStorageValue(cid, sthk)
local storage = getPlayerStorageValue(cid, sthk)

function onKill(cid, target)
    if getPlayerStorageValue(cid, sfbp) == 1 then
            if storage < 1 then
                setPlayerStorageValue(cid, sthk, 0)
            end
            setPlayerStorageValue(cid, sthk, storage + 1)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have killed ' .. storage .. ' players, need [' .. killValue .. '] more.')
            for wut = 1, #wat do
                if storage == wat[wut].kills then
                    doPlayerAddItem(cid, wat[wut].rewardID, wat[wut].rewardCount)
                    setPlayerStorageValue(cid, sfbp)
                    setPlayerStorageValue(cid, sthk, 0)
                    setPlayerStorageValue(cid, sthl, getPlayerStorageValue(cid, sthl) + 1)
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have been rewarded for killing '.. storage ..' players.')
                end
            end
    end
return true
end

local erexo, sthl, sfbp = {10,50,100}, 59349, 24321
Frags amount, must be same as amount in script.


Not tested[/I]
bro how i can add more than 1 task i mean i want add 500 kills 100 kills and 1000 kills.
 
Back
Top