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

CreatureEvent Teleport players in premium area who loose premium to free account temple

Serp

/* No comment */
Joined
Mar 23, 2008
Messages
249
Reaction score
1
Just a small script someone wanted me to make. apparnatly other people want the same i'm throwing it up here.

Hope this is of some use to people. my first release =\

Login.lua
PHP:
PremDay = getPlayerPremiumDays(cid) -- Checks premium player days
ftemple = {x=438, y=503, z=8} -- This is the Free account temple position
Prem1 = {x=370, y=592, z=7} -- This is the top left Co-ord for checking the Premium area.
Prem2 = {x=403, y=645, z=7} -- This is the bottom right co-ord for checking the Premium area.

-- Top left, and bottom right co-ords exist because isInArea function checks a SQAURE area. from top left to bottom right

function onLogin(cid)
	if isInArea(getPlayerPosition(cid), Prem1, Prem2) then
		if PremDay < 1 then
			doTeleportThing(cid, ftemple)
			doPlayerSendTextMessage(cid,24,"You no longer have a premium account, Please renew your premium to gain access to the premium areas.")
		end
	end
	registerCreatureEvent(cid, "PlayerDeath")
return TRUE
end


And this anywhere in Global.lua
PHP:
-- Function isInaArea by Colandus!
function isInArea(pos, fromPos, toPos)
    if pos.x >= fromPos.x and pos.x <= toPos.x then
        if pos.y >= fromPos.y and pos.y <= toPos.y then
            if pos.z >= fromPos.z and pos.z <= toPos.z then
                return true
            end
        end
    end
    return false
end
 
Last edited:
Its already tested on someone elses TFS and it worked. and the Best 0.2 is out lol. it came out a few hours ago
 
Code:
Prem1 = {x=370, y=592, z=7} -- This is the top left Co-ord for checking the Premium area.
Prem2 = {x=403, y=645, z=7} -- This is the bottom right co-ord for checking the co-ord

What I write in this x,y,z ? Temple of Pacc City ?
 
Code:
Prem1 = {x=370, y=592, z=7} -- This is the top left Co-ord for checking the Premium area.
Prem2 = {x=403, y=645, z=7} -- This is the bottom right co-ord for checking the co-ord

What I write in this x,y,z ? Temple of Pacc City ?

-- This is the top left Co-ord for checking the Premium area.
-- This is the bottom right co-ord for checking the co-ord

@top

50/50 ;p
 
@ Schikell
Thats used to Define the area it checks. so it needs to check the premmy land

PHP:
   |---- First co-ordinate
  \/
 [X]
           ____________
        __|            |
     __|                |
    |                    |
    |   Premmy area   ___/
    |                /
     \______      __/
            |____/     
                              [X]<-- Second Co-ordinate.


The co-ordinates make a Box shape. and then check the area INSIDE the box see if the player is there

PHP:
   |---- First co-ordinate
  \/
 [X]____________________________
  |        ____________         |
  |      __|            |       |
  |   __|                |      | <--- The Box
  |  |                    |     |
  |  |   Premmy area   ___/     |
  |  |                /         |
  |   \______       __/          |
  |          |____/             |
  |____________________________[X]<-- Second Co-ordinate.

Hope that answered your question ;D

~ Samme
PHP:
-- This is the bottom right co-ord for checking the co-ord
lol my fault that was a small typo. i corrected it
 
Last edited:
Script is working when i add Prem3?
Only add Prem3 & Prem4 if you want to check 2 Premium areas.

Example:
PHP:
PremDay = getPlayerPremiumDays(cid) -- Checks premium player days
ftemple = {x=438, y=503, z=8} -- This is the Free account temple position
-- 1st premium area check
Prem1 = {x=370, y=592, z=7} -- This is the top left Co-ord for checking the Premium area.
Prem2 = {x=403, y=645, z=7} -- This is the bottom right co-ord for checking the Premium area.
-- 2nd premium area check
Prem3 = {x=370, y=592, z=7} -- 2nd Prem area to check 1st co-rd
Prem4 = {x=403, y=645, z=7} -- 2nd Prem area to check 2nd co-ord

-- Top left, and bottom right co-ords exist because isInArea function checks a SQAURE area. from top left to bottom right

function onLogin(cid)
    if isInArea(getPlayerPosition(cid), Prem1, Prem2) or isInArea(getPlayerPosition(cid), Prem3, Prem4) then
        if PremDay < 1 then
            doTeleportThing(cid, ftemple)
            doPlayerSendTextMessage(cid,24,"You no longer have a premium account, Please renew your premium to gain access to the premium areas.")
        end
    end
    registerCreatureEvent(cid, "PlayerDeath")
