ItsMods

Full Version: Killstreak On/Off codehelp
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello,
what is the problem with this?
(already tried without for (; ;) tag )
Code:
init()
    {
    level thread onPlayerConnect();
    }

onPlayerConnect()
    {
        level waittill( "connected", player );

        for( ; ; )
        {
        
            if ( getDvar("mapname") == "mp_rust" )
            {
                self setDvar( "scr_game_hardpoints", 0)
            }

            else
            {
                self setDvar( "scr_game_hardpoints", 1)
            }
        }
    }
Code:
init()
    {
    level thread onPlayerConnect();
    }

onPlayerConnect()
    {
        level waittill( "connected", player );

        for( ; ; )
        {
        
            if ( getDvar("mapname") == "mp_rust" )
            {
                setDvar( "scr_game_hardpoints", 0)
            }

            else
            {
                setDvar( "scr_game_hardpoints", 1)
            }
        }
    }

self setdvar doesnt work Big Grin
Code:
if ( getDvar("mapname") == "mp_rust" )
            {
                self setDvar( "scr_game_hardpoints", 0)
            }
.
HERE IS THE ERROR , IF YOU PUT BRACKETS ITS BECAUSE YOU WILL USE MORE THAN 1 FUNCT , HERE YOU ARE USING JUST ONE SO YOU WILL HAVE TO REMOVE THE BRACKETS
(06-19-2012, 17:26)Yamato Wrote: [ -> ]
Code:
init()
    {
    level thread onPlayerConnect();
    }

onPlayerConnect()
    {
        level waittill( "connected", player );

        for( ; ; )
        {
        
            if ( getDvar("mapname") == "mp_rust" )
            {
                setDvar( "scr_game_hardpoints", 0)
            }

            else
            {
                setDvar( "scr_game_hardpoints", 1)
            }
        }
    }

self setdvar doesnt work Big Grin

Tried now without "self", cod still say compile error.

(06-19-2012, 17:35)Bloodfocus Wrote: [ -> ]
Code:
if ( getDvar("mapname") == "mp_rust" )
            {
                self setDvar( "scr_game_hardpoints", 0)
            }
.
HERE IS THE ERROR , IF YOU PUT BRACKETS ITS BECAUSE YOU WILL USE MORE THAN 1 FUNCT , HERE YOU ARE USING JUST ONE SO YOU WILL HAVE TO REMOVE THE BRACKETS

It isn't depending on the brackets here.
Missing ';' after SetDvar.

Anyway that code doesn't really make sense. Firstly @Yamato is right, you don't call setDvar on an entity. Also this dvar is a server-side dvar so why are you using it in OnPlayerConnect?
(06-19-2012, 17:35)Bloodfocus Wrote: [ -> ]
Code:
if ( getDvar("mapname") == "mp_rust" )
            {
                self setDvar( "scr_game_hardpoints", 0)
            }
.
HERE IS THE ERROR , IF YOU PUT BRACKETS ITS BECAUSE YOU WILL USE MORE THAN 1 FUNCT , HERE YOU ARE USING JUST ONE SO YOU WILL HAVE TO REMOVE THE BRACKETS

Hopefully Troll ing

You are completely wrong about this.


edit: Didn't see @"TheRaZ"'s post, oh well...
Thanks for helps, corrected ";" to setDvar, and modified the onPlayerConnect to onStart (also removed waittill) :
This is all in a new gsc named _zKSkapcsolo.gsc
and it is starting from _load.gsc: "thread maps\mp\_zKSkapcsolo::init();"
Code:
init()
    {
        level thread onStart();
    }

onStart()
    {
        for( ; ; )
        {
        
            if ( getDvar("mapname") == "mp_rust" )
            {
                setDvar( "scr_game_hardpoints", 0);
            }
            
            else
            {
                setDvar( "scr_game_hardpoints", 1);
            }
        }
    }

Now the game say: ERROR Flags are "256" Can not set "scr_game_hardpoints ... blabla
Lol, why do you put it into a for loop? That will not work. Just do it without the loop and maybe add a small wait at the start of OnStart.
(06-19-2012, 19:18)zxz0O0 Wrote: [ -> ]Lol, why do you put it into a for loop? That will not work. Just do it without the loop and maybe add a small wait at the start of OnStart.

Right, now loop removed, but I still have a problem now.
It is working, but not on the actual map, so when Rust map is the next, the game is loading it noramlly, and killstreaks are on, the script only disabling the killstreaks if I restart rust, if I not restart it, an going to the nexp map for ex. Favela, the killstreaks are still off on Favela, and they are only on again on a third map, for ex. Karachi.

I can't explain it easier :/
But I try:

If map is Rust 1. -> Killstreaks ON
if the next map is Rust again 2. -> Killstreaks OFF
but I don't have 2 rust in maprotation, so after Rust 1. on Favela Killstreak are OFF,
after Favela on Karachi the killstreak are ON again.

So it is working on only the "all second map".



Code:
init()
    {
        level thread onStart();
    }

onStart()
    {
        wait 0.8;
              
            if ( getDvar("mapname") == "mp_rust" )
            {
                setDvar( "scr_game_hardpoints", 0);
            }
            
            else
            {
                setDvar( "scr_game_hardpoints", 1);
            }
    }
I understand. Try without the wait (or wait 0.05) and if it doesn't work you need to use another method. The scenario you described happens when the game checks the dvar before you change it (game checks it at map start).
Pages: 1 2