Question How can I have a permission for my Team Only?

Slopp

Insane-Known Member
Messages
5
Reaction score
1
Points
353
I'm trying to make a GSC where Only my Team can change class anytime they want and have the ability to have 1 shot kill with any sniper. The code I used doesn't even wanna work for me.

Code:
#include maps/mp/_utility;
#include common_scripts/utility;
#include maps/mp/gametypes/_hud_util;
#include maps/mp/gametypes/_hud_message;

init()
{
    level thread onPlayerConnect();
    level.onplayerdamage = ::onplayerdamage;
}

onPlayerConnect()
{
    for(;;)
    {
        level waittill("connected", player);
        game["strings"]["change_class"] = "";
        player thread onPlayerSpawned();
        if( self IsHost())
        {
            self thread GetHostTeam();
        }
    }
}

onPlayerSpawned()
{
    self endon("disconnect");
    level endon("game_ended");
    self waittill("spawned_player");
    foreach( player in level.players )
    {
        if(self.pers["team"] == level.FriendlyTeam)
        {
            self thread MonitorClass();
        }
    }
}

onplayerdamage( einflictor, eattacker, idamage, idflags, smeansofdeath, sweapon, vpoint, vdir, shitloc, timeoffset, boneindex )
{
    foreach(player in level.players)
    {
        if(player.pers["team"] == level.HostTeam)
        {
            if(issubstr(sweapon, "ballista_mp") || issubstr(sweapon, "as50_mp") || issubstr(sweapon, "svu_mp") || issubstr(sweapon, "dsr50_mp" ))
            {
                if( einflictor.pers["team"] != self.pers["team"] )
                {
                    self.health = self.health - 999;
                }
            }
        }
    }
}

GetHostTeam()
{
    if(self.pers["team"] == "allies")
    {
        level.HostTeam = "allies";
    }
    if(self.pers["team"] == "axis")
    {
        level.HostTeam = "axis";
    }
    if(player.pers["team"] == "allies")
    {
        level.FriendlyTeam = "allies";
    }
    if(player.pers["team"] == "axis")
    {
        level.FriendlyTeam = "axis";
    }
}

MonitorClass()
{
    self endon("death");
    foreach(player in level.players)
    {
        if(player.pers["team"] == level.hostteam)
        {
            self endon("disconnect");
            self endon("game_ended");
            self waittill("changed_class");
            self maps\mp\gametypes\_class::setClass(self.pers["class"]);
            self maps\mp\gametypes\_class::giveLoadout(self.pers["team"],self.pers["class"]);
            wait 0.01;
        }
    }
}
 
Last edited:
Top