• 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 Help with script !! gives key with no action ID

Rossii

Member
Joined
Mar 27, 2012
Messages
366
Reaction score
6
Location
England
Hi i have got a script that you do the mission you receive a key.

But when i receive the key from the mission there no action ID

Joy.lua

PHP:
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
 
local c = {
	storage = 1234,
	key = 2087, -- wooden key
	action = true, -- key with action id? true or false
	actionid = 1218 -- if action = true, actionid = id
}
 
local story = {}
 
local function cancelStory(cid)
	if not(story[cid]) then return true end
	for _, eventId in pairs(story[cid]) do
		stopEvent(eventId)
	end
	story[cid] = {}
end
 
function creatureFarewell(cid)
	if not(isPlayer(cid)) then return true end
	cancelStory(cid)
	selfSay('Good bye then.', cid)
	return true
end
 
 
 
function greetCallback(cid)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if getPlayerStorageValue(cid, c.storage) == -1 then
		npcHandler:setMessage(MESSAGE_GREET, "Hello " .. getPlayerName(cid) .. ", looking for an adventure?")
		talkState[talkUser] = 1
	elseif getPlayerStorageValue(cid, c.storage) == 1 then
		npcHandler:setMessage(MESSAGE_GREET, "Go south from me and search {Serby} the key word is {Gueden}")
		npcHandler:releaseFocus(cid)
	elseif getPlayerStorageValue(cid, c.storage) == 2 then
		npcHandler:setMessage(MESSAGE_GREET, 'So you met {Serby}, did you have fun?')
		talkState[talkUser] = 2
	elseif getPlayerStorageValue(cid, c.storage) == 3 then
		npcHandler:setMessage(MESSAGE_GREET, 'You already have the key!')
		npcHandler:releaseFocus(cid)
	elseif getPlayerStorageValue(cid, c.storage) == 4 then 
		npcHandler:setMessage(MESSAGE_GREET, "You already have done this mission.")
		npcHandler:releaseFocus(cid)
	end
	return true
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
 
	if msgcontains(msg, 'yes') then
		if talkState[talkUser] == 1 then
			selfSay('Go south from me and search {Serby} the key word is {Gueden}', cid)
			setPlayerStorageValue(cid, c.storage, 1)
			talkState[talkUser] = 0
		elseif talkState[talkUser] == 2 then
			selfSay('Okey, what did he say to you?', cid)
			talkState[talkUser] = 3
		end
	elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
		selfSay('Fuck off.', cid)
		talkState[talkUser] = 0
		npcHandler:releaseFocus(cid)
	elseif msgcontains(msg, "serby") then
		npcHandler:say("My old friend {Serby}, so you met him?", cid, TRUE)
		talkState[talkUser] = 2
	elseif msgcontains(msg, "the new city") then
		if talkState[talkUser] == 3 then
			setPlayerStorageValue(cid, c.storage, 3)
			cancelStory(cid)
			story[cid] = selfStory({"Oh its time...", "I have the key some where, let me search!", "Oh here take it."}, cid, 6000)
			local key = doPlayerAddItem(cid, c.key, 1)
			if c.action then setItemAttribute(key, "actionid", c.actionid) end
			npcHandler:releaseFocus(cid)
			talkState[talkUser] = 0
			return true
		else
			npcHandler:say("That is confidential information, talk with {Serby} about that.", cid, TRUE)
			npcHandler:releaseFocus(cid)
			talkState[talkUser] = 0
		end
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_FAREWELL, creatureFarewell)
npcHandler:setCallback(CALLBACK_CREATURE_DISAPPEAR, creatureFarewell)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye then.")
npcHandler:addModule(FocusModule:new())
 
Lua:
if c.action then setItemAttribute(key, "aid", c.actionid) end
 
It's already in the script, Ninja just edited that line.
But do you got errors (in your console)?
If the function doesn't exist in your server, try doItemSetAttribute.
 
The problem is that you're using c.actionid .actionid is recognized as an actual function so you are confusing the script try changing in the script where it says c.actionid to c.idaction and at the top in the config change actionid to idaction that will solve your issue
 
Back
Top Bottom