Announcement

Collapse
No announcement yet.

Clan Flag System - Proof of Concept

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Clan Flag System - Proof of Concept

    Good Morning,

    I've made a clan system based on the radius of players within a distance to the flag. If a player isn't in the owning clan that owns the base, the health decreases. Once it reaches 0 the new owner of the base is the player. If 2 people or more are in the radius of the flag but are in different gangs the health of the flag is frozen, once one of the player dies it either increase the health of the flag (if they own the base) or continues to decrease until it reaches 0 and you take the flag.

    The flag cannot be hit and health is reduced every second you're within the radius

    Here's a video

    PHP Code:
    function onUpdated() {
            
    //The distance take over for the flag
        
    this.flag_radius 8;

            
    //Flag owner
        
    this.flag_owner "manager";

            
    //Time for flag to be taken over if in the radius
        
    this.flag_hp 10;
        
    this.flag_maxhp 10;

        
    this.settimeout(1);
    }

    function 
    onTimeout() {
            
    //Store the players count within the radius
        
    let radius_players 0;

            
    //The clan names of people in the radius
        
    let radius_clans = [];

            
    //Store the amount of players in the level
        
    let level_players Server.searchPlayers({map:this.map.name});

        for (
    let i=0i<level_players.lengthi++) {
                
    //Is the player dead, if so let's ignore them
            
    if (level_players[i].isdead === true) {
                continue;
            }

                
    //If they're not in a clan, do nothing!
            
    if (level_players[i].clanname === "") {
                continue;
            }        

                
    //Position of the player from the flag
            
    let player_dist Math.sqrtMath.pow((this.level_players[i].x), 2) + Math.pow((this.level_players[i].y), 2) );
            if (
    player_dist this.flag_radius) {
                continue;
            }

                
    //Keep a track of how many are in the radius (not currently used, but could add faster/slower hp based on players within the radius)
            
    radius_players++;

                
    //Store the clan name if it's not already in it
            
    if (!(radius_clans.includes(level_players[i].clanname))) {
                
    radius_clans.push(level_players[i].clanname);
            }
        }

            
    //If the only clan within the radius is the owner, heal it
        
    if (radius_clans.length === 1) {
            if (
    radius_clans[0] === this.flag_owner) {
                if (
    this.flag_hp this.flag_maxhp) {
                    
    this.flag_hp++;
                }        
            } else {
                    
    //Take over the flag
                
    this.flag_hp--;
                if (
    this.flag_hp <= 0) {
                    
    this.flag_owner radius_clans[0];
                    
    this.flag_hp 1;

                    
    //Maybe heal all the players and kick all players
                
    }
            }
        }

        
    //Generic message to show the flag owner and the health of the flag
        
    this.say(this.flag_owner "- " this.flag_hp "/" this.flag_maxhp);
        
    this.settimeout(1);

    Last edited by Deas; 12-30-2018, 01:45 AM.

  • #2
    WOW Perfecttt

    Comment


    • #3
      That's pretty cool👌

      Comment


      • #4
        Like it, seem like the scripting system is advancing

        Comment


        • #5
          Great! keep up the good work

          Comment

          Working...
          X