• 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
Joined
Nov 17, 2010
Messages
6,828
Solutions
586
Reaction score
5,409
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:
Hey your chest script yesterday didnt work :(

The Error
Code:
[02/04/2016 16:46:07] [Error - Action Interface]
[02/04/2016 16:46:07] data/actions/scripts/youbro/goldset.lua:eek:nUse
[02/04/2016 16:46:07] Description:
[02/04/2016 16:46:07] data/actions/scripts/youbro/magicset.lua:41: attempt to index field '?' (a number value)
[02/04/2016 16:46:07] stack traceback:
[02/04/2016 16:46:07]     data/actions/scripts/youbro/magicset.lua:41: in function 'getAllItemWeight'
[02/04/2016 16:46:07]     data/actions/scripts/youbro/goldset.lua:18: in function <data/actions/scripts/youbro/goldset.lua:10>

The Action
Code:
<action uniqueid="4014" event="script" value="youbro/goldset.lua"/>



The Lua goldset.lua
Code:
local storage = 4014

local items = {
   [1] = {item_id = 2471, item_count = 1},
   [2] = {item_id = 2646, item_count = 1},
   [3] = {item_id = 2470, item_count = 1},
   [4] = {item_id = 2466, item_count = 1}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

   if getPlayerStorageValue(cid, storage) == 1 then
     doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
     doPlayerSendCancel(cid, "It is empty.")
     return true
   end

   if getAllItemWeight(weight) > getPlayerFreeCap(cid) then
     doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
     doPlayerSendCancel(cid, "You require ".. string.format("%.2f", getAllItemWeight(weight)) .." capacity to obtain this reward.")
     return true
   end

   item = doCreateItemEx(1987, 1)
   if (doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
     doPlayerSendCancel(cid, "You require free inventory space to obtain this reward.")
   else
     for i = 1, #items do
       doAddContainerItem(item, items.item_id, items.item_count)
     end
     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a ".. getItemNameById(1987) .." weighing ".. string.format("%.2f", getAllItemWeight(weight)) .." oz.")
     setPlayerStorageValue(cid, storage, 1)
   end
  
   return true
end

function getAllItemWeight(weight)
   local item = {}
   local count = {}
   local weight = 0
   for i = 1, #items do
     table.insert(items, items.item_id)
     table.insert(count, items.item_count)
   end
   for i = 1, #item do
     weight = (weight + (getItemWeightById(item, count)))
   end
   return weight
end
Code:
local storage = 4014

local items = {
  [1] = {item_id = 2471, item_count = 1},
  [2] = {item_id = 2646, item_count = 1},
  [3] = {item_id = 2470, item_count = 1},
  [4] = {item_id = 2466, item_count = 1}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
   
   if getPlayerStorageValue(cid, storage) == 1 then
     doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
     doPlayerSendCancel(cid, "It is empty.")
     return true
   end
   
   if getAllItemWeight(weight) + 8 > getPlayerFreeCap(cid) then
     doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
     doPlayerSendCancel(cid, "You require ".. string.format("%.2f", getAllItemWeight(weight) + 8) .." capacity to obtain this reward.")
     return true
   end
   
   item = doCreateItemEx(1987, 1)
   if (doPlayerAddItemEx(cid, item, false) ~= RETURNVALUE_NOERROR) then
     doPlayerSendCancel(cid, "You require free inventory space to obtain this reward.")
   else
     for i = 1, #items do
       doAddContainerItem(item, items.item_id, items.item_count)
     end
     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a ".. getItemNameById(1987) .." weighing ".. string.format("%.2f", getAllItemWeight(weight) + 8) .." oz.")
     setPlayerStorageValue(cid, storage, 1)
   end
   
   return true
end

function getAllItemWeight(weight)
   local item = {}
   local count = {}
   local weight = 0
   for i = 1, #items do
     table.insert(items, items.item_id)
     table.insert(count, items.item_count)
   end
   for i = 1, #item do
     weight = (weight + (getItemWeightById(item, count)))
   end
   return weight
end
 
Xikini that's so unnecessary... My script is so much cleaner then yours.
As far as cleanliness goes, yours doesn't even have proper tabbing.. and if you tested your script, you'd notice how broken it is.
I felt it was quite necessary.
 
@Elpulpo

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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
   
    player = Player(cid)
   
    if msgcontains(msg, 'trade') then
        if player:getStorageValue(storage) == 1 then
            addEvent(sendShop, 0)
        else
            selfSay("I wont do busness with you.", cid, true)
        end
    end

    return true
end


function sendShop()
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addBuyableItem({'death arrow'}, 2263, 300, 3, 'death arrow rune')

shopModule:addSellableItem({'wand of vortex', 'vortex'}, 2190, 250, 'wand of vortex')
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Broken because it sends a message for each item separately?
It doesn't check cap properly (to be fair my original post didn't either.), and it doesn't check if they have inventory space.
Telling them each individual item is fine.
 
ummm the script automatically does that because I didn't put TRUE on the part to add the bag....

Meaning the bag will only be made if the player has room. So the only broken part I see with that is the bag needs to check if it can be made before it sets the players storage value.
 
ummm the script automatically does that because I didn't put TRUE on the part to add the bag....

Meaning the bag will only be made if the player has room. So the only broken part I see with that is the bag needs to check if it can be made before it sets the players storage value.
I'm not going to bicker with you.
He can use yours or mine, I don't care either way.
 
Can you help me adding 1 greet word to 1 npc? (not all npc)
I use othire (it's like avesta)
I'm not sure how to do it for avesta, but the standard npc system can use this..
Code:
 -- place this at the top with the other functions.
function greet(cid)
    npcHandler:setMessage(MESSAGE_GREET, "Hello! What can I smith for you today?")
    return true
end
Code:
npcHandler:setCallback(CALLBACK_GREET, greet) -- place this at the very bottom of your code
Can you help me make the vocation script the other day you made for me only lvl 8 can get the warlock vocation?
Add this to the script inside the function, directly underneath the storage value check
Code:
if getPlayerLevel(cid) ~= 8 then
    doPlayerSendCancel(cid, "You must be level 8 to use this statue.")
    return true
end
@Xikini thanks very much for the script works perfectly :)

Edit: is it possible to add more than 1 item id that gives the same reward ?
Never saw the edit until today.
Untested though.
Code:
local config = {
     [1] = {   take_item_id = 2544,
         take_item_count = 5,
         give_item_id = 2546,
         give_item_count = 3,
         effect = CONST_ME_EXPLOSIONHIT,
         pos = {x = 1397, y = 1422, z = 7}
         },
     [2] = {   take_item_id = 2544,
         take_item_count = 5,
         give_item_id = 2546,
         give_item_count = 3,
         effect = CONST_ME_EXPLOSIONHIT,
         pos = {x = 1397, y = 1422, z = 7}
         },
     [3] = {   take_item_id = 2544,
         take_item_count = 5,
         give_item_id = 2546,
         give_item_count = 3,
         effect = CONST_ME_EXPLOSIONHIT,
         pos = {x = 1397, y = 1422, z = 7}
         },
}
local lever_timer = 2

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

local function getItemCountOnPosition(item, pos)
     local item_pos = {x = pos.x, y = pos.y, z = pos.z}
     local item_count = 0
     for i = 1, 255 do
         local check_pos = {x = item_pos.x, y = item_pos.y, z = item_pos.z, stackpos = i}
         if getThingFromPos(check_pos).itemid <= 0 then
             break
         elseif getThingFromPos(check_pos).itemid == item then
             if isItemStackable(getThingFromPos(check_pos).itemid) == true then
                 item_count = item_count + getThingFromPos(check_pos).type
             else
                 item_count = item_count + 1
             end
         end
     end   
     return item_count
end

function onUse(cid, item, fromPosition, itemEx, toPosition)

     -- check if lever is currently used
     if item.itemid == 1946 then
         return doPlayerSendTextMessage(cid, 22, "Wait for switch to reset.")
     end
     
     -- check if items are on tile
     for i = 1, #config do
         if getItemCountOnPosition(config[i].take_item_id, config[i].pos) >= config[i].take_item_count then
             doRemoveItem(getTileItemById(config[i].pos, config[i].take_item_id).uid, config[i].take_item_count)
             addEvent(doCreateItem, 200, config[i].give_item_id, config[i].give_item_count, config[i].pos)
             doSendMagicEffect(config[i].pos, config[i].effect)
         else
             doSendMagicEffect(config[i].pos, CONST_ME_POFF)
         end
     end
     
     -- transform lever, and add reset
     doTransformItem(item.uid, item.itemid + 1)
     addEvent(reset, lever_timer * 1000, toPosition)
   
     return true
end
 
Last edited:
I'm not sure how to do it for avesta, but the standard npc system can use this..
Code:
 -- place this at the top with the other functions.
function greet(cid)
    npcHandler:setMessage(MESSAGE_GREET, "Hello! What can I smith for you today?")
    return true
end
Code:
npcHandler:setCallback(CALLBACK_GREET, greet) -- place this at the very bottom of your code
I requested one greet word not greet message... Instead of hi I want another word to get focus. But I don't want to change the default greet word for another npcs
 
I requested one greet word not greet message... Instead of hi I want another word to get focus. But I don't want to change the default greet word for another npcs
Code:
function creatureSayCallback(cid, type, msg)
   if msgcontains(msg, 'hail') or msgcontains(msg, 'hello') or msgcontains(msg, 'salutations') and not npcHandler:isFocused(cid) then
      npcHandler:say('I greet thee..', cid, TRUE)
      npcHandler:addFocus(cid)
   end
  
   .
   .
   . rest of script
   .
   .
   .
  
   return true
end
 
Thanks Xikini how do I fix the stages script? i put in true for stages for my server but my exp says x0 even if im lvl 300 or 200 or 100 or 8 it says x0 exp rate

Code:
<?xml version="1.0" encoding="UTF-8"?>
<stages>
    <world id="0" multiplier="1">
        <stage minlevel="1" maxlevel="80" multiplier="300"/>
        <stage minlevel="81" maxlevel="123" multiplier="250"/>
        <stage minlevel="124" maxlevel="130" multiplier="225"/>
        <stage minlevel="131" maxlevel="150" multiplier="200"/>
        <stage minlevel="151" maxlevel="230" multiplier="150"/>
        <stage minlevel="231" maxlevel="350" multiplier="100"/>
        <stage minlevel="351" multiplier="50"/>
        </world>
</stages>
 
Thanks Xikini how do I fix the stages script? i put in true for stages for my server but my exp says x0 even if im lvl 300 or 200 or 100 or 8 it says x0 exp rate

Code:
<?xml version="1.0" encoding="UTF-8"?>
<stages>
    <world id="0" multiplier="1">
        <stage minlevel="1" maxlevel="80" multiplier="300"/>
        <stage minlevel="81" maxlevel="123" multiplier="250"/>
        <stage minlevel="124" maxlevel="130" multiplier="225"/>
        <stage minlevel="131" maxlevel="150" multiplier="200"/>
        <stage minlevel="151" maxlevel="230" multiplier="150"/>
        <stage minlevel="231" maxlevel="350" multiplier="100"/>
        <stage minlevel="351" multiplier="50"/>
        </world>
</stages>
No idea. It all looks fine to me.
 
Is there something wrong with this?


Code:
    experienceStages = True
    rateExperience = 0
    rateExperienceFromPlayers = 100
    rateSkill = 10.0
    rateMagic = 10.0
    rateLoot = 7.0
    rateSpawn = 10
 
rateExperience = 0
change to

rateExperience = 1
 
Is there something wrong with this?


Code:
    experienceStages = True
    rateExperience = 0
    rateExperienceFromPlayers = 100
    rateSkill = 10.0
    rateMagic = 10.0
    rateLoot = 7.0
    rateSpawn = 10

try replacing
Code:
 experienceStages = True
with
Code:
 experienceStages = true
Shouldn't make any difference with capital letter or not, just try it.
 
Status
Not open for further replies.
Back
Top