What's new

Skrypty & Kody random dla p?tli

Czopeq

Advanced User
Joined
Jun 29, 2015
Messages
191
Reaction score
6
Hello, chcia?em zrobi? to co jest w configu wy?wietla?o si? randomowo:
[LUA]config = {
[1] = { text="text1"},
[2] = { text="text12"},
[3] = { text="text123"}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local x = math.random(3)
for i, k in pairs(config) do
if item.itemid == 1945 then
doTransformItem(item.uid, 1946)
doPlayerSendTextMessage(cid,25,k.text)
doPlayerSendTextMessage(cid,22,"random: "..x.. " ")
elseif item.itemid == 1946 then
doTransformItem(item.uid, 1945)
end
return true
end
return true
end
[/LUA]
Tak ?eby ta randomowa cyfra do 3 by?a tym "i", jak x = 2 to wy?wietla tekst z 2'ki...

---------- Tre?? dodana o 23:25 ----------

Albo jak skr?ci? ten kod:
[LUA]function onUse(cid, item, fromPosition, itemEx, toPosition)
local x = math.random(3)
if item.itemid == 1945 then
if x <= 1 then
doTransformItem(item.uid, 1946)
doPlayerSendTextMessage(cid,25,"text1")
elseif x == 2 then
doTransformItem(item.uid, 1946)
doPlayerSendTextMessage(cid,25,"text2")
else
doTransformItem(item.uid, 1946)
doPlayerSendTextMessage(cid,25,"text3")
end
elseif item.itemid == 1946 then
doTransformItem(item.uid, 1945)
end
return true
end[/LUA]

Ja ju? nie mam pomys?u :c
 

Placek

Blue Waffle
Joined
Sep 30, 2008
Messages
6,793
Reaction score
672
Age
9
Odp: random dla p?tli

PHP:
messages = {"text1", "text2", "text3"}

function onUse(cid, item, fromPosition, itemEx, toPosition)
  if item.itemid == 1945 then
    local random = math.random(3)
    doTransformItem(item.uid, 1946)
    doPlayerSendTextMessage(cid, 25, messages[random])
  elseif item.itemid == 1946 then
    doTransformItem(item.uid, 1945)
  end
return true
end
 

Czopeq

Advanced User
Joined
Jun 29, 2015
Messages
191
Reaction score
6
Odp: random dla p?tli

Takie proste a nawet nie bra?em tego pod uwag?.. no c??.
Dzi?ki :)

//Temat do zamkni?cia
 
Top