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

Solved TFS 1.0 Help withscript functions

Xarly

Member
Joined
Mar 9, 2015
Messages
360
Reaction score
20
Hello guys, well im fixing my warzone from tfs 1.1 to tfs 1.0 but i got stuck on shooting.lua can't find the correct function for fix it i changed local playerPos = player:getPosition() to local playerPos = getPlayerPosition(cid)
that fixed my error on line 2 aniway im not sure if its correct after it now im getting error on line 3
if player:getStorageValue(Storage.BigfootBurden.Shooting) < 6 then and i dont know why because if im correct this function its correct >.< too on movements shooting i fixed the error on stepin ect.. the only problem its , this is not creating the dummies -.-" i post there the 2 scripts will be great if someone can help me! thanks
First problem script:http://pastebin.com/sdKdk9rA action script
Second problem script:http://pastebin.com/gviA50XE movement script (dummies problem)
Thanks in advance guys
 
Just add this under the main function.
Code:
local player = Player(cid)
getPlayerPosition(cid) is a function from TFS 0.2, it only works because of the compat.lua which sets TFS 0.2 functions to TFS 1.0 functions.
 
Just add this under the main function.
Code:
local player = Player(cid)
getPlayerPosition(cid) is a function from TFS 0.2, it only works because of the compat.lua which sets TFS 0.2 functions to TFS 1.0 functions.
okey mate, thanks for the help i will take a look in one moment and lets see if working fine, one question about createdummies do you know why its not creating the dummies? because its not giving any error on distro >.<
 
Code:
doCreateDummy(cid, Position(playerPosition.x, playerPosition.y - 5, 10))
thanks limos, last thing if u can help because im breaking my head with ohter script but can solve it >.<
it says line 6 attempt to index local 'player' but cant solve it:/
that's the script
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target.actionid ~= 8013 then
        return false
    end

    if player:getStorageValue(Storage.ChildrenoftheRevolution.Questline) == 13 then
        player:setStorageValue(Storage.ChildrenoftheRevolution.Questline, 14)
        player:setStorageValue(Storage.ChildrenoftheRevolution.Mission04, 4) --Questlog, Children of the Revolution "Mission 4: Zze Way of Zztonezz"
        item:remove()
        player:say("Due to being extra greasy, the leavers can now be moved.", TALKTYPE_MONSTER_SAY)
    end
    return true
end
thanks in advance
 
Last edited by a moderator:
Add this under function onUse
Code:
local player = Player(player)
In TFS 1.0 the first parameter is a creatureid, in TFS 1.1 it's userdata, so in TFS 1.0 you have to make it userdata first.
 
Add this under function onUse
Code:
local player = Player(player)
In TFS 1.0 the first parameter is a creatureid, in TFS 1.1 it's userdata, so in TFS 1.0 you have to make it userdata first.
thanks i think now i understand , the thing its ia dded it but idk why now won't work and don't say errors U.U xd
 
Does the player has the right storage value? You can add print or else to see what's wrong.
yea i will check the storages, and make some prints and lets see >.<
EDIT: @Limos
well we added prints and only get test test1 test3 so can be the storages? because i checked them and the storage number its the correct >.<
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
print("test")
local player = Player(player)
print("test1")
    if target.actionid == 8013 then
    print("test3")
        return false
    end
print("test4")
    if player:getStorageValue(Storage.ChildrenoftheRevolution.Questline) == 13 then
    print("test5")
        player:setStorageValue(Storage.ChildrenoftheRevolution.Questline, 14)
        print("test6")
        player:setStorageValue(Storage.ChildrenoftheRevolution.Mission04, 4) --Questlog, Children of the Revolution "Mission 4: Zze Way of Zztonezz"
        print("test7")
        item:remove()
        print("test8")
        player:say("Due to being extra greasy, the leavers can now be moved.", TALKTYPE_MONSTER_SAY)
        print("test9")
    end
    return true
end

Does the player has the right storage value? You can add print or else to see what's wrong.
that was the old script if(getPlayerStorageValue(cid, 1050) == 16) then
i changed to 16 the storage but aniway still wont work xd
 
Last edited by a moderator:
If you get test3 it's because it's returning false immediately after. it's ending the function when you get test3. It looks more like it should be checking if the action id is NOT equal to the value
 
If you get test3 it's because it's returning false immediately after. it's ending the function when you get test3. It looks more like it should be checking if the action id is NOT equal to the value
so what you say?, because i checked action id and its correct, to the id of the item im using for target so idk >.<
one thing do you know about this function why im getting error in function 'transform' a nil value?
i already tried to change dotransformiteme ct.. but not working because it need to transform a dead monster
 
