PDA

View Full Version : Levitation


Novice
03-07-2009, 07:35 PM
This is a simple levitation script. Just a fun little toy.
//Scripted by Novice

//#CLIENTSIDE
function onCreated() {
this.rep = {"walk","grab","pull","push","sit"};
this.air = 0;
player.z = 0;
}

function onWeaponFired() {
if (this.air == 0) {
this.air = 1;
for (i=0; i<this.rep.size(); i++)
replaceAni(this.rep[i],"idle");
setAni("idle",null);
}
else if (this.air in {1,2})
this.air = 0;
setTimer(0.05);
}

function onTimeOut() {
if (this.air != 0) {
if (player.z == 2)
this.air = 2;
if (player.z == 1)
this.air = 1;
if (this.air == 1)
player.z += 0.05;
else if (this.air == 2)
player.z -= 0.05;
setTimer(0.05);
} else {
if (player.z > 0) {
player.z -= 0.05;
setTimer(0.05);
} else {
for (i=0; i<this.rep.size(); i++)
replaceAni(this.rep[i],this.rep[i]);
}
}
}

function onPlayerDies() {
if (this.air != 0) {
this.air = 0;
player.z = 0;
setTimer(0);
for (i=0; i<this.rep.size(); i++)
replaceAni(this.rep[i],this.rep[i]);
}
}
You can also add/remove Ganis you want to change by adding to "this.rep", and change the Gani you want it to play instead of those in "this.rep" by changing "idle" to the one you want to play in "setAni("idle",null);" and "replaceAni(this.rep[i],"idle");"