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

-.Ktz

New Member
Joined
Feb 11, 2016
Messages
37
Reaction score
1
Can anyone tell me if this is right script
use tfs 1.2

Code:
if isPlayer(creature:getTarget()) and creature:getTarget() ~= getTopCreature(Variant.getPosition(variant)).uid then
  creature:sendCancelMessage("You can not shoot this directly on players.")
  return false
end

the script is to make the player can not attack using the hotkeys in use on target only with crosshairs
 
Code:
local target = creature:getTarget()

if not target then
    return false
end

local vpos = variant:getPosition()

if target:isPlayer() and target:getId() == getTopCreature(vpos).uid then
    creature:sendCancelMessage("You can not shoot this directly on players.")
    return false
end
 
Last edited:
Show us the entire script not just a tiny part of it, if you do this with an onUse event then you can check if it's done by hotkey with "isHotkey"
You cannot determine through var if the action is performed by a hotkey or by a crosshair action.
If it's not done by onUse then you have to add a new parameter to your event which can detect if it's done by a hotkey or not (no way around source edits here)
 
Show us the entire script not just a tiny part of it, if you do this with an onUse event then you can check if it's done by hotkey with "isHotkey"
You cannot determine through var if the action is performed by a hotkey or by a crosshair action.
If it's not done by onUse then you have to add a new parameter to your event which can detect if it's done by a hotkey or not (no way around source edits here)
We don't always need the whole script to find a solution to a problem, but I get what you are saying.

Could always just swap out variant with toPosition.
 
Here the entire code
Code:
function onCastSpell(creature, variant)
   local target = creature:getTarget()
   if not target then
    return false
   end

   local vpos = variant:getPosition()

   if target:isPlayer() and target:getId() == getTopCreature(vpos).uid then
    creature:sendCancelMessage("You can not shoot this directly on players.")
    return false
   end

   if isPlayer(variant:getNumber()) then
  creature:sendCancelMessage("You can not shoot this directly on players.")
  return false
   end

   return combat:execute(creature, variant)
end
still does not work if you are not attacking the player the rune does not come out and is attacking it shows You can not shoot this message directly on players.
 
Here the entire code
Code:
function onCastSpell(creature, variant)
   local target = creature:getTarget()
   if not target then
    return false
   end

   local vpos = variant:getPosition()

   if target:isPlayer() and target:getId() == getTopCreature(vpos).uid then
    creature:sendCancelMessage("You can not shoot this directly on players.")
    return false
   end

   if (variant:getNumber()) then
  creature:sendCancelMessage("You can not shoot this directly on players.")
  return false
   end

   return combat:execute(creature, variant)
end
still does not work if you are not attacking the player the rune does not come out and is attacking it shows You can not shoot this message directly on players.
isPlayer does not take arguments, also if you are going to test different conditions use different strings.

change this
getTopCreature(vpos).uid
to
getTopCreature(vpos):getId()
 
Last edited:
Still nothing, if not the target the player only the message of the rune
09:36 Using one of 98 sudden death runes ...

if you're in the target shows You can not shoot this message directly on players.
 
ok just to clear things up and I do not misunderstand you.
You want the rune to be exclusively used at a player if it's done by crosshair and not by hotkey or am I wrong here?
 
Code:
function onCastSpell(creature, variant)
    local target = creature:getTarget()
    if not target then
        return false
    end

    local vpos = variant:getPosition()

    if target:isPlayer() and target:getId() == getTopCreature(vpos):getId() then
        creature:sendCancelMessage("You can not shoot this directly on players.")
        return false
    end

    return combat:execute(creature, variant)
end
 
I can't believe its taking you soo long.. no need to test just write it, if it doesn't work it doesn't work.. bet you use a calculator to do simple arithmetic too :p
 
Back
Top