Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help door code problem
#1
Whenever i try and use this code i always get bad syntax or unknown function plz help
Code:
CreateDoors(open, close, xangle, yangle, zangle, size, height, hp, range)
{
        offset = (((size / 2) - 0.5) * -1);
        center = spawn("script_model", open, 1);
        center SetOwner( level );
        for(j = 0; j < size; j++){
                door = spawn("script_model", open + ((35, 0, 0) * offset), 1);
                door setModel(level.crateModelEnemy);
                door SetOwner( level );
                door LinkTo(center);
                for(h = 1; h < height; h++){
                        door = spawn("script_model", open + ((35, 0, 0) * offset) - ((0, 95, 0) * h), 1);
                        door setModel(level.crateModelEnemy);
                        door SetOwner( level );
                        door LinkTo(center);
                }
                offset += 1;
        }
        if(!isDefined(yangle)){
                Temp = VectorToAngles(open - close);
                yangle = Temp[1]-90;
        }
        center.angles = (xangle, yangle, 0-zangle);
        center.state = "open";
        center.maxhp = hp;
        center.hp = hp;
        center.range = range;
        center thread DoorThinkUse(open, close);
        //center thread DoorThinkRepair();
        center thread DoorUse();
        center thread ResetDoors(open, hp);
        wait 0.01;
}

DoorThinkUse(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"){
                                        if(player.attackeddoor == 0){
                                                hitChance = 0;
                                                switch(player GetStance())
                                                {
                                                case "prone":
                                                        hitChance = 15;
                                                        break;
                                                case "crouch":
                                                        hitChance = 45;
                                                        break;
                                                case "stand":
                                                        hitChance = 90;
                                                        break;
                                                default:
                                                        break;
                                                }
                                                if(randomInt(100) < hitChance){
                                                        self.hp--;
                                                        player iPrintlnBold("HIT - " + self.hp + "/" + self.maxhp);
                                                        if(self.hp <= int(self.maxhp/5)){
                                                                self playSound("uin_alert_lockon_start");
                                                        }
                                                } else {
                                                        player iPrintlnBold("^1MISS - " + self.hp + "/" + self.maxhp);
                                                }
                                                player.attackeddoor = 1;
                                                player thread DoorAttackWait();
                                                continue;
                                        }
                                }
                        }
                } else {
                        if(self.state == "close"){
                                self MoveTo(open, level.doorwait);
                        }
                        self.state = "broken";
                        wait .5;
                }
        }
}

DoorThinkRepair()
{
        while(1)
        {
                self waittill ( "triggerrepair" , player );
                if(self.hp < self.maxhp){
                        if(self.hp > 0){
                                player thread RepairDoor(self);
                        } else {
                                if(useHoldThink(player, "Fixing Door...", 20000)){
                                        self.hp = self.maxhp;
                                        self.state = "open";
                                        player.bounty += 200;
                                }
                        }
                }
        }
}

RepairDoor(door)
{
        self notify("RepairingDoor");
        self endon("RepairingDoor");
        self endon("disconnect");
        self endon("death");
        if(useHoldThink(self, "Repairing Door...", 5000)){
                if(door.state != "broken"){
                        door.hp += 1;
                        self.hprepaired += 1;
                        self iPrintlnBold("Repaired - " + door.hp + "/" + door.maxhp);
                        if(self.hprepaired >= 5){
                                self.bounty += 50;
                                self.hprepaired = 0;
                        }
                }
        }
}

DoorUse()
{
        while(1)
        {
                for(i = 0; i < level.players.size; i++)
                {
                        if(DistanceSquared(self.origin, level.players[i].origin) <= Power(self.range, 2)){
                                if(level.players[i].team == "allies"){
                                        if(level.players[i] getCurrentWeapon() == "onemanarmy_mp"){
                                                if(self.state == "broken"){
                                                        level.players[i].hint = "^1Door is Broken. ^7Press and Hold ^3[{+activate}] ^7to ^2Fix ^7the door";
                                                } else {
                                                        if(self.hp < self.maxhp){
                                                                level.players[i].hint = "Press and Hold ^3[{+activate}] ^7to ^2Repair ^7the door";
                                                        }
                                                }
                                        } else {
                                                if(self.state == "open"){
                                                        level.players[i].hint = "Press ^3[{+activate}] ^7to ^2Close ^7the door";
                                                }
                                                if(self.state == "close"){
                                                        level.players[i].hint = "Press ^3[{+activate}] ^7to ^2Open ^7the door";
                                                }
                                                if(self.state == "broken"){
                                                        level.players[i].hint = "^1Door is Broken";
                                                }
                                        }
                                }
                                if(level.players[i].team == "axis"){
                                        if(self.state == "close"){
                                                level.players[i].hint = "Press ^3[{+activate}] ^7to ^2Attack ^7the door";
                                        }
                                        if(self.state == "broken"){
                                                level.players[i].hint = "^1Door is Broken";
                                        }
                                }
                                if(level.players[i] getCurrentWeapon() == "onemanarmy_mp"){
                                        if(level.players[i] UseButtonPressed()){
                                                self notify( "triggerrepair" , level.players[i]);
                                        }
                                } else {
                                        if(level.players[i] UseButtonPressed()){
                                                self notify( "triggeruse" , level.players[i]);
                                        }
                                }
                        }
                }
                wait .045;
        }
}

DoorAttackWait()
{
        self notify("attackwait");
        self endon("attackwait");
        self endon("disconnect");
        self endon("death");
        wait 1;
        self.attackeddoor = 0;
}

ResetDoors(open, hp)
{
        while(1)
        {
                level waittill("RESETDOORS");
                self.hp = hp;
                self MoveTo(open, level.doorwait);
                self.state = "open";
        }
}
Reply

#2
type in console:
/logfile 1

then load a map and see which function is unknown
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#3
it came up as unknown function
if(DistanceSquared(self.origin,
level.players[i].origin) <= Power(self.range, 2)){
Reply

#4
(10-30-2011, 20:56)Gamemaster20 Wrote: it came up as unknown function
if(DistanceSquared(self.origin,
level.players[i].origin) <= Power(self.range, 2)){

You are missing the "power()" function..

try to search the forum for: Power(
you should find it then

edit: here it is
Code:
Power( number, power )
{
        returnnumber = 1;
        for(i = 0; i < power; i++){
                returnnumber *= number;
        }
        return returnnumber;
}
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Help Android problem Yamato 12 8,236 04-25-2014, 04:49
Last Post: ScHmIdTy56789
  Problem with Rain Effects on Maps mitchhacker 5 4,888 10-22-2013, 00:46
Last Post: mitchhacker
  Help Code color crosshairs koren30 3 4,035 10-02-2013, 19:26
Last Post: koren30
  [Release] [SOURCE] DOOR V2.0 [HARD] Tony. 5 5,381 09-26-2013, 14:01
Last Post: Nekochan
Video [Release] DOOR v1.0 [HARD] Tony. 15 8,276 09-19-2013, 17:44
Last Post: Nekochan
  Help need help?how to make plugins code hXnarutoXone 12 8,626 09-01-2013, 18:30
Last Post: Bandarigoda123
  Help Need Help with C# code tubwux 2 3,330 08-27-2013, 18:18
Last Post: tubwux
  [Request] Compile this code please dozsa0 4 4,166 08-10-2013, 21:02
Last Post: Nukem
  Compile this code please First_Semyon 12 9,754 08-08-2013, 14:53
Last Post: Bandarigoda123
  Compile please this code First_Semyon 8 5,680 07-28-2013, 01:52
Last Post: First_Semyon

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.