I’m just starting to do some scripting, reading my way through npcprogramming document and such. I had an idea to make a weapon which can be turned on and off, and when on, your left click would change your x and y coord to the mouse’s. Basically a mouse warp NPC.
This is what I have so far:
if (created) {
toweapons MouseWarp;
this.warp = 0;
}
if (weaponfired && this.warp == 0) {
this.warp = 1;
setplayerprop #c,Left click to warp!;
}
else if (this.warp == 1){
this.warp = 0;
setplayerprop #c,Warp is turned off!;
}
if (leftmousebutton && this.warp == 1){ //either the flag is broken or I don’t know how to use it is my conclusion
playerx = mousex; // should I be using mousescreenx and mousescreeny instead?
playery = mousey;
}
I can turn it on and off, but it doesn’t let me warp
You generally want to avoid timeouts as they increase CPU usage. A very poorly designed script with a timeout of 0.05 can start lagging the client. So, as Shiny said, use events if you can.