local num = math.random(1, 2)
local num = 1
function xxx()
num = num == 1 and 2 or 1
end
function onStepIn(item, position, lastPosition, fromPosition, toPosition, actor)
local alphaTeam = {x = 1000, y = 1000, z = 7}
local bravoTeam = {x = 1000, y = 1000, z = 7}
local number = math.random(1, 2)
local tileid = 474
local tileuid = 1897554
if isPlayer(cid) and item.itemid == tileid and item.uid == tileuid then
if number == 1 then
doTeleportThing(cid, alphaTeam)
doSendTextMessage(cid, CONST_ME_DESCR, "You are a alpha teamer!")
end return true
elseif number == 2 then
doTeleportThing(cid, bravoTeam)
doSendTextMessage(cid, CONST_ME_DESCR, "You are a bravo teamer!")
end return true
end
return true
end
local dest = {
[1] = {x = 1000, y = 1000, z = 7},
[2] = {x = 1000, y = 1000, z = 7}
}
local names = {"Alpha", "Bravo"}
local tileid = 474
local tileuid = 1897554
function onStepIn(item, position, lastPosition, fromPosition, toPosition, actor)
if isPlayer(cid) and item.itemid == tileid and item.uid == tileuid then
local number = math.random(1, 2)
doTeleportThing(cid, dest[number])
doSendTextMessage(cid, CONST_ME_DESCR, "You are a ".. names[number] .." teamer!")
end
end
- math.random() with no arguments generates a real number between 0 and 1.
- math.random(upper) generates integer numbers between 1 and upper.
- math.random(lower, upper) generates integer numbers between lower and upper.
math.random(2)
don't include the two integers
LUA:math.random(2)