return TRUE
end
 
Wouldn't this lag if i place it on a huge island? since it has to check a couple of 100 000 sqms each time someone logon the server?

//Massen
 
Nop it will not, that's why I made that function. I've seen people looping areas to look for ONE SPECIFIC PLAYER, so I decided to make that function and release it to avoid very unnecessary looping.

As you see the isInArea function is only using if-statements and no loops.

@Script
It will not work as the getPlayerPremDays~ is outside the onLogin function. Also please declare your variables local!
Here's a little fix :)
PHP:
local templePos = {x=438, y=503, z=8} -- This is the Free account temple position

local townPositions = {
    { -- Ankrahmun
        topLeft = {x=370, y=592, z=5},
        bottomRight = {x=403, y=645, z=8}
    },
    { -- Edron
        topLeft = {x=770, y=366, z=5},
        bottomRight = {x=910, y=733, z=8}
    },
}

function onLogin(cid)
    if getPlayerPremiumDays(cid) < 1 then
        for _, positions in pairs(townPositions) do
            if isInArea(getPlayerPosition(cid), positions.topLeft, positions.bottomRight) then
                doTeleportThing(cid, templePos)
                doPlayerSendTextMessage(cid, 24, "You no longer have a premium account. Please renew your premium to gain access to the premium areas.")
                break
            end
        end
    end
    registerCreatureEvent(cid, "PlayerDeath")
    return TRUE
end


Or maybe if you don't want to use "topLeft" and "bottomRight":
PHP:
local templePos = {x=438, y=503, z=8} -- This is the Free account temple position

local townAreas = {
    {fromx=370, fromy=592, fromz=5, tox=403, toy=645, toz=8}, -- Ankrahmun
    {fromx=770, fromy=366, fromz=5, tox=910, toy=733, toz=8} -- Edron
}

function onLogin(cid)
    if getPlayerPremiumDays(cid) < 1 then
        for _, area in ipairs(townAreas) do
            if isInArea(getPlayerPosition(cid), area) then
                doTeleportThing(cid, templePos)
                doPlayerSendTextMessage(cid, 24, "You no longer have a premium account. Please renew your premium to gain access to the premium areas.")
                break
            end
        end
    end
    registerCreatureEvent(cid, "PlayerDeath")
    return TRUE
end

And then the isInArea:
PHP:
-- Function isInaArea by Colandus!
function isInArea(pos, area)
    if pos.x >= area.fromx and pos.x <= area.tox then
        if pos.y >= area.fromy and pos.y <= area.toy then
            if pos.z >= area.fromz and pos.z <= area.toz then
                return true
            end
        end
    end
    return false
end
 
Last edited:
It does not work in TFS 3.0b!

PHP:
ftemple = {x=289, y=216, z=7} -- This is the Free account temple position
Prem1 = {x=500, y=760, z=7} -- This is the top left Co-ord for checking the Premium area.
Prem2 = {x=650, y=900, z=7} -- This is the bottom right co-ord for checking the Premium area.
PHP:
if isInArea(getCreaturePosition(cid), Prem1, Prem2) then
       PremDay = isPremium(cid) -- Checks premium player days
        if PremDay < 1 then
            doTeleportThing(cid, ftemple)
            doPlayerSendTextMessage(cid,24,"You no longer have a premium account, Please renew your premium to gain access to the premium areas.")
		end
    end
 
And, you've forgot to change the temple position. If you die you'd just end up at the premmy island again.
 
Hello,error please

hello,in have error aim use tfs 0.2(scrip of colandus)

PHP:
13/12/2008  09:34:28] Lua Script Error: [CreatureScript Interface] 
[13/12/2008  09:34:28] data/creaturescripts/scripts/login.lua:onLogin

[13/12/2008  09:34:28] data/global.lua:651: attempt to compare nil with number
[13/12/2008  09:34:28] stack traceback:
[13/12/2008  09:34:28] 	data/global.lua:651: in function 'isInArea'
[13/12/2008  09:34:28] 	data/creaturescripts/scripts/login.lua:169: in function <data/creaturescripts/scripts/login.lua:166>
 
This works, but then my shop that gesior made doesn't work.
And when i change the name to login3.lua And adding this line to creaturescripts.lua
PHP:
<event type="login" name="PlayerLogin" script="login3.lua"/>

It doesn't work. Can someone please help me out?
 
Back
Top