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

Battle Area

AIMSHOT

New Member
Joined
Jul 2, 2015
Messages
56
Reaction score
1
Location
Spain
Hello everyone,

I wana asking for Battle Npc Area the players should have 10 Arena tokens and max 2 players can entra this area i already create map for it i hope someone create that npc for me ;)

TFS 0.4
client version:- 8.6
token item id:- 9020


Thank you Guys and here you are pic of area
BxBjldS.jpg

 
have fun :) #AIMSHOT
Code:
local config = {
one = {
item_Id     = 9020 , -- Arena tokens
item_Count  = 10    -- Count
} ,

teleport_to = {x = 2000, y = 2000, z = 7} ,

GlobalStorage = 57894 -- set here free GlobalStorage

}


local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)            npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                    npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
---------------------------------------------------------------------

    if(not npcHandler:isFocused(cid)) then
        return false
    end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

if msgcontains(msg, "enter")  or msgcontains(msg, "arena")  then
selfSay('Did you bring me '..config.one.item_Count..' Arena tokens ?', cid)
talkState[talkUser] = 1
  
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) and getGlobalStorageValue(config.GlobalStorage) < 2 then
if getPlayerItemCount(cid,config.one.item_Id) >= config.one.item_Count then
    if doPlayerRemoveItem(cid, config.one.item_Id,config.one.item_Count) then
         selfSay('Here you go, have a fun trip to arena .', cid)
         doTeleportThing(cid,config.teleport_to)
        setGlobalStorageValue( config.GlobalStorage, getGlobalStorageValue(config.GlobalStorage) == -1 and 1 or getGlobalStorageValue( config.GlobalStorage) + 1)
    end
    else
        selfSay('Sorry, you don\'t have these items .', cid)
    talkState[talkUser] = 0
return true
end

elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) and getGlobalStorageValue(config.GlobalStorage) == 2 then
    selfSay('Sorry, there are two players in arena .', cid)
    talkState[talkUser] = 0

elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
selfSay('Maybe one day you will wise up and change your mind!', cid)
talkState[talkUser] = 0
  
  
end
    return true
end


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Thank you i'll test it

But i got another idea please can u try to do it?

Maybe they can 1 from 3 area...

Player:- hi
NPC:- Choes one from 3 arena Room 1 / 2/ 3
Player:- Room 1
NPC:- it will cost you 10 token are you sure u wana teleport to room 1?
Player:- Yes
Npc:- Enjoy Your Hunting Room 1 :)
 
Last edited by a moderator:
ummm ok

have fun # AIMSHOT
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local talkState, xmsg = {}, {}

function onCreatureAppear(cid)         npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)       npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)       npcHandler:onCreatureSay(cid, type, msg) end
function onThink()           npcHandler:onThink() end

local locations = {
     ["Room 1"] = {pos = {x = 2000, y = 2000, z = 7}, cost = 10, GlobalStorage = 50001},
     ["Room 2"] = {pos = {x = 2000, y = 2000, z = 7}, cost = 10, GlobalStorage = 50002},
     ["Room 3"] = {pos = {x = 2000, y = 2000, z = 7}, cost = 10, GlobalStorage = 50003}
}

local function Cptl(f, r)
     return f:upper()..r:lower()
end

function creatureSayCallback(cid, type, msg)
     if not npcHandler:isFocused(cid) then
         return false
     end

     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

     local x = locations[msg:gsub("(%a)([%w_']*)", Cptl)]
     if msgcontains(msg, 'travel') or msgcontains(msg, 'passage') then
         if getPlayerPremiumDays(cid) >= 0 then
             selfSay('Where do you want to go? I can bring you to { Room 1 }, { Room 2 } or { Room 3 }.', cid)
             talkState[talkUser] = 1
         else
             selfSay('Travel is only for premium.', cid)
         end
     elseif x and talkState[talkUser] == 1 then
         selfSay('Do you want to travel to '..msg..' for '..x.cost..' token?', cid)
         xmsg[cid] = msg
         talkState[talkUser] = 2
      
     elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
              x = locations[xmsg[cid]:gsub("(%a)([%w_']*)", Cptl)]
    if getGlobalStorageValue(x.GlobalStorage) < 2 then
         if doPlayerRemoveItem(cid,9020, x.cost) then
             selfSay('Here you go, have a fun trip to '..xmsg[cid]..'.', cid)
             doTeleportThing(cid, x.pos)
             setGlobalStorageValue(x.GlobalStorage, getGlobalStorageValue(x.GlobalStorage) == -1 and 1 or getGlobalStorageValue(x.GlobalStorage) + 1)
             talkState[talkUser] = 0
            else
             selfSay('You don\'t have enough token.', cid)
         end
          else
       selfSay('Sorry, there are two players in area .', cid)
         talkState[talkUser] = 0
    end
     else
         selfSay('What? I don\'t understand what you mean with '..msg..'.', cid)
         talkState[talkUser] = 0
     end
     return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited by a moderator:
you are welcome tell me if you get any problem or want to change any thing

it will take time always when i start the server get my pc lagy and take time to up the server but i'll try thank you very much ;)

@Sir Islam
Can you help me to create an npc to change ur sex? :)
for 15 token Itemid:- 9020
 
Last edited by a moderator:
@Sir Islam
Can you help me to create an npc to change ur sex? :)
for 15 token Itemid:- 9020
have fun

Code:
local config = {
one = {
item_Id     = 9020 , -- Arena tokens
item_Count  = 15    -- Count
}
}


local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)            npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                    npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
---------------------------------------------------------------------

    if(not npcHandler:isFocused(cid)) then
        return false
    end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

if msgcontains(msg, "changesex")  or msgcontains(msg, "change")  then
selfSay('Did you bring me '..config.one.item_Count..' tokens ?', cid)
talkState[talkUser] = 1
 
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if getPlayerItemCount(cid,config.one.item_Id) >= config.one.item_Count then
    if doPlayerRemoveItem(cid, config.one.item_Id,config.one.item_Count) then
         selfSay('You have changed your sex  .', cid)
        doPlayerSetSex(cid, getPlayerSex(cid) == 0 and 1 or 0)
    end
    else
        selfSay('You don\'t have enough token.', cid)
    talkState[talkUser] = 0
return true
end


elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
selfSay('Maybe one day you will wise up and change your mind!', cid)
talkState[talkUser] = 0
 
end
    return true
end


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Jnlgi1A.png

no such or directory
make file name battlearea.lua and put the code on it

load small map in test to load server fast and don't get lag
 
Last edited by a moderator:
i already do that :)
thanks

Those 2 scripts Works Prefect i dont know how i can thank i swear ;)

But something more i need when i talk to Changender Npc

Player:- Hi
Npc:- hello ~ , To change your sex you have to say Change

Update.
 
Last edited by a moderator:
Those 2 scripts Works Prefect i dont know how i can thank i swear ;)

no problem i dont take time when i make scripts and easy to make :)

xd this from npc.xml file

Code:
    <parameters>
        <parameter key="message_greet" value="Hello |PLAYERNAME|.To change your sex you have to say Change ."/>
        <parameter key="message_farewell" value="Good bye my dear friend."/>
    </parameters>
 
Back
Top