if the action id of the target is 8013, the script ends. Since the action id of the target is 8013, that's why you're not getting past "test3"


as for the transform error, can you post the part of the script that contains it?
 
if the action id of the target is 8013, the script ends. Since the action id of the target is 8013, that's why you're not getting past "test3"


as for the transform error, can you post the part of the script that contains it?
that is mate so about the other script, what i can make for fix it? because im starting with lua im rlly noob xd
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
Code:
local player = Player(player)
    if target.itemid ~= 18484 then
        return false
    end

    local extractedCount = player:getStorageValue(Storage.BigfootBurden.ExtractedCount)
    if extractedCount == 7
            or player:getStorageValue(Storage.BigfootBurden.MissionRaidersOfTheLostSpark) ~= 1 then
        return false
    end

    player:setStorageValue(Storage.BigfootBurden.ExtractedCount, math.max(0, extractedCount) + 1)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You gathered a spark.')
    target:transform(18485)       <<<< IM GETTING THE ERROR JUSTHERE
    toPosition:sendMagicEffect(CONST_ME_ENERGYHIT)
    return true
end
 
Last edited by a moderator:
change
if target.actionid == 8013 then

to

if target.actionid ~= 8013 then

As far as I can tell, that's what you want.

As for the transform error, it's returning a nil value most likely because target does not exist.

What do you have to do in-game? Are you using an item (right click>use) or using an item on another item (right click>use with...)?
 
change
if target.actionid == 8013 then

to

if target.actionid ~= 8013 then

As far as I can tell, that's what you want.

As for the transform error, it's returning a nil value most likely because target does not exist.

What do you have to do in-game? Are you using an item (right click>use) or using an item on another item (right click>use with...)?
im using a item on a dead monster witht he id 18484 and when i use the item on him he need to transform to 18485 because if the monster don't transform the ppl can use the item again again again on the same dead monster >.< so its a task and its working i slain the monster without problem but the problem its if the monster don't transform after slain him the player can do it all times he want
 
in actions.cpp: bool Action::executeUse(Player* player, Item* item, const Position& fromPos, Thing* target, const Position& toPos, bool isHotkey)
target is of type "Thing", but transform is invoked on an object of type "Item", so try casting it:

Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local player = Player(player)
local t = Item(target)
if not Item(target) then
return false
end
if target.itemid ~= 18484 then
return false
end

local extractedCount = player:getStorageValue(Storage.BigfootBurden.ExtractedCount)
if extractedCount == 7
or player:getStorageValue(Storage.BigfootBurden.MissionRaidersOfTheLostSpark) ~= 1 then
return false
end

player:setStorageValue(Storage.BigfootBurden.ExtractedCount, math.max(0, extractedCount) + 1)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You gathered a spark.')
t:transform(18485)
toPosition:sendMagicEffect(CONST_ME_ENERGYHIT)
return true
end

See if that works any better.
 
Last edited:
in actions.cpp: bool Action::executeUse(Player* player, Item* item, const Position& fromPos, Thing* target, const Position& toPos, bool isHotkey)
target is of type "Thing", but transform must be evoked on an object of type "Item", so try casting it:

Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local player = Player(player)
local t = Item(target)
if not Item(target) then
return false
end
if target.itemid ~= 18484 then
return false
end

local extractedCount = player:getStorageValue(Storage.BigfootBurden.ExtractedCount)
if extractedCount == 7
or player:getStorageValue(Storage.BigfootBurden.MissionRaidersOfTheLostSpark) ~= 1 then
return false
end

player:setStorageValue(Storage.BigfootBurden.ExtractedCount, math.max(0, extractedCount) + 1)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You gathered a spark.')
t:transform(18485)
toPosition:sendMagicEffect(CONST_ME_ENERGYHIT)
return true
end

See if that works any better.
nope bro with that don't work >.<
 
This works for me. I just tested it in my server. Transforms the corpse and everything. It's identical to the original. Can you post the exact console error you got?
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local player = Player(player)
   
    if target.itemid ~= 18484 then
        return false
    end

    local extractedCount = player:getStorageValue(Storage.BigfootBurden.ExtractedCount)
    if extractedCount == 7 or player:getStorageValue(Storage.BigfootBurden.MissionRaidersOfTheLostSpark) ~= 1 then
        return false
    end

    player:setStorageValue(Storage.BigfootBurden.ExtractedCount, math.max(0, extractedCount) + 1)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You gathered a spark.')
    target:transform(18485)
    toPosition:sendMagicEffect(CONST_ME_ENERGYHIT)
    return true
end
 
Back
Top