• 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 [1.2]Simple onUse quest problem

Pasiac

New Member
Joined
Jul 4, 2008
Messages
44
Reaction score
4
Hello, this is my piece of code
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   
    if  getPlayerStorageValue(cid, 4444)==1 then
        doPlayerSendCancel(cid,"You already done that quest.")
    else
        setPlayerStorageValue(cid, 4444, 1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Now you can enter to the lower floor respawn.")
    end
    return true
end

here is how I added it to actions.xml
PHP:
    <action uniqueid="4444" script="karamba/skrzyniagsy.lua" />

And when I click on the item with uniqueid 4444 I got this in console
 
Code:
onUse(cid, item, fromPosition, itemEx, toPosition)
Cid is being treated as player
This is what a normal 1.2 onUse looks like
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
See the difference?

Now the parameter names don't really matter, its how they are used which does, it looks like you took this script from an earlier distribution hoping it would work in 1.2 which just isn't the case, however that does not mean it can't, you just need to update it to use 1.2 methods.
 
@592160
I wrote it from scrap but after it didnt work I changed it few times(it didn't help xD). So my upper post is result of my experiments.
I changed headline and it still doesnt work.
Is it http://pastebin.com/wrnD8jHH proper methods to use in tfs 1.2 lua programing?
My code now:
PHP:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    if  player:getStorageValue(4444)==1 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You already done that quest.")
    else
        player:setStorageValue(4444, 1)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Now you can enter to the lower floor respawn.")
    end
    return true
end
 
@592160
I wrote it from scrap but after it didnt work I changed it few times(it didn't help xD). So my upper post is result of my experiments.
I changed headline and it still doesnt work.
Is it http://pastebin.com/wrnD8jHH proper methods to use in tfs 1.2 lua programing?
My code now:
PHP:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    if  player:getStorageValue(4444)==1 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You already done that quest.")
    else
        player:setStorageValue(4444, 1)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Now you can enter to the lower floor respawn.")
    end
    return true
end
Show us the whole script.
 
PHP:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  
    if  player:getStorageValue(4444)==1 then
        player:sendCancelMessage("You already done that quest.")
    else
        player:setStorageValue(4444, 1)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Now you can enter to the lower floor respawn.")
    end
    return true
end
Check this code.
 
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(4444) == 1 then
        player:sendCancelMessage("You already done that quest.")
        return true
    end

    player:setStorageValue(4444, 1)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Now you can enter to the lower floor respawn.")
    return true
end
 
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(4444) == 1 then
        player:sendCancelMessage("You already done that quest.")
        return true
    end

    player:setStorageValue(4444, 1)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Now you can enter to the lower floor respawn.")
    return true
end
I applaud your effort but do you know that this does the same thing as what he originally posted?
The only thing you did different was remove the else and return true within the if statement.
You have not altered the execution of the script at all.
 
Back
Top