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

Request: Premium scroll script!

panantha

New Member
Joined
Apr 14, 2012
Messages
1
Reaction score
0
As the title say I need a script so I can implicate premium scrolls in to my 8.54 OT Server (TFS 0.3.6 pl1)
Any help would be appreciated!

Some details:

A premium scroll should last for 7 days after you right click on it.
If you log out in the premium city once your premium has run out, you will be teleported to the main temple (x: 1000, y: 1000, z: 7) upon next login.
The ID for the Premium scroll (custom server) is 11460.


Kind regards,
Panantha
 
function onUse(cid, item, frompos, item2, topos)
doPlayerAddPremiumDays(cid, 7)
doPlayerSendTextMessage(cid, 22, "You have been credited with 7 premium account days.")
return TRUE
end
 
At Actions/actions.xml add this line:
Code:
<action itemid="11460" event="script" value="premiumscroll.lua"/>

Add this at actions/scripts/ make new lua name it: premiumscroll.lua

Lua:
local this_script_is_awesome = true -- The choice is your if you want the script work then you leave it true

local otswe = {
prem_days = 7, -- Edit how many days
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if this_script_is_awesome == true then
if isPlayer(cid) then
doPlayerAddPremiumDays(cid, otswe.prem_days)
doSendAnimatedText(getCreaturePosition(cid), otswe.prem_days, TEXTCOLOR_RED)
doPlayerSendTextMessage(cid, 19, "Gratz you have obtained +7 premium days.")
doRemoveItem(item.uid, 1)
else
doPlayerSendTextMessage(cid, 19, "The admin dont want to admit it -.-.")
end
end
end

And this in creaturescripts/scripts/login.lua make sure the script is under
Code:
function onLogin(cid)
Lua:
local otswe = {
tp_pos = {x = 1000, y = 1000, z = 7}
}

if isPlayer(cid) then
if not isPremium(cid) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You has been teleported, because your premium has ended.")
doTeleportThing(cid, otswe.tp_pos, true)
end
return TRUE
end
 
@up

organize plx?

Lua:
local config = {
	prem_days = 7, -- Edit how many days
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isPlayer(cid) then
		doPlayerAddPremiumDays(cid, config.prem_days)
		doSendAnimatedText(getCreaturePosition(cid), config.prem_days, TEXTCOLOR_RED)
		doPlayerSendTextMessage(cid, 19, "Congralutions, you have obtained more 7 days of premium account.")
		doRemoveItem(item.uid, 1)
	else
	doPlayerSendTextMessage(cid, 19, "Sorry, not possible.")
	end
end

Lua:
local config = {
	tp_pos = {x = 1000, y = 1000, z = 7}
}
 
if isPlayer(cid) then
	if not isPremium(cid) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You has been teleported, because your premium has ended.")
		doTeleportThing(cid, config.tp_pos, true)
	end
return TRUE
end

I think is really better this way xd
 
So would one remove
Code:
local otswe = {
tp_pos = {x = 1000, y = 1000, z = 7}
}
Then replace
Code:
doTeleportThing(cid, otswe.tp_pos, true)
With
Code:
doPlayerSetTown(cid, townid)

should that work? Because as it is it teleports the player every time they log in if in premium town or not. You go hunting in no Premmy town, log off, come back later POOF your in the temple again, very annoying lol
 
Im trying to do this. When player logs in
If not premium - and town not ID 2
set town ID 2 and teleport player to town

If now premium - and town ID IS 2
then do send message xxxx

But it only teleports everytime even if town ID is 2
Code:
function onLogin(cid)

if isPlayer(cid) then
if not isPremium(cid) then
doPlayerSetTown(cid, 2)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You has been teleported, because your premium has ended.")
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
            doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
elseif getPlayerTown(cid) == 2 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your premium has ended.")
end
return TRUE
end
 
You can use isInRange.
Code:
if not isPremium(cid) and isInRange(getPlayerPosition(cid), {x = 100, y = 100, z = 7}, {x = 200, y = 200, z = 7}) then
Then change the positions to the positions in the premium area.
 
Ok so wrote this code. Limos pointed out it does not contain enough "end" statements
Code:
function onLogin(cid)

local playerTown = getPlayerTown(cid)
if isPlayer(cid) then
if playerTown ~= 2 then  -- <-- not sure if this is right or not
if not isPremium(cid) then
doPlayerSetTown(cid, 2)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You has been teleported, because your premium has ended.")
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
elseif playerTown == 2 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your premuim has ended")
end
return TRUE
end

so edited

Code:
function onLogin(cid)

local playerTown = getPlayerTown(cid)
if isPlayer(cid) then
if playerTown ~= 2 then
if not isPremium(cid) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You has been teleported, because your premium has ended.")
doPlayerSetTown(cid, 2)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
end
end
  end
return TRUE
end
Uhoh but then it says '<eof>' expected near 'end'

so removed one "end" statement from above code, all works fine
Script checks to see if player is or is not premuim, if not and if town ID is not premmy town teleport player to premmy town and set town ID.

If player is not premmy and town ID is premmy town, nothing happens

Working code here
Code:
function onLogin(cid)

local playerTown = getPlayerTown(cid)
if isPlayer(cid) then
if playerTown ~= 2 then
if not isPremium(cid) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You has been teleported, because your premium has ended.")
doPlayerSetTown(cid, 2)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
end
end
return TRUE
end
Thanks Limos for the help
 
An end is just to close an if statement or something else, it's not a statement by itself as it's not stating anything :p
Remove if isPlayer(cid) then, this is never needed in a login script.

Btw, try to tab/indent your scripts next time.
 
An end is just to close an if statement or something else, it's not a statement by itself as it's not stating anything :p
Remove if isPlayer(cid) then, this is never needed in a login script.
staement..close..words lol ok so im not a programmer I use hillbilly slang
I added an extry wurd whert it wernt needed :p
thanks again !! :D
 
Ok rewritten because I think the previous code was ending function onLogin for the rest of the script below it. (if I understand this correctly)

This worked so far. If player is NOT premium and town ID IS NOT premium town
script will teleport player to premmy town, set players town ID to premmy town.
If player IS NOT premium and town ID IS already set to premium town
only sends message "you premium has expired. This avoids teleporting your players back to temple every time they log in.
UPDATED: removed if isPlayer(cid)

PHP:
local playerTown = getPlayerTown(cid)
if playerTown ~= 2 then
if not isPremium(cid) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You has been teleported, because your premium has ended.")
doPlayerSetTown(cid, 2)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
end
else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "your premium has ended.")
return TRUE
end
 
Last edited:
If you tab/indent the script you can see that a player will get that message always if the townid is not 2.
Code:
function onLogin(cid)
     if getPlayerTown(cid) ~= 2 then
         if not isPremium(cid) then
             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You has been teleported, because your premium has ended.")
             doPlayerSetTown(cid, 2)
             doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
         end
     else
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "your premium has ended.")
         return TRUE
     end
     return true
end
So better remove it.

You can also use isInRange and check if the player is not premium and in the premium area, like this there won't be any mixed up actions from not premium members who time is already over for a long time or never were premium or premium members who's premium time is over but simply don't have town id 2.
 
Ahhhh your right. Redone. Works now.


PHP:
function onLogin(cid)

local playerTown = getPlayerTown(cid)
       if playerTown ~= 2 then
       if not isPremium(cid) then
       doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You has been teleported, because your premium has ended.")
       doPlayerSetTown(cid, 2)
       doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
  end
  return TRUE
end
       if playerTown == 2 then
       if not isPremium(cid) then
      doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "your premium has ended.")
  end
  return TRUE
end

Ill try if isInRange later today
 
Last edited:
Back
Top