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

Need help fixing this scrpit

healer007

New Member
Joined
Nov 11, 2008
Messages
174
Reaction score
0
Location
doesnt matter
PHP:
function onUse(cid, item, frompos, item2, topos)
if doPlayerRemoveMoney(cid, 10000) == 1 then
doPlayerAddItem(cid, 2173, 1)
doPlayerSendTextMessage(cid,24,'You Bought An Amulet Of Loss For 10K')
else
			doPlayerSendCancel(cid, 'You don\'t have enough money.')
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
		end
		end

This scrpit works like this when you use item (eg switch) with uiq 17001 then you get aol for 10k + msg saying you bought the aol,but also says (you can not use the item) + when you have no money doesnt give error saying no enough money

Fix-
Should work like this Use (switch) get aol + msg saying you get aol, and when you have no money it should give error msg saying no money
Can anyone help me fix this scrpit?
 
PHP:
<action uniqueid="17001" script="myScript.lua" />
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if doPlayerRemoveMoney(cid, 10000) == TRUE then
        doPlayerAddItem(cid, 2173, 1)
        doCreatureSay(cid, getCreatureName(cid) .. " purchased an amulet of loss.", TALKTYPE_ORANGE_1, toPosition)
        doSendMagicEffect(getCreaturePosition(cid), 12)
    else
        doSendMagicEffect(getCreaturePosition(cid), 2)
        doPlayerSendCancel(cid, "You do not have enough money to purchase an amulet of loss.")
    end

    if item.itemid == 1945 then
        doTransformItem(item.uid, 1946)
    elseif item.itemid == 1946 then
        doTransformItem(item.uid, 1945)
    end
    return TRUE
end
 
i need swich remove 10 items and give 1 items
Chris, Jan 30, 2009
I think this might be one of the worst necro's I've seen in awhile.

Not sure what you meant, so here is two scripts, both untested.
Code:
local function reset(p)
   doTransformItem(getTileItemById(p, 1946).uid, 1945)
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
  
   if getPlayerItemCount(cid, 1111) >= 10 then
     doPlayerRemoveItem(cid, 1111, 10)
     doPlayerAddItem(cid, 2222, 1, true)
   end
  
   -- transform lever, and add reset
   doTransformItem(item.uid, item.itemid + 1)
   addEvent(reset, 10 * 1000, toPosition)

   return true
end

Code:
local t = {
   -- remove these items
   [1] = {item = 1111, count = 1},
   [2] = {item = 1111, count = 1},
   [3] = {item = 1111, count = 1},
   [4] = {item = 1111, count = 1},
   [5] = {item = 1111, count = 1},
   [6] = {item = 1111, count = 1},
   [7] = {item = 1111, count = 1},
   [8] = {item = 1111, count = 1},
   [9] = {item = 1111, count = 1},
   [10] = {item = 1111, count = 1},
   -- Give this item
   [11] = {item = 1111, count = 1}
}

local function reset(p)
   doTransformItem(getTileItemById(p, 1946).uid, 1945)
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
  
   i = 1
   count = 0
   for 1, 10 do
     if getPlayerItemCount(cid, t[i].item) >= t[i].count then
       count = count + 1
     end    
     i = i + 1
   end
   if count == 10 then
     i = 1
     for 1, 10 do
       doPlayerRemoveItem(cid, t[i].item, t[i].count)
       i = i + 1
     end
     doPlayerAddItem(cid, t[i].item, t[i].count, true)
   end
  
   -- transform lever, and add reset
   doTransformItem(item.uid, item.itemid + 1)
   addEvent(reset, 10 * 1000, toPosition)

   return true
end
 
Chris, Jan 30, 2009
I think this might be one of the worst necro's I've seen in awhile.

Not sure what you meant, so here is two scripts, both untested.
Code:
local function reset(p)
   doTransformItem(getTileItemById(p, 1946).uid, 1945)
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
 
   if getPlayerItemCount(cid, 1111) >= 10 then
     doPlayerRemoveItem(cid, 1111, 10)
     doPlayerAddItem(cid, 2222, 1, true)
   end
 
   -- transform lever, and add reset
   doTransformItem(item.uid, item.itemid + 1)
   addEvent(reset, 10 * 1000, toPosition)

   return true
end

Code:
local t = {
   -- remove these items
   [1] = {item = 1111, count = 1},
   [2] = {item = 1111, count = 1},
   [3] = {item = 1111, count = 1},
   [4] = {item = 1111, count = 1},
   [5] = {item = 1111, count = 1},
   [6] = {item = 1111, count = 1},
   [7] = {item = 1111, count = 1},
   [8] = {item = 1111, count = 1},
   [9] = {item = 1111, count = 1},
   [10] = {item = 1111, count = 1},
   -- Give this item
   [11] = {item = 1111, count = 1}
}

local function reset(p)
   doTransformItem(getTileItemById(p, 1946).uid, 1945)
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
 
   i = 1
   count = 0
   for 1, 10 do
     if getPlayerItemCount(cid, t[i].item) >= t[i].count then
       count = count + 1
     end   
     i = i + 1
   end
   if count == 10 then
     i = 1
     for 1, 10 do
       doPlayerRemoveItem(cid, t[i].item, t[i].count)
       i = i + 1
     end
     doPlayerAddItem(cid, t[i].item, t[i].count, true)
   end
 
   -- transform lever, and add reset
   doTransformItem(item.uid, item.itemid + 1)
   addEvent(reset, 10 * 1000, toPosition)

   return true
end


i want IT remove 12 Diffrent items and give 1 items Only Can Helped?
 
??
Code:
local t = {
     -- remove these items
     [1] = {item = 1111, count = 1},
     [2] = {item = 1111, count = 1},
     [3] = {item = 1111, count = 1},
     [4] = {item = 1111, count = 1},
     [5] = {item = 1111, count = 1},
     [6] = {item = 1111, count = 1},
     [7] = {item = 1111, count = 1},
     [8] = {item = 1111, count = 1},
     [9] = {item = 1111, count = 1},
     [10] = {item = 1111, count = 1},
     [11] = {item = 1111, count = 1},
     [12] = {item = 1111, count = 1},
     -- Give this item
     [13] = {item = 1111, count = 1}
}

local function reset(p)
     doTransformItem(getTileItemById(p, 1946).uid, 1945)
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
    
     i = 1
     count = 0
     for 1, #t do
         if getPlayerItemCount(cid, t[i].item) >= t[i].count then
             count = count + 1
         end  
         i = i + 1
     end
     if count == #t - 1 then
         i = 1
         for 1, 10 do
             doPlayerRemoveItem(cid, t[i].item, t[i].count)
             i = i + 1
         end
         doPlayerAddItem(cid, t[i].item, t[i].count, true)
     end
    
     -- transform lever, and add reset
     doTransformItem(item.uid, item.itemid + 1)
     addEvent(reset, 10 * 1000, toPosition)
    
     return true
end
 
:: Loading actions.xml...Warning: [Event::loadScript] Can not load script. data/
actions/scripts/demi parts.lua
data/actions/scripts/demi parts.lua:30: '<name>' expected near '1'
[done]

i use aries xml 0.4.0
 
show the code your using.
You must have set-up the table wrong somewhere.
 
i want fix script take 12 different item and give 1 item and Fix when i was in level 450k my spell was 10kk and when get 500k+ my spell by i think 5kk or 4kk
 
Back
Top