10-07-2011, 13:00
Hi, i have a probelem with my Doors! I can close, but no open Important my Mod, is no with Zombi!
Code:
CreateDoors(open, close, angle, size, height, hp, range)
{
offset = (((size / 2) - 0.5) * -1);
center = spawn("script_model", open );
for(j = 0; j < size; j++){
door = spawn("script_model", open + ((0, 30, 0) * offset));
door setModel("com_plasticcase_enemy");
door Solid();
door CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
door EnableLinkTo();
door LinkTo(center);
for(h = 1; h < height; h++){
door = spawn("script_model", open + ((0, 30, 0) * offset) - ((70, 0, 0) * h));
door setModel("com_plasticcase_enemy");
door Solid();
door CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
door EnableLinkTo();
door LinkTo(center);
}
offset += 1;
}
center.angles = angle;
center.state = "open";
center.hp = hp;
center.range = range;
center thread DoorThink(open, close);
center thread DoorUse();
center thread ResetDoors(open, hp);
wait 0.01;
}
DoorThink(open, close)
{
while(1)
{
if(self.hp > 0){
self waittill ( "triggeruse" , player );
if(player.team == "allies"){
if(self.state == "open"){
self MoveTo(close, level.doorwait);
wait level.doorwait;
self.state = "close";
continue;
}
if(self.state == "close"){
self MoveTo(open, level.doorwait);
wait level.doorwait;
self.state = "open";
continue;
}
}
if(player.team == "axis"){
if(self.state == "close"){
self.hp--;
player iPrintlnBold("HIT");
wait 1;
continue;
}
}
} else {
if(self.state == "close"){
self MoveTo(open, level.doorwait);
}
self.state = "broken";
wait .5;
}
}
}
DoorUse(range)
{
self endon("disconnect");
while(1)
{
foreach(player in level.players)
{
if(Distance(self.origin, player.origin) <= self.range){
if(player.team == "allies"){
if(self.state == "open"){
player.hint = "Press ^3[{+activate}] ^7to ^2Close ^7the door";
}
if(self.state == "close"){
player.hint = "Press ^3[{+activate}] ^7to ^2Open ^7the door";
}
if(self.state == "broken"){
player.hint = "^1Door is Broken";
}
}
if(player.team == "axis"){
if(self.state == "close"){
player.hint = "Press ^3[{+activate}] ^7to ^2Attack ^7the door";
}
if(self.state == "broken"){
player.hint = "^1Door is Broken";
}
}
if(player.buttonPressed[ "+activate" ] == 1){
player.buttonPressed[ "+activate" ] = 0;
self notify( "triggeruse" , player);
}
}
}
wait .045;
}
}
ResetDoors(open, hp)
{
while(1)
{
level waittill("RESETDOORS");
self.hp = hp;
self MoveTo(open, level.doorwait);
self.state = "open";
}
}
Code:
CreateDoors((565, 1540, 295), (653, 1540, 295), (90, 90, 0), 3, 2, 15, 60);