Toranks
Active member
I have a script to interact with various menus. Until now only player 1 could handle them, and I wanted to make it accessible to all 3 players. The only way I've gotten it to work is by tripling the code. Just for curiosity, and for learning. Can anyone think of a way to simplify this script or is it fine as it is? Thanks!
C:
void keyintall(void Ani, int Frame, void Key, int Hflag, int Limit)
{// Change current animation if proper key is pressed or released by any player
void self = getlocalvar("self");
void Health = getentityproperty(self,"health");
int iDir = getentityproperty(self, "direction");
void iRKey;
void iRKey2;
void iRKey3;
if (Key=="U"){ //Up Required?
iRKey = playerkeys(0, 0, "moveup"); // "Up"
} else if (Key=="D"){ //Down Required?
iRKey = playerkeys(0, 0, "movedown"); // "Down"
} else if (Key=="F"){ //Forward Required?
iRKey = playerkeys(0, 0, "moveright"); // "Right"
} else if (Key=="B"){ //Forward Required?
iRKey = playerkeys(0, 0, "moveleft"); // "Left"
} else if (Key=="J"){ //Jump Required?
iRKey = playerkeys(0, 0, "jump"); // "Jump"
} else if (Key=="A"){ //Attack Required?
iRKey = playerkeys(0, 0, "attack"); // "Attack"
} else if (Key=="S"){ //Special Required?
iRKey = playerkeys(0, 0, "special"); // "Special"
} else if (Key=="A2"){ //Attack2 Required?
iRKey = playerkeys(0, 0, "attack2"); // "Attack2"
} else if (Key=="A3"){ //Attack3 Required?
iRKey = playerkeys(0, 0, "attack3"); // "Attack3"
} else if (Key=="A4"){ //Attack4 Required?
iRKey = playerkeys(0, 0, "attack4"); // "Attack4"
}
if (Hflag==1){ //Not holding the button case?
iRKey = !iRKey; //Take the opposite condition
}
if ((Health > Limit)&&iRKey){
changeentityproperty(self, "animation", openborconstant(Ani), 2);
changeentityproperty(self, "animpos", Frame);
// updateframe(self, Frame);
}
if (Key=="U"){ //Up Required?
iRKey2 = playerkeys(1, 0, "moveup"); // "Up"
} else if (Key=="D"){ //Down Required?
iRKey2 = playerkeys(1, 0, "movedown"); // "Down"
} else if (Key=="F"){ //Forward Required?
iRKey2 = playerkeys(1, 0, "moveright"); // "Right"
} else if (Key=="B"){ //Forward Required?
iRKey2 = playerkeys(1, 0, "moveleft"); // "Left"
} else if (Key=="J"){ //Jump Required?
iRKey2 = playerkeys(1, 0, "jump"); // "Jump"
} else if (Key=="A"){ //Attack Required?
iRKey2 = playerkeys(1, 0, "attack"); // "Attack"
} else if (Key=="S"){ //Special Required?
iRKey2 = playerkeys(1, 0, "special"); // "Special"
} else if (Key=="A2"){ //Attack2 Required?
iRKey2 = playerkeys(1, 0, "attack2"); // "Attack2"
} else if (Key=="A3"){ //Attack3 Required?
iRKey2 = playerkeys(1, 0, "attack3"); // "Attack3"
} else if (Key=="A4"){ //Attack4 Required?
iRKey2 = playerkeys(1, 0, "attack4"); // "Attack4"
}
if (Hflag==1){ //Not holding the button case?
iRKey2 = !iRKey2; //Take the opposite condition
}
if ((Health > Limit)&&iRKey2){
changeentityproperty(self, "animation", openborconstant(Ani), 2);
changeentityproperty(self, "animpos", Frame);
// updateframe(self, Frame);
}
if (Key=="U"){ //Up Required?
iRKey3 = playerkeys(2, 0, "moveup"); // "Up"
} else if (Key=="D"){ //Down Required?
iRKey3 = playerkeys(2, 0, "movedown"); // "Down"
} else if (Key=="F"){ //Forward Required?
iRKey3 = playerkeys(2, 0, "moveright"); // "Right"
} else if (Key=="B"){ //Forward Required?
iRKey3 = playerkeys(2, 0, "moveleft"); // "Left"
} else if (Key=="J"){ //Jump Required?
iRKey3 = playerkeys(2, 0, "jump"); // "Jump"
} else if (Key=="A"){ //Attack Required?
iRKey3 = playerkeys(2, 0, "attack"); // "Attack"
} else if (Key=="S"){ //Special Required?
iRKey3 = playerkeys(2, 0, "special"); // "Special"
} else if (Key=="A2"){ //Attack2 Required?
iRKey3 = playerkeys(2, 0, "attack2"); // "Attack2"
} else if (Key=="A3"){ //Attack3 Required?
iRKey3 = playerkeys(2, 0, "attack3"); // "Attack3"
} else if (Key=="A4"){ //Attack4 Required?
iRKey3 = playerkeys(2, 0, "attack4"); // "Attack4"
}
if (Hflag==1){ //Not holding the button case?
iRKey3 = !iRKey3; //Take the opposite condition
}
if ((Health > Limit)&&iRKey3){
changeentityproperty(self, "animation", openborconstant(Ani), 2);
changeentityproperty(self, "animpos", Frame);
// updateframe(self, Frame);
}
}
Last edited:
