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

Xikini's Free Scripting Service. [0.3.7 & (0.3.6/0.4)]

Status
Not open for further replies.

Xikini

I whore myself out for likes
Senator
Premium User
Joined
Nov 17, 2010
Messages
6,800
Solutions
582
Reaction score
5,363
Doing quick (30 min or less) scripts for [0.3.7 & (0.3.6/0.4)]
I am not here to fix your broken scripts, although I will give advice if requested.
I am here for script requests of scripts not already available on the forum.
If you require support for your scripting issues please make a thread in the support section.

For clarity's sake,
I will script actionscripts, creaturescripts, globalevents, talkactions, movements, npcs for you.
I will not script spells, weapons, raids or monster scripts.
Additionally, source editing, websites and database queries are a no go as well.

Code:
How to make shorter links to posts.
https://otland.net/threads/234306/page-14#post-2330703
 
Last edited:
Change outfit ring ? For example when you use outfit ring - you are able to wear outfit "x" and it appear at outfitwindow so you are able to change colours. Protocol 7.72
So if a player has XXXX item equipped, they have YYYY outfit unlocked?
And if the player removes XXXX item, while they have YYYY outfit equipped, they get changed to default citizen outfit?
 
So if a player has XXXX item equipped, they have YYYY outfit unlocked?
And if the player removes XXXX item, while they have YYYY outfit equipped, they get changed to default citizen outfit?
Sorry for late answer i was out of home.
Exactly as you said. Is it possible to code ?
 
Sorry for late answer i was out of home.
Exactly as you said. Is it possible to code ?
yeah yeah, of course it's possible. xP

First you'll need to create an outfit that is not available by default.
Each tfs has a slightly different outfits.xml, so change it how you think it needs to be done.
Mine looks like this.
XML:
<outfit id="30" premium="yes" default="0">
    <list gender="0" lookType="513" name="Crystal Warlord"> </list>
    <list gender="1" lookType="512" name="Crystal Warlord"> </list>
</outfit>

After you have an outfit like that, find an item that is equipable, and then install the following scripts.

data/movements/movements.xml
(I tested mine with an amazon helmet)
XML:
<movevent type="Equip" itemid="2499" slot="head" event="script" value="test_movement_script.lua"/>
<movevent type="DeEquip" itemid="2499" slot="head" event="script" value="test_movement_script.lua"/>
data/movements/scripts/test_movement_script.lua
(change "30" to your outfit id, and change 513 & 512 to your respective looktypes)
(Look here, for the reason of some parts of the code. [Fix] [0.3.7 / 0.4 / 0.3.6] Multiple onEquip bug.)
Lua:
function onEquip(cid, item, slot, boolean)
   if boolean == false then
       doPlayerAddOutfitId(cid, 30, 0) -- 3 = both addons, 0 = no addons
   end
   return callFunction(cid, item.uid, slot, boolean)
end

function onDeEquip(cid, item, slot, boolean)
   local temp = getCreatureOutfit(cid)
   if isInArray({513, 512}, temp.lookType) then
       temp.lookType = getPlayerSex(cid) == 0 and 136 or 128
       temp.lookAddons = 0
       doCreatureChangeOutfit(cid, temp)
   end
   doPlayerRemoveOutfitId(cid, 30)
   return callFunction(cid, item.uid, slot, boolean)
end
 
Hi, i need one script in tfs 0.4:


There is a chair on the map, which the player should step on, and when he exits the chair, the script should show: you have X seconds in the chair. THX!
 
Hi, i need one script in tfs 0.4:
There is a chair on the map, which the player should step on, and when he exits the chair, the script should show: you have X seconds in the chair. THX!

P3j3AZJ.png

XML:
<movevent type="StepIn" actionid="45001" event="script" value="put_aid_under_the_chair.lua"/>
Lua:
local function countTimeOnChair(cid, counter, position)
   if not isPlayer(cid) then
       return true
   end
   local cid_p = getThingPosition(cid)
   if cid_p.x == position.x and cid_p.y == position.y then
       addEvent(countTimeOnChair, 0, cid, counter + 0.1, position)
   else
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You were on the chair for " .. counter .. " seconds!")
   end
