• 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 TFS 0.4 Block Spells

FearWar

Active Member
Joined
Sep 17, 2017
Messages
221
Reaction score
26
Location
Brasil
Hi otlanders,

I'm using the script below, but I would like to put more places with block, but this place only exists 1 place.

Lua:
local pos = {
              minx = 19197,
              maxx = 19268,
              miny = 17468,
              maxy = 17530
}
              
function onSay(cid, words, param, channel)
    if getThingPos(cid).x >= pos.minx and getThingPos(cid).x <= pos.maxx and getThingPos(cid).y >= pos.miny and getThingPos(cid).y <= pos.maxy then
        doPlayerSendCancel(cid,"You cant use this spell inside the Zombie Event!")
           return true
    end
end

I would improve the script for example:

Lua:
local zombie = {
              minx = 19197,
              maxx = 19268,
              miny = 17468,
              maxy = 17530
}
local firestorm = {
              minx = 19197,
              maxx = 19268,
              miny = 17468,
              maxy = 17530
}
local castle = {
              minx = 19197,
              maxx = 19268,
              miny = 17468,
              maxy = 17530
}
 
Solution
Lua:
local onepos = {
  frompos = {x=31694, y=32709, z=7},
  topos = {x=31744, y=32774, z=7},
}
local otherpos = {
  frompos = {x=31728, y=32704, z=7},
  topos = {x=31755, y=32763, z=7},
}
local onemorepos = {
  frompos = {x=771, y=2225, z=9},
  topos = {x=775, y=2229, z=9},
}
             
function onSay(cid, words, param, channel)
    if isInArea(getPlayerPosition(cid), onepos.frompos, onepos.topos) or isInArea(getPlayerPosition(cid), otherpos.frompos, otherpos.topos) or isInArea(getPlayerPosition(cid), onemorepos.frompos, onemorepos.topos) then
        doPlayerSendCancel(cid,"You cant use this spell inside the Zombie Event!")
           return true
    end
end
If it didn't work just change getPlayerPosition to getThingPos
Lua:
local onepos = {
  frompos = {x=31694, y=32709, z=7},
  topos = {x=31744, y=32774, z=7},
}
local otherpos = {
  frompos = {x=31728, y=32704, z=7},
  topos = {x=31755, y=32763, z=7},
}
local onemorepos = {
  frompos = {x=771, y=2225, z=9},
  topos = {x=775, y=2229, z=9},
}
             
function onSay(cid, words, param, channel)
    if isInArea(getPlayerPosition(cid), onepos.frompos, onepos.topos) or isInArea(getPlayerPosition(cid), otherpos.frompos, otherpos.topos) or isInArea(getPlayerPosition(cid), onemorepos.frompos, onemorepos.topos) then
        doPlayerSendCancel(cid,"You cant use this spell inside the Zombie Event!")
           return true
    end
end
If it didn't work just change getPlayerPosition to getThingPos
 
Solution
i go test!
Post automatically merged:

Lua:
local onepos = {
  frompos = {x=31694, y=32709, z=7},
  topos = {x=31744, y=32774, z=7},
}
local otherpos = {
  frompos = {x=31728, y=32704, z=7},
  topos = {x=31755, y=32763, z=7},
}
local onemorepos = {
  frompos = {x=771, y=2225, z=9},
  topos = {x=775, y=2229, z=9},
}
            
function onSay(cid, words, param, channel)
    if isInArea(getPlayerPosition(cid), onepos.frompos, onepos.topos) or isInArea(getPlayerPosition(cid), otherpos.frompos, otherpos.topos) or isInArea(getPlayerPosition(cid), onemorepos.frompos, onemorepos.topos) then
        doPlayerSendCancel(cid,"You cant use this spell inside the Zombie Event!")
           return true
    end
end
If it didn't work just change getPlayerPosition to getThingPos
i am go test
 
Alright if it didn't work then you can use this one its more simple/organized.
Lua:
local event_areas = {
    {{x = 999, y = 849, z = 7}, {x = 1029, y = 879, z = 7}}, -- {{from},{to}}
    {{x = 906, y = 831, z = 7}, {x = 963, y = 888, z = 7}}
}

function onSay(cid, words, param, channel)
 for i = 1, #event_areas do
 local cid_pos = getThingPosition(cid)
    if isPlayer(cid) and isInArea(cid_pos, event_areas[i][1], event_areas[i][2]) then
            doPlayerSendCancel(cid, "You can't use this spell here.")
            end
    return true
    end
end
 
Alright if it didn't work then you can use this one its more simple/organized.
Lua:
local event_areas = {
    {{x = 999, y = 849, z = 7}, {x = 1029, y = 879, z = 7}}, -- {{from},{to}}
    {{x = 906, y = 831, z = 7}, {x = 963, y = 888, z = 7}}
}

function onSay(cid, words, param, channel)
for i = 1, #event_areas do
local cid_pos = getThingPosition(cid)
    if isPlayer(cid) and isInArea(cid_pos, event_areas[i][1], event_areas[i][2]) then
            doPlayerSendCancel(cid, "You can't use this spell here.")
            end
    return true
    end
end
not work, no error on the console

that way the script is better, can you fix it?
 
u add the " , " in all the lines just the last is without it
ex

{{x = 999, y = 849, z = 7}, {x = 1029, y = 879, z = 7}}, -- {{from},{to}}
{{x = 906, y = 831, z = 7}, {x = 963, y = 888, z = 7}},
{{x = 906, y = 831, z = 7}, {x = 963, y = 888, z = 7}},
{{x = 906, y = 831, z = 7}, {x = 963, y = 888, z = 7}}
 
u add the " , " in all the lines just the last is without it
ex

{{x = 999, y = 849, z = 7}, {x = 1029, y = 879, z = 7}}, -- {{from},{to}}
{{x = 906, y = 831, z = 7}, {x = 963, y = 888, z = 7}},
{{x = 906, y = 831, z = 7}, {x = 963, y = 888, z = 7}},
{{x = 906, y = 831, z = 7}, {x = 963, y = 888, z = 7}}
Yes bro, you can check, the last one is without ",".
 
Try it

Lua:
local config = {
    { {x = 2253, y = 2318, z = 6}, {x = 2256, y = 2321, z = 6} },
    { {x = 2261, y = 2318, z = 6}, {x = 2265, y = 2320, z = 6} }
}

function onSay(cid, words, param, channel)

    for i = 1, #config do
        local from = {x = config[i][1].x, y = config[i][1].y, z = config[i][1].z}
        local to = {x = config[i][2].x, y = config[i][2].y, z = config[i][2].z}
        if (isPlayer(cid) and isInRange(getThingPosition(cid), from, to)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You can't use spell here.")
            doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
            return true
        end
    end
    return true
end

@FearWar
 
Try it

Lua:
local config = {
    { {x = 2253, y = 2318, z = 6}, {x = 2256, y = 2321, z = 6} },
    { {x = 2261, y = 2318, z = 6}, {x = 2265, y = 2320, z = 6} }
}

function onSay(cid, words, param, channel)

    for i = 1, #config do
        local from = {x = config[i][1].x, y = config[i][1].y, z = config[i][1].z}
        local to = {x = config[i][2].x, y = config[i][2].y, z = config[i][2].z}
        if (isPlayer(cid) and isInRange(getThingPosition(cid), from, to)) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You can't use spell here.")
            doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
            return true
        end
    end
    return true
end

@FearWar
Thanks bro!
 
Back
Top