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

Key_2271

bomba

Member
Joined
Feb 26, 2008
Messages
635
Reaction score
7
Location
Brazil
I have one error in my script:
05a4ab5ca0b420557cade9d4fe4c04e2.jpg


Script1:
PHP:
--Key_Quest_2271
function onUse(cid, item, frompos, item2, topos) 
  
if item.uid == 2271 then 
local queststatus = getPlayerStorageValue(cid,2271) 
    if queststatus < 1 then
        setPlayerStorageValue(cid, 2271, 1)
            doPlayerAddItem(cid, 2376, 1)
	    doSetItemActionId(uid, 2271)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a ' .. getItemName(2087) .. '.') 
        end
    else 
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.") 
      end 
    end

Script2:
PHP:
	<action uniqueid="2271" script="quests/key_quest_2271.lua"/>
 
I see the error.

doSetItemActionId(uid, 2271)

You didn't specify what the actionid is being set to

I know simple programming but I don't know how to fix it. Mwahaha
 
This should work.
Code:
[COLOR=#000000][COLOR=#007700][FONT=Courier New]--[/FONT][/COLOR][FONT=Courier New][COLOR=#0000bb]Key_Quest_2271 [/COLOR][/FONT]
[FONT=Courier New][COLOR=#007700]function [/COLOR][COLOR=#0000bb]onUse[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]cid[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]item[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]frompos[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]item2[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]topos[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]) [/COLOR][/FONT]
 
[FONT=Courier New][COLOR=#007700]if [/COLOR][COLOR=#0000bb]item[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]uid [/COLOR][COLOR=#007700]== [/COLOR][/FONT][FONT=Courier New][COLOR=#0000bb]2271 then [/COLOR][/FONT]
[FONT=Courier New][COLOR=#0000bb]local queststatus [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]getPlayerStorageValue[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]cid[/COLOR][COLOR=#007700],[/COLOR][COLOR=#0000bb]2271[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]) [/COLOR][/FONT]
[FONT=Courier New][COLOR=#007700]if [/COLOR][COLOR=#0000bb]queststatus [/COLOR][COLOR=#007700]< [/COLOR][/FONT][FONT=Courier New][COLOR=#0000bb]1 then [/COLOR][/FONT]
[FONT=Courier New][COLOR=#0000bb]setPlayerStorageValue[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]cid[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]2271[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]1[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]) [/COLOR][/FONT]
[FONT=Courier New][COLOR=#007700]key = [/COLOR][COLOR=#0000bb]doPlayerAddItem[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]cid[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]2376[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]1[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]) [/COLOR][/FONT]
[FONT=Courier New][COLOR=#0000bb]doSetItemActionId[/COLOR][COLOR=#007700](key.[/COLOR][COLOR=#0000bb]uid[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]2271[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]) [/COLOR][/FONT]
[FONT=Courier New][COLOR=#0000bb]doPlayerSendTextMessage[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]cid[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]MESSAGE_INFO_DESCR[/COLOR][COLOR=#007700], [/COLOR][COLOR=#dd0000]'You have found a ' [/COLOR][COLOR=#007700].. [/COLOR][COLOR=#0000bb]getItemName[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]2087[/COLOR][COLOR=#007700]) .. [/COLOR][COLOR=#dd0000]'.'[/COLOR][/FONT][COLOR=#007700][FONT=Courier New]) [/FONT][/COLOR]
[COLOR=#0000bb][FONT=Courier New]end [/FONT][/COLOR]
[FONT=Courier New][COLOR=#007700]else [/COLOR][/FONT]
[FONT=Courier New][COLOR=#0000bb]doPlayerSendTextMessage[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]cid[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]MESSAGE_INFO_DESCR[/COLOR][COLOR=#007700], [/COLOR][COLOR=#dd0000]"It is empty."[/COLOR][/FONT][COLOR=#007700][FONT=Courier New]) [/FONT][/COLOR]
[COLOR=#0000bb][FONT=Courier New]end [/FONT][/COLOR]
[FONT=Courier New][COLOR=#0000bb]end [/COLOR][/FONT]
[/COLOR]
You can never give a item a unique id without naming the parameter for it.
 
Last edited by a moderator:
PHP:
key = doPlayerAddItem(cid, 2376, 1) 
doSetItemActionId(key.uid, 2271)

or remove .uid from this one and it'll work ^^
 
No, it needs the uid. I have used this in so many of my scripts, are you sure you are doing everything right?

Is there any console errors?
 
No, it needs the uid. I have used this in so many of my scripts, are you sure you are doing everything right?

Is there any console errors?

You don't need the .uid, in fact, I don't think it works with it. So try to remove the .uid and test again.
 
Well from TFS sources, the parameters of the function, it clearly states Uid, unless im wrong

doSetItemActionId(uid, actionid)

If it is the case you dont need the uid, wouldnt this confuse beginners of the parameters?
 
Last edited by a moderator:
well try as they said, not the .uid
PHP:
--Key_Quest_2271 
function onUse(cid, item, frompos, item2, topos)
    if item.uid == 2271 then
        local queststatus = getPlayerStorageValue(cid,2271)
        if queststatus < 1 then
            setPlayerStorageValue(cid, 2271, 1)
            key = doPlayerAddItem(cid, 2376, 1)
            doSetItemActionId(key, 2271)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a ' .. getItemName(2087) .. '.')
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
    end
end

if you don't get an error, then it works ^.^
 
Action ID: (Key number)
Unique ID: (Item ID)
In mapeditor :)

Code:
function onUse(cid, item, frompos, item2, topos)
prize = item.uid
aid = item.actionid
local key = doCreateItemEx(prize)

if prize > 0 and prize < 7000 then
queststatus = getPlayerStorageValue(cid,prize)

if queststatus == -1 then
if aid > 1000 then
doPlayerSendTextMessage(cid,22,'You have found a ' .. getItemName(prize) .. '.')
setPlayerStorageValue(cid,prize,1)
doSetItemActionId(key, aid)
doPlayerAddItemEx(cid, key)
else
doPlayerSendTextMessage(cid,22,'You have found a ' .. getItemName(prize) .. '.')
doPlayerAddItem(cid,prize,1)
setPlayerStorageValue(cid,prize,1)
end
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end

return 1
else
return 0
end
end
 
Action ID: (Key number)
Unique ID: (Item ID)
In mapeditor :)

Code:
function onUse(cid, item, frompos, item2, topos)
prize = item.uid
aid = item.actionid
local key = doCreateItemEx(prize)

if prize > 0 and prize < 7000 then
queststatus = getPlayerStorageValue(cid,prize)

if queststatus == -1 then
if aid > 1000 then
doPlayerSendTextMessage(cid,22,'You have found a ' .. getItemName(prize) .. '.')
setPlayerStorageValue(cid,prize,1)
doSetItemActionId(key, aid)
doPlayerAddItemEx(cid, key)
else
doPlayerSendTextMessage(cid,22,'You have found a ' .. getItemName(prize) .. '.')
doPlayerAddItem(cid,prize,1)
setPlayerStorageValue(cid,prize,1)
end
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end

return 1
else
return 0
end
end

???
<action uniqueid="2271" script="key_2271.lua" />
or
<action itemid="2087" script="key_2271.lua"/>
or
<action actionid="2271" script="key_2271.lua"/>
???
 
Last edited:
Back
Top