View Single Post
  #1  
Old 03-16-2010, 11:55 PM
Zeltino Zeltino is offline
Gov'nah
Zeltino's Avatar
Join Date: May 2005
Location: USA
Posts: 239
Zeltino will become famous soon enough
Using Random() {Major Help needed}

Hey guys,

I'm trying to put together a script that will make an NPC warp from one location to a list of ~100 locations on a server. The locations will be pre-determined. That means that I will have a list of the level, x, and y position that the NPC will warp to. I just need to know how to make the NPC randomly select between these locations, and how it will warp there, etc. It will randomly choose from the specified list of levels every 5 minutes.

I have very little scripting knowledge. I'm just trying to pull this together last-minute (needs to be done by tonight, ew). Any help would be tremendously helpful.

So far, I've started scripting the NPC in a class script (I assumed this would be better than a level NPC).

This is all I have so far:
NPC Code:
function onCreated(){ 
setimg("block.png");
this.locationsarray = {"test.nw","30","30"}, //Random Movement
{"zeltest.nw","40","40"};

scheduleevent("0.05","MoveMe","");
}

function onMoveMe(){
temp.i=int(random(0,99));
this.location=this.locationsarray[temp.i];
scheduleevent("300","MoveMe","");
}

function onPlayertouchsme(){
}


Almost certain none of the above is correct.

Can anyone help me <3?
__________________
Developer
Crescent Pirates
Email: [email protected]
Reply With Quote