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

Convert Castle War for Tfs 1.2

igorlabanca

New Member
Joined
Aug 15, 2010
Messages
36
Reaction score
3
I really need to convert this script to tfs 1.2 because it is the most important of my server.
Note: shows no error

Thanks :)

Code:
function onUse(cid, item, frompos, item2, topos)

local castle_one_name = "GH"               
local storages = {154154,54321,123123}             

local premio_por_vezes = 1       
local premio_vezes = 1          
local premio = 5956               
local premio_cont = 1            
local premio_reset = 1  
local sto_ativ = getGlobalStorageValue(storages[2])
position = getCreaturePosition(cid)      

local hora = tonumber(os.date("%H"))
                   
                    if hora < 22 or hora > 22 then
                        doPlayerSendTextMessage(cid,18,"A Guild House só pode ser invadida entre as 22 e 23 horas.")
                        return true
                           end
if item.itemid == 9826 then
            doTransformItem(9826)
            doPlayerSendCancel(cid,"A Guild House ja foi invadida hoje.")
            return false
            end
           
if item.itemid == 9825 then
for posx = 1254,1256 do
for posy = 690,690 do
local pos = {x=posx, y=posy, z=6, stackpos=253}
local creature = getThingfromPos(pos)
if isMonster(creature.uid) then
doTransformItem(9825)
doPlayerSendTextMessage(cid,18,"Para dominar a guild house é necessario matar os guardas.")
return false
end
end
end
end
           


   if isPlayerGuild(cid) == TRUE then
      if sto_ativ == 1 or sto_ativ == -1 then

         guildname = getPlayerGuildName(cid)    
         guild = getPlayerGuildId(cid)              
         guild_sto = getGlobalStorageValue(storages[3])
                 
            if guild ~= guild_sto then           
               setPlayerStorageValue(cid,guild_sto,guild)                     
               if getPlayerStorageValue(cid,storages[1]) == -1 then
                  setPlayerStorageValue(cid,storages[1],0)
               end
              
               sto_vezes = getPlayerStorageValue(cid,storages[1])                  
              
               setGlobalStorageValue(storages[3],getPlayerGuildId(cid))
               setPlayerStorageValue(cid,storages[1], sto_vezes + 1)
              
               sto_vezes_total = getPlayerStorageValue(cid,storages[1])
                       
               doPlayerSendTextMessage(cid, 18,  "A guild "..getPlayerGuildName(cid).." acaba de dominar a Guild House de Dol\'Guldur!")
                
                 if premio_por_vezes == 1 then
                    if getPlayerStorageValue(cid,storages[1]) == premio_vezes then
                       if getItemWeightById(premio,1) <= getPlayerFreeCap(cid) then
                          doPlayerAddItem(cid, premio,premio_cont)

                            if premio_reset == 1 then                   
                               setPlayerStorageValue(cid,storages[1],0) 
                            end                                         

                       
                       else
                       doPlayerSendTextMessage(cid, 18, "Voce nao tem capacidade para ganhar o item. Vamos verificar novamente em 10 segundos!")
                       addEvent(additem,10000,cid,premio,premio_cont,premio_reset)
                       end
                    end                                       
                 end              
            else
              doPlayerSendCancel(cid,"Sua guild já está dominando a guild house.")
              doTransformItem(9825)
            end
      else
      doPlayerSendCancel(cid,"O sistema está desativado")
      end     
   else
   doPlayerSendCancel(cid,"É nescessario ter guild para dominar a guild house.")
   doTransformItem(9825)
   end
end


function isPlayerGuild(cid)
if getPlayerGuildName(cid) ~= "" then
return TRUE
else
return FALSE
end
end
 
I think it's better that you try to convert it by yourself. It's really easy, just change for example:
FROM:
Code:
function onUse(cid, item, frompos, item2, topos)
TO:
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)

Another example:
FROM:
Code:
local sto_ativ = getGlobalStorageValue(storages[2])
position = getCreaturePosition(cid)    

local hora = tonumber(os.date("%H"))
                 
                    if hora < 22 or hora > 22 then
                        doPlayerSendTextMessage(cid,18,"A Guild House só pode ser invadida entre as 22 e 23 horas.")
                        return true
                           end
if item.itemid == 9826 then
            doTransformItem(9826)
            doPlayerSendCancel(cid,"A Guild House ja foi invadida hoje.")
            return false
            end
TO:
Code:
local sto_ativ = Game.getStorageValue(storages[2])
position = creature:getPosition() --Im not sure if put creature or player.  

local hora = tonumber(os.date("%H"))
                 
                    if hora < 22 or hora > 22 then
                       player:sendTextMessage(18,"A Guild House só pode ser invadida entre as 22 e 23 horas.")
                        return true
                           end
if item.itemid == 9826 then
            doTransformItem(9826)
            player:sendTextCancel("A Guild House ja foi invadida hoje.")
            return false
            end
You see? It's easy, you only have to change some functions like:
getGlobalStorageValue()
TO:
Game.getStorageValue()

And how you gonna do that? Just see your compat.lua. You can find it on libs folder and then compat folder.
Good luck ^^
 

Similar threads

Back
Top