Teleporting to a random destination
Posted: Mon Jan 16, 2006 10:41 am
Still getting the hang of scripting..albeit very slowly!
I'm using this script by bdbodger to teleport players to a destination defined by a triggger.
As I understand it the script indexes the triggers and finds the next available free one to use as a destination.
In other words it checks trigger 1, then 2 then 3 etc
If I have 10 destination triggers in my map how do I make the choice of destination random useing the script below?
I'm guessing i'll have to rename the triggers to something like $endtrigger1 , $endtrigger2 etc and have some code to pick a random number between 1 and 10?
As always thanks in advance for any help.
I'm using this script by bdbodger to teleport players to a destination defined by a triggger.
As I understand it the script indexes the triggers and finds the next available free one to use as a destination.
In other words it checks trigger 1, then 2 then 3 etc
If I have 10 destination triggers in my map how do I make the choice of destination random useing the script below?
I'm guessing i'll have to rename the triggers to something like $endtrigger1 , $endtrigger2 etc and have some code to pick a random number between 1 and 10?
Code: Select all
//setthread to tele_porter $endtrigger's are trigger_multiples
tele_porter:
local.player = parm.other
for(local.i=1;local.i <= $endtrigger.size;local.i++)
{
if($endtrigger[local.i].isused != 1)
{
local.player thread tele_player $endtrigger[local.i]
end
}
}
end
tele_player local.spot:
self tele local.spot.origin
local.spot.isused = 1
while(self is touching local.spot)
waitframe
local.spot.isused = 0
end