ItsMods

Full Version: killstreaks mod bug on S&Deee
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
HI

i use the killstreaks mod (attached)
but its has bug on search and destroy:
The Killstreak Count Resets To 0 when round changed?!! Sad

how can fix this problem??

[attachment=1644]
is it very hard realy?
This was posted on alteriwnet forums by @banz , I just copied and pasted his info, Tongue

Code:
Hey,

i figured out a way to save variables in round-based gamemodes like SnD, so they wont get reset on round end. Well, i already used that method in promodv3.1 and feel like posting how to to do it now . ;)

As you might know, normally variables get "reset" when the round ends in SnD (Sab), even if you define them somewhere on init() or onplayerconnect()
e.g.:

You define some variables on onplayerconnect() or onplayerspawned() (above the for(;;) loop) of some .gsc file:

Code: Select all
    onPlayerConnect()
    {
    for(;;)
    {
    level waittill( "connected", player );

    if(!isDefined( player.roundsplayed )) //this wont help :p
    player.roundsplayed = 0; //to count the rounds the player played

    player thread onPlayerSpawned();
    }
    }



or

Code: Select all
    onPlayerSpawned()
    {
    self endon("disconnect");

    if(!isDefined( self.roundsplayed )) //this wont help :P
    self.roundsplayed = 0; //to count the rounds the self played

    for(;;)
    {
    self waittill("spawned_player");
    self thread countRounds();
    }
    }



and you make a function countRounds() to count the times you spawned (rounds played) and displays it after you spawned, so you can see if its counted correctly.


Code: Select all
    countRounds()
    {
    self endon("disconnect");
    self endon("death");

    self.roundsplayed++;

    while( !gameFlag( "prematch_done" ) )
    wait .05;

    for (i=0; i < 4; i++)
    {
    self iPrintLnBold("^7Rounds Played ^1" +self.roundsplayed);
    wait 1.5;
    }
    }



You will see that that self.roundsplayed (player.roundsplayed) will get reset to 0 every time a round ends.
Even if you put a if( !isDefined (player.roundsplayed ) ) infront.
Every time you spawn "Rounds Played 1" will be displayed.

Well, the solution to avoid the resetting is quite simple:
You define the variable at the same place naming it:

Code: Select all
    if ( !isDefined( player.pers["roundsPlayed"] ) )
    player.pers["roundsPlayed"] = 0;



Working code:

Spoiler: Toggle

    Code: Select all
        onPlayerConnect()
        {
        for(;;)
        {
        level waittill( "connected", player );


        if ( !isDefined( player.pers["roundsPlayed"] ) )
        player.pers["roundsPlayed"] = 0;

        player thread onPlayerSpawned();
        }
        }

        onPlayerSpawned()
        {
        self endon("disconnect");

        for(;;)
        {
        self waittill("spawned_player");
        self thread countRounds();
        }
        }

        countRounds()
        {
        self endon("disconnect");
        self endon("death");

        self.pers["roundsPlayed"]++;


        while( !gameFlag( "prematch_done" ) )
        wait .05;

        for (i=0; i < 4; i++)
        {
        self iPrintLnBold("^7Rounds Played ^1" +self.pers["roundsPlayed"]);
        wait 1.5;
        }
        }



So if you want to define a player.variable you have to define it like this:

Code: Select all
    if ( !isDefined( player.pers["variablename"] ) )
    player.pers["variablename"] = 0;



(same goes for arrays)

Spoiler: Toggle

    Code: Select all
        if ( !isDefined( player.pers["arrayname"] ) )
        player.pers["arrayname"] = [];



and put it onplayerconnect()

If you want to define a self.variable the same way

Code: Select all
    if ( !isDefined( self.pers["variablename"] ) )
    self.pers["variablename"] = 0;



and put it onplayerspawned().
You may also search for self.pers or players.pers variables in the "stock" .gsc files an put yours below...
(There are some in _playerlogic.gsc and _rank.gsc for example.)
This will also work in costum .gsc files, at least if you call them properly. ;)
and how do this with self.money that your money won't reset?
Put player.money on connect.