end

function onStepIn(cid, item, position, fromPosition)
   if not isPlayer(cid) then
       return true
   end
   addEvent(countTimeOnChair, 0, cid, 0, position)
   return true
end
 
P3j3AZJ.png

XML:
<movevent type="StepIn" actionid="45001" event="script" value="put_aid_under_the_chair.lua"/>
Lua:
local function countTimeOnChair(cid, counter, position)
   if not isPlayer(cid) then
       return true
   end
   local cid_p = getThingPosition(cid)
   if cid_p.x == position.x and cid_p.y == position.y then
       addEvent(countTimeOnChair, 0, cid, counter + 0.1, position)
   else
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You were on the chair for " .. counter .. " seconds!")
   end
end

function onStepIn(cid, item, position, fromPosition)
   if not isPlayer(cid) then
       return true
   end
   addEvent(countTimeOnChair, 0, cid, 0, position)
   return true
end
os.mtime() is a thing, you can save os.mtime() and use os.mtime() - saved to = milliseconds stood on chair
 
Hello Xikini,i'm glad otland have your services.. I think i need help, i want to make when i press LEVER NUMBER ONE ( IT TP PEOPLE TO X,Y,Z LOCATION)
AND WHEN I PRESS SECOND LETTER ( IT TP PEOPLE TO X,Y,Z, OTHER LOCATION)
Here is example :Screenshot_1.png Screenshot_2.png Screenshot_3.png
P.S FORGOT TO SAY ITS TFS 0.4, 8.6 TIBIA
 
os.mtime() is a thing, you can save os.mtime() and use os.mtime() - saved to = milliseconds stood on chair
You butt. xD

Siiigh.
I didn't think it was worth the hassle to get the exact time.
But since you mentioned it... xP

XML:
<movevent event="StepIn" actionid="45001" script="put_aid_under_the_chair.lua" />
<movevent event="StepOut" actionid="45001" script="put_aid_under_the_chair.lua" />
Lua:
global_chair_counter = {}

function onStepIn(cid, item, position, fromPosition)
   if not isPlayer(cid) then
       return true
   end
   local cur_time = os.mtime()
   global_chair_counter[cid] = cur_time
   return true
end

function onStepOut(cid, item, position, lastPosition)
   if not isPlayer(cid) then
       return true
   end
   local cur_time = os.mtime()
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You were on the chair for " .. (cur_time - global_chair_counter[cid]) / 1000 .. " seconds!")
   return true
end
 
Hello Xikini,i'm glad otland have your services.. I think i need help, i want to make when i press LEVER NUMBER ONE ( IT TP PEOPLE TO X,Y,Z LOCATION)
AND WHEN I PRESS SECOND LETTER ( IT TP PEOPLE TO X,Y,Z, OTHER LOCATION)
Here is example :View attachment 31474 View attachment 31475 View attachment 31476
P.S FORGOT TO SAY ITS TFS 0.4, 8.6 TIBIA
Xikini what you say about my problem ? :p
If your getting strange errors, change this line
Lua:
-- line 71
local unique_id = item.uid -- change from this
local unique_id = item.uniqueid -- to this
Code:
19:24 You see a switch.
ItemID: [1945], ActionID: [45000], UniqueID: [45001].

19:24 You see a switch.
ItemID: [1945], ActionID: [45000], UniqueID: [45002].

