• logo_cipsoft
    Nowe serwery zostały otwarte 19 Lut 2025:
    Noctalia (Open PvP) Ignitera (Open PvP) us_logo Xybra (Open PvP)

Skrypty & Kody random dla p?tli

Czopeq

Advanced User
Dołączył
Czerwiec 29, 2015
Posty
191
Liczba reakcji
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
 
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
 
Odp: random dla p?tli

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

//Temat do zamkni?cia
 
Do góry