• 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 0.3.6 and now 1.2, doplayer say and others

narkotyko

New Member
Joined
Jan 16, 2016
Messages
22
Reaction score
0
Hello how can i make doplayer say, or addevent and say in talktype_orange_1 in tfs 1.2?
Ok all know without addevent any ideas? Here is my code,
HTML:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 77)
combat:setArea(createCombatArea(FALA_G_P))
function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 7
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 11
    return -min, -max
end
combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function player_look(cid)
if getPlayerLookDir(cid) == 1 then   --right           
//do combat1

elseif getPlayerLookDir(cid) == 2 then    --down
 //do combat2           

elseif getPlayerLookDir(cid) == 3 then   --left
 //do combat3             

elseif getPlayerLookDir(cid) == 0 then   --up
 //do combat4           
     end
     end
function mow_1(cid)   
       doPlayerSendTextMessage(cid,TALKTYPE_ORANGE_1, 'test')   
       doPlayerSendTextMessage(cid,TALKTYPE_ORANGE_1, 'test2')
           //how add function player_look here?
     end
function onCastSpell(creature, variant)
//how add function mow_1 here?

return TRUE
end
</code>
 
Last edited:
Solution
Try this...

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 77)
combat:setArea(createCombatArea(FALA_G_P))
function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 7
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 11
    return -min, -max
end
combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    addEvent(speak, 0, creature:getId())
    local p = Player(creature)
    if p then
        if p:getDirection() == 1 then   --right        
            combat:execute(creature, variant)
        elseif p:getDirection()...
there are alot of ways to call a function but i think easiest to use AddEvent(mow_1(creature), 1000)
or you can use it directly like this mow_1(creature)
 
Last edited:
addEvent(x, 10 * 1000, creature:getId())
why creature:get id? Is work but i getting traceback
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/spells/scripts/zoltagruba.lua:32: attempt to index global 'creature' (a nil
value)
stack traceback:
[C]: in function '__index' data/spells/scripts/spellname.lua:32: in function <data/spells/scripts/spellname.lua:29>

+ why doCreatureSay(cid,'test',TALKTYPE_ORANGE_1) wont work?
 
Last edited:
why creature:get id? Is work but i getting traceback
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/spells/scripts/zoltagruba.lua:32: attempt to index global 'creature' (a nil
value)
stack traceback:
[C]: in function '__index' data/spells/scripts/spellname.lua:32: in function <data/spells/scripts/spellname.lua:29>

+ why doCreatureSay(cid,'test',TALKTYPE_ORANGE_1) wont work?

1.x uses userdata values insted of "integers", you have to make sure it's still a valid userdata value before executing anything.
If the player logs before the script is executed you could (atleast in the past) crash the server by running w/e function ex player:getName()
Thats because creature does not exist, maybe player? Or post the script.
If thats a function from the script it's not converted, if you feel lazy you could use cid:getId() but thats not really correct since you will still be running the compat functions for the rest of the file.

Post the script.
 
This wont work :(
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 77)
combat:setArea(createCombatArea(FALA_G_P))
function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 7
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 11
    return -min, -max
end
combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onCastSpell(creature, variant)
addEvent(speak,0,creature:getId()) 
if isPlayer(cid) == TRUE and
getPlayerLookDir(cid) == 1 then   --right           
combat:execute(creature, variant)
elseif isPlayer(cid) == TRUE and
getPlayerLookDir(cid) == 2 then    --down
combat:execute(creature, variant)         
elseif isPlayer(cid) == TRUE and
getPlayerLookDir(cid) == 3 then   --left
 combat:execute(creature, variant)             
elseif isPlayer(cid) == TRUE and
getPlayerLookDir(cid) == 0 then   --up
combat:execute(creature, variant)      
end
return TRUE
end
function speak(cid)
doCreatureSay(cid,'Test',TALKTYPE_ORANGE_1)
end
On tfs 0.3.6 was more easy o_O

#ref anyone? :C
 
Last edited by a moderator:
I almost didn't help you because you sound like a 5 year old trying to explain what they want.

Code:
local combat = Combat()
    combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
    combat:setParameter(COMBAT_PARAM_EFFECT, 77)
    combat:setArea(createCombatArea(FALA_G_P))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 7
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 11
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    player = Player(creature) // <--- Adds player user data if possible
        if player then // <-- Checks if the userdata was added
            combat:execute(creature, variant)
            player:say("Test", TALKTYPE_ORANGE_1, player:getPosition()) // <-- Look how i did it.
end
return TRUE
end

Learn how to space your code and add tabs.
 
Try this...

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 77)
combat:setArea(createCombatArea(FALA_G_P))
function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 7
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 11
    return -min, -max
end
combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    addEvent(speak, 0, creature:getId())
    local p = Player(creature)
    if p then
        if p:getDirection() == 1 then   --right        
            combat:execute(creature, variant)
        elseif p:getDirection() == 2 then    --down
            combat:execute(creature, variant)      
        elseif p:getDirection() == 3 then   --left
            combat:execute(creature, variant)          
        elseif p:getDirection() == 0 then   --up
            combat:execute(creature, variant)    
        end
    return TRUE
    end
end
function speak(cid)
    local p = Player(cid)
    if not p then
        return
    end
    p:say("TEST!", TALKTYPE_MONSTER_SAY)
    return true
end
 
Last edited:
Solution
Wow, this is really bad.

Code:
function onCastSpell(creature, variant)
    addEvent(speak, 0, creature:getId())
    local p = Player(cid)

See anything wrong here?
 
Thanks @Itutorial , I edited it, the problem consist in 'local p = Player(cid)', where cid is nill, now I changed it to 'local p = Player(creature)' now it shot works @narkotyko , also sorry for that mistake, and also, the direction available are:
Code:
DIRECTION_NORTH
DIRECTION_EAST
DIRECTION_SOUTH
DIRECTION_WEST
DIRECTION_SOUTHWEST
DIRECTION_SOUTHEAST
DIRECTION_NORTHWEST
DIRECTION_NORTHEAST
and not only "NORTH, SOUTH, EAST, WEST, ETCETERA", need the DIRECTION_
 
Also 1,2,3,0 work on direction, thanks you guys so much! :) Is there any way to add exhaust between function?
Code:
addEvent(speak, 0, creature:getId())
    local p = Player(creature)
    if p then <<before this i wanna 2 second exhaust
 
Last edited:
Back
Top