• 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 Help with War OTS

Mr Zool

New Member
Joined
Jul 5, 2012
Messages
216
Reaction score
2
I creating "Unique" war server and i need some help.

First of all my "Frag Reward doesnt work" :
xml : <event type="kill" name="Reward" script="fragreward.lua"/>
lua :
function onKill(cid, target)
local reward = {
item = 2160, --ITEM ID!
count = 1 -- How many?
}
if(isPlayer(cid) and isPlayer(target)) then
doPlayerAddItem(cid, reward.item, reward.count)
end
return true
end

login :
registerCreatureEvent(cid, "FragReward")


Im Looking also for script
Login in random temple :
t1 t2 ....
cant find
 
login : registerCreatureEvent(cid, "FragReward")
xml : <event type="kill" name="Reward" script="fragreward.lua"/>

Data/creaturescripts/login.lua:
Code:
local templepositions = {[/SIZE][/SIZE]
[SIZE=6][SIZE=4]    {x=,y=,z=},
    {x=,y=,z=}
}
local areas = {
    {frompos = {x=,y=,z=}, topos = {x=,y=,z=}},
    {frompos = {x=,y=,z=}, topos = {x=,y=,z=}}
}
for i = 0, table.maxn(templepositions) do
    if isInArea(getThingPos(cid), areas[i].frompos, areas[i].topos) then
        doTeleportThing(cid, templepositions[math.random(1, table.maxn(templepositions))]
        doSendMagicEffect(cid, CONST_ME_TELEPORT)
    end
end

This will teleport the player to any of the temple positions you put in the table IF he is standing inside one of the temples already (to prevent players from randomly teleporting to a temple everytime they login, unless you want them to be teleported every single time they relog, just tell me and I will change it). To add a new temple, you must:
1- Create a new line in the table (templepositions),
2- Copy one of the lines in the table (templepositions),
3- Paste it on the new line, then change the x, y, z values to your new position,
4- Make sure all the lines end with a ",", except the last line.
5- Go to the second table (areas), then create a new line in it,
6- Copy one of the lines already in the table (areas), then change the values as such:
frompos: Is the northwest corner of your new temple, if it is not "squareshaped" then you must pick the top northwest corner that would be symmetrical with your northeast corner,
topos: Is the southeast corner of your new temple, same rules like above if the temple is not squareshaped.
You can also create multiple values in the areas table for a single temple instead of locating the symmetrical corner.
 
Last edited:
[Error - LuaInterface::loadFile] data/creaturescripts/scripts/login.lua:24: unexpected symbol near ','

this is 24 line :
{frompos = {x=552,y=561,z=6}, topos = {x=528,y=565,z=6},
{frompos = {x528=,y=465,z=7}, topos = {x=534,y=469,z=7}
}
 
can u say what you change please?
Like this ?
Code:
local areas = {
    {frompos = {x=479,y=512,z=7}, topos = {x=505,y=518,z=7},
    {frompos = {x=444,y=481,z=7}, topos = {x=451,y=484,z=7},
    {frompos = {x=427,y=504,z=6}, topos = {x=431,y=512,z=6},
    {frompos = {x=476,y=561,z=7}, topos = {x=482,y=565,z=7},
    {frompos = {x=552,y=561,z=6}, topos = {x=528,y=565,z=6},
    {frompos = {x528=,y=465,z=7}, topos = {x=534,y=469,z=7}}
}
or everywhere {x=528,y=565,z=6}},
like this ?


Still error :
[5/10/2013 10:36:44] [Error - LuaInterface::loadFile] data/creaturescripts/scripts/login.lua:24: unexpected symbol near ','
[5/10/2013 10:36:44] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/login.lua)
 
Last edited:
Missing bracket at the end, all of them need it because there is a bracket before frompos

{frompos = {x=552,y=561,z=6}, topos = {x=528,y=565,z=6}},
 
Taken from my old war server. Set the available town ids and add it to login.lua

Code:
    local towns = {1,2,3,4,5,6,7,8}
    doTeleportThing(cid,getTownTemplePosition(towns[math.random(#towns)]))
 
[5/10/2013 13:28:1] [Error - CreatureScript Interface]
[5/10/2013 13:28:1] data/creaturescripts/scripts/login.lua
[5/10/2013 13:28:1] Description:
[5/10/2013 13:28:1] (luaDoTeleportThing) Thing not found
 
-- To dodajemy w miejsce słów function onLogin(cid) (in english -- Here you add words "Function onlogin(cid)

local towns = {1,2,3,4,5,6,7,8}
doTeleportThing(cid,getTownTemplePosition(towns[math.random(#towns)]))

Code:
[5/10/2013 16:38:20] [Error - CreatureScript Interface]
[5/10/2013 16:38:20] data/creaturescripts/scripts/login.lua
[5/10/2013 16:38:20] Description:
[5/10/2013 16:38:20] (luaDoTeleportThing) Thing not found
 
Back
Top