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

Action Shop lever rand

Avios

New Member
Joined
Dec 26, 2009
Messages
8
Reaction score
0
Hello.

Script is when you press the lever we buy a item but not as what we want just a random item.

Data/actions/script/NAME_SCRIPTS.lua
PHP:
function onUse(cid, item, frompos, item2, topos)
local item = {
      id = 2130,  -- id1 itemka
      id2 = XXXX,  -- id2 itemka
      id3 = XXXX  -- id3 itemka
}
local money = 4000
local rand = math.random(1, #item)
    if item.itemid == 1945 then
        if(doPlayerRemoveMoney(cid, money) == TRUE) then
            doPlayerAddItem(cid, item[rand])
            doPlayerSendTextMessage(cid, 22, "Brought ".. item.name ..".")
    elseif item.itemid == 1946 then
                if(doPlayerRemoveMoney(cid, money) == TRUE) then
                    doPlayerAddItem(cid, item[rand])
                    doPlayerSendTextMessage(cid, 22, "Brought ".. item.name ..".")
                end
        end
    end
    return TRUE
end

Data/actions.xml
PHP:
    <action uniqueid="1234" event="script" value="NAME_SCRIPTS.lua"/>
 
Last edited:
Whow to make it like... there are 2 slots (like this image)
24oafdw.jpg

1 g ingot = 100 golg nugets / 1 gold nuget = 100cc
And, if the player get X iten, he get a broadcast "Playername is to lucky to win itenX from lotery.
 
he put 1 gold ingot OR 100 golden nugets in the lower basin, and use the switch and he win a random iten in the up one
 
The one who give him the script, its not a good idea for sharing other servers scripts, make your own server instead of taking other people ideas + requesting it, atleast make it your self.
 
There is some inecessary things like:
In your script:
function onUse(cid, item, frompos, item2, topos) = function onUse(cid, item) '-'
Obs:
if item.itemid == 1945 then
if(doPlayerRemoveMoney(cid, money) == TRUE) then

Second if is inecessary '-'
If your server is 8.54 you can use this...

if item.itemid == 1945 and getPlayerMoney(cid) >= money then
doPlayerRemoveMoney(cid, money)


You can reduce that script man...
Don't take it like a critic... just take it like little help to the evolution...
 
There is some inecessary things like:
In your script:
function onUse(cid, item, frompos, item2, topos) = function onUse(cid, item) '-'
Obs:
if item.itemid == 1945 then
if(doPlayerRemoveMoney(cid, money) == TRUE) then

Second if is inecessary '-'
If your server is 8.54 you can use this...

if item.itemid == 1945 and getPlayerMoney(cid) >= money then
doPlayerRemoveMoney(cid, money)


You can reduce that script man...
Don't take it like a critic... just take it like little help to the evolution...

It works and it's shorter with if doPlayerRemoveMoney(cid, money).
 
On Call Of Duty 5 I bought random weapons on Zombie mode xD

Yeah ive recently mapped a custom replica of der reise with scripts for electrical fences and all mainframes, il use this for the random weapon box, so it is useful there are some screens of the map in map showoff on another site that people use
 
script not work D:

Code:
[29/04/2010 17:24:30] [Error - Action Interface] 
[29/04/2010 17:24:30] data/actions/scripts/other/random item.lua:onUse
[29/04/2010 17:24:30] Description: 
[29/04/2010 17:24:30] data/actions/scripts/other/random item.lua:8: bad argument #2 to 'random' (interval is empty)
[29/04/2010 17:24:30] stack traceback:
[29/04/2010 17:24:30] 	[C]: in function 'random'

Help please.
 
Last edited:
Back
Top