19:24 You see a switch.
ItemID: [1945], ActionID: [45000], UniqueID: [45003].
XML:
<action actionid="45000" event="script" value="teleport_multiple_players.lua"/>
Lua:
local config = {
   [45001] = {
       check_positions = {
           {x = 1000, y = 1000, z = 7, stackpos = 253},
           {x = 1001, y = 1000, z = 7, stackpos = 253}
       },
       teleport_positions = {
           {x = 1000, y = 1001, z = 7},
           {x = 1001, y = 1001, z = 7}
       }
   },
   [45002] = {
       check_positions = {
           {x = 1000, y = 1000, z = 7, stackpos = 253},
           {x = 1001, y = 1000, z = 7, stackpos = 253},
           {x = 1002, y = 1000, z = 7, stackpos = 253}
       },
       teleport_positions = {
           {x = 1000, y = 1001, z = 7},
           {x = 1001, y = 1001, z = 7},
           {x = 1002, y = 1001, z = 7}
       }
   },
   [45003] = {
       check_positions = {
           {x = 1000, y = 1000, z = 7, stackpos = 253},
           {x = 1001, y = 1000, z = 7, stackpos = 253},
           {x = 1002, y = 1000, z = 7, stackpos = 253},
           {x = 1003, y = 1000, z = 7, stackpos = 253},
           {x = 1004, y = 1000, z = 7, stackpos = 253}
       },
       teleport_positions = {
           {x = 1000, y = 1001, z = 7},
           {x = 1001, y = 1001, z = 7},
           {x = 1002, y = 1001, z = 7},
           {x = 1003, y = 1001, z = 7},
           {x = 1004, y = 1001, z = 7}
       }
   }
}

local function teleportPlayers(table_location)
   for i = 1, #table_location.check_positions do
       doTeleportThing(getThingFromPosition(table_location.check_positions[i]).uid, table_location.teleport_positions[i])
       doSendMagicEffect(table_location.check_positions[i], CONST_ME_POFF)
       doSendMagicEffect(table_location.teleport_positions[i], CONST_ME_POFF)
   end
end

local function countPlayers(table_location)
   for i = 1, #table_location.check_positions do
       if not isPlayer(getThingFromPosition(table_location.check_positions[i]).uid) then
           return false
       end
   end
   teleportPlayers(table_location)
   return true
end

local function reset(pos)
   doTransformItem(getTileItemById(pos, 1946).uid, 1945)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
   if item.itemid == 1946 then
       doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
       doPlayerSendCancel(cid, "Wait for switch to reset.")
       return true
   end

   local unique_id = item.uid
   if config[unique_id] then
       if countPlayers(config[unique_id]) then
           doTransformItem(getTileItemById(toPosition, 1945).uid, 1946)
           addEvent(reset, 60 * 1000, toPosition)
       else
           doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
           doPlayerSendCancel(cid, "Not enough players for this action.")
       end
   end
   return true
end
Sorry about this "flood", but i had to say I amire your job. Congratulations, Xikini, great scripts!
and I thank you for that. :oops:
 
I'm a bit retarded or something is wrong,can you explain to me step by step,where to put what and stuff? It doesnt show any errors just wont work
 
I'm a bit retarded or something is wrong,can you explain to me step by step,where to put what and stuff? It doesnt show any errors just wont work
xml script -> goes into data/actions/actions.xml
lua script -> goes into data/actions/scripts/teleport_multiple_players.lua

Check my pm if you need more help.
 
xml script -> goes into data/actions/actions.xml
lua script -> goes into data/actions/scripts/teleport_multiple_players.lua

Check my pm if you need more help.
You butt. xD

Siiigh.
I didn't think it was worth the hassle to get the exact time.
But since you mentioned it... xP

XML:
<movevent event="StepIn" actionid="45001" script="put_aid_under_the_chair.lua" />
<movevent event="StepOut" actionid="45001" script="put_aid_under_the_chair.lua" />
Lua:
global_chair_counter = {}

function onStepIn(cid, item, position, fromPosition)
   if not isPlayer(cid) then
       return true
   end
   local cur_time = os.mtime()
   global_chair_counter[cid] = cur_time
   return true
end

function onStepOut(cid, item, position, lastPosition)
   if not isPlayer(cid) then
       return true
   end
   local cur_time = os.mtime()
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You were on the chair for " .. (cur_time - global_chair_counter[cid]) / 1000 .. " seconds!")
   return true
end

[15/01/2018 00:05:23] data/movements/scripts/test.lua:16: attempt to call field 'mtime' (a nil value)
[15/01/2018 00:05:23] stack traceback:
[15/01/2018 00:05:23] data/movements/scripts/test.lua:16: in function <data/movements/scripts/test.lua:12>
 
[15/01/2018 00:05:23] data/movements/scripts/test.lua:16: attempt to call field 'mtime' (a nil value)
[15/01/2018 00:05:23] stack traceback:
[15/01/2018 00:05:23] data/movements/scripts/test.lua:16: in function <data/movements/scripts/test.lua:12>
I already tested the script, it's working 100%. o_O
and why would it only error when you stepOut and not when you stepIn?

Makes no sense to me.

Only suggestion I can offer is to make sure you copy/pasted script fully, or use the original one I posted which doesn't use "os.mtime()".
 
I already tested the script, it's working 100%. o_O
and why would it only error when you stepOut and not when you stepIn?

Makes no sense to me.

Only suggestion I can offer is to make sure you copy/pasted script fully, or use the original one I posted which doesn't use "os.mtime()".

I used the first script where it does not use os.mtime and it is 100%, thank you!
 
I already tested the script, it's working 100%. o_O
and why would it only error when you stepOut and not when you stepIn?

Makes no sense to me.

Only suggestion I can offer is to make sure you copy/pasted script fully, or use the original one I posted which doesn't use "os.mtime()".


I'm trying to make a script with the function of the chair that you did for me, but I did not have, success, could you help me?

I wanted an event to count which guild was able to stay longer over the chair.

For example: The player Joao was 5 seconds in the chair and player Juca was 8 seconds (they are from the same guild), so the guild totaled 13 seconds.
The player Marcos was 2 seconds in the chair and player Kiko was 2 seconds (they are from the same guild), so the guild totaled 4 seconds.
Finally, the winning guild was the one with the highest points, thank you!
 
I'm trying to make a script with the function of the chair that you did for me, but I did not have, success, could you help me?

I wanted an event to count which guild was able to stay longer over the chair.

For example: The player Joao was 5 seconds in the chair and player Juca was 8 seconds (they are from the same guild), so the guild totaled 13 seconds.
The player Marcos was 2 seconds in the chair and player Kiko was 2 seconds (they are from the same guild), so the guild totaled 4 seconds.
Finally, the winning guild was the one with the highest points, thank you!
Would take too long to script and I have no way to accurately test each part of it.

Basically you'll want to create a global table, and have all time from the players added to their guilds or teams respective ID number, and store it in the table.
Then have a globalevent/talkaction/action script to start the timer for the game to start and end. I'd personally use a global storage for this part, just for convenience, unless there is going to be multiple locations.. then I'd just store everything into the global table.

And then of course the timing/score portion of the script would basically be the same as the above script, but instead of increasing the counter, you'd just increase the amount in the global table through each iteration.

The rest of the script would be cleaning up / resetting each part of the system, and of course sending the players to the event, returning them, creating some sort of reward system for the winning team, along with some anti-cheating measures and failsafes, in case players are logging in/out during the event, or the server restarts/crashes while players are in the event.

Hope that helps!
 
Would take too long to script and I have no way to accurately test each part of it.

Basically you'll want to create a global table, and have all time from the players added to their guilds or teams respective ID number, and store it in the table.
Then have a globalevent/talkaction/action script to start the timer for the game to start and end. I'd personally use a global storage for this part, just for convenience, unless there is going to be multiple locations.. then I'd just store everything into the global table.

And then of course the timing/score portion of the script would basically be the same as the above script, but instead of increasing the counter, you'd just increase the amount in the global table through each iteration.

The rest of the script would be cleaning up / resetting each part of the system, and of course sending the players to the event, returning them, creating some sort of reward system for the winning team, along with some anti-cheating measures and failsafes, in case players are logging in/out during the event, or the server restarts/crashes while players are in the event.

Hope that helps!


Hi!
The script of the event I already have.

When server starts, will set all globalstorage(getPlayersGuildId,0) -- > globalstorage(getPlayersGuildId) -> will be the counter storage

At the end of the event, he would have to get the largest globalStorage (getPlayerGuildId)

Here is the question: I should check the players that are online, and those with guild to check the largest globalstorage (getPlayerGuildId),
Is there any way to do this check? Thank you for answering my questions.
 
Status
Not open for further replies.
Back
Top