• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code My code not compiling

Fede_mer-k

Member
Aug 14, 2013
5
0
it is my code:

Code:
class CheckPerkSame extends Mutator;

var KFGameType KF;
var bool bExtraChecked;
var array<Controller> players;
var int i;

function PostBeginPlay(){
    if(KFGameType(level.Game) != None){
        KF = KFGameType(level.Game);
        SetTimer(2.0, true);
    }else{
        Destroy();
    }
}

function Timer(){
    if(KF.bWaveInProgress) { //No podriamos cambiarlo cuando el wave esta en progreso
        if(!bExtraChecked) { //Chqueando otra vez, en caso de que se haya cambiado el perk en los ultimos 2 seg.
            MutUpdate();
            bExtraChecked = True;
        }
    }
    else
    { //Despues de la primera wave, en el tiempo del trade
        MutUpdate();
        bExtraChecked = False;
    }
}

function MutUpdate() {
    local Controller C;

    //Tomo todos los controllers que sean players.
    for(C=lever.ControllerList; C != None; C.NextController) {
        if(C.bIsPlayer && C.Pawn != None && C.Pawn.Health > 0 && (C.PlayerReplicationInfo != None || KFPlayerReplicationInfo(C.PlayerReplicationInfo) != None))
            players[players.length] = C;
    }
}

function CheckPlayersPerk() {
    local string playerName;
    local class<KFVeterancyTypes> myVetType;
    local bool bSameType;
    local int i;
    local int j;
    local int pLength;
    pLength = players.length;

    for( i=0; i<pLength; i++ ) {
        //Guardo el player a chequear contra todos los demas que estan en el server.
        playerName = KFPlayerReplicationInfo(player[i].PlayerReplicationInfo).PlayerName;
        myVetType = KFPlayerReplicationInfo(player[i].PlayerReplicationInfo).ClientVeteranSkill;
        for(j=0; j<pLength; j++ )
            //Si no es el mismo que estoy chequeando && tienen el mismo perk
            if(j != i && myVetType != KFPlayerReplicationInfo(player[j].PlayerReplicationInfo).ClientVeteranSkill)
                //LO MATO :D
                player[j].Pawn.Health = 0;
    }
}

defaultproperties {
    bAddToServerPackages=True
	Description="Restricts the use only one perk per player, players whith same perk, kill instatly.||By [LB]Fede_mer-k LastBullet clan 1/2016"
	FriendlyName="Check Perk Same"
	GroupName="PerkRestrictions"
}

The error is this:

Code:
Warning Line 45: 'i' obscures 'i' defined in the base class
Error Line 52 : Bad or missing expression in '='

Please, i need help, and not got idea of this error :(
 
it is my code:

Code:
class CheckPerkSame extends Mutator;

var KFGameType KF;
var bool bExtraChecked;
var array<Controller> players;
var int i;

function PostBeginPlay(){
    if(KFGameType(level.Game) != None){
        KF = KFGameType(level.Game);
        SetTimer(2.0, true);
    }else{
        Destroy();
    }
}

function Timer(){
    if(KF.bWaveInProgress) { //No podriamos cambiarlo cuando el wave esta en progreso
        if(!bExtraChecked) { //Chqueando otra vez, en caso de que se haya cambiado el perk en los ultimos 2 seg.
            MutUpdate();
            bExtraChecked = True;
        }
    }
    else
    { //Despues de la primera wave, en el tiempo del trade
        MutUpdate();
        bExtraChecked = False;
    }
}

function MutUpdate() {
    local Controller C;

    //Tomo todos los controllers que sean players.
    for(C=lever.ControllerList; C != None; C.NextController) {
        if(C.bIsPlayer && C.Pawn != None && C.Pawn.Health > 0 && (C.PlayerReplicationInfo != None || KFPlayerReplicationInfo(C.PlayerReplicationInfo) != None))
            players[players.length] = C;
    }
}

function CheckPlayersPerk() {
    local string playerName;
    local class<KFVeterancyTypes> myVetType;
    local bool bSameType;
    local int i;
    local int j;
    local int pLength;
    pLength = players.length;

    for( i=0; i<pLength; i++ ) {
        //Guardo el player a chequear contra todos los demas que estan en el server.
        playerName = KFPlayerReplicationInfo(player[i].PlayerReplicationInfo).PlayerName;
        myVetType = KFPlayerReplicationInfo(player[i].PlayerReplicationInfo).ClientVeteranSkill;
        for(j=0; j<pLength; j++ )
            //Si no es el mismo que estoy chequeando && tienen el mismo perk
            if(j != i && myVetType != KFPlayerReplicationInfo(player[j].PlayerReplicationInfo).ClientVeteranSkill)
                //LO MATO :D
                player[j].Pawn.Health = 0;
    }
}

defaultproperties {
    bAddToServerPackages=True
	Description="Restricts the use only one perk per player, players whith same perk, kill instatly.||By [LB]Fede_mer-k LastBullet clan 1/2016"
	FriendlyName="Check Perk Same"
	GroupName="PerkRestrictions"
}

The error is this:

Code:
Warning Line 45: 'i' obscures 'i' defined in the base class
Error Line 52 : Bad or missing expression in '='

Please, i need help, and not got idea of this error :(

Try to replace = with ==, usually that solves the issue.
 
  • Like
Reactions: Fede_mer-k
Upvote 0
Toblerone;n2137361 said:
Try to replace = with ==, usually that solves the issue.

Thanks for you response. The error was solved:

Code:
Line 52:
playerName = KFPlayerReplicationInfo(player[i].PlayerReplicationInfo).PlayerName;
//Array "player" is not defined, the correct name is "players"!!!
playerName = KFPlayerReplicationInfo(players[i].PlayerReplicationInfo).PlayerName;
 
Upvote 0