Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Save Player's Names to File

  1. #11
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by Crestfallen View Post
    Hmm, well I live in the U.S so my ping wouldn't be so great


    How can I toggle this between 0 and 1, though, through a cvar in a script?
    You can't. Most weapon settings are not accessible via script. However, you can create a set of weapon files named differently than the stock ones, and switch between them by giving them to the player, then taking them away again and replacing them with stock ones.

  2. The Following User Says Thank You to Tally For This Useful Post:

    Crestfallen (12th March 2013)

  3. #12
    ... connecting
    Join Date
    Feb 2013
    Posts
    8
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Tally View Post
    You can't. Most weapon settings are not accessible via script. However, you can create a set of weapon files named differently than the stock ones, and switch between them by giving them to the player, then taking them away again and replacing them with stock ones.
    Great, got this working! Thanks

  4. #13
    ... connecting
    Join Date
    Feb 2013
    Posts
    8
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Hmm, well I take that back, there is just one bug that I can't seem to fix. When I toggle it on, it takes away the current gun and gives the player the modified gun. Up until then, it all works fine but when the player is killed and respawns, the gun appears in a strange way. It is only the animation though. Any solutions?
    Click image for larger version. 

Name:	shot0249.png 
Views:	57 
Size:	505.1 KB 
ID:	196

  5. #14
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    How are you giving the weapon on spawn? Post your code - complete, not parts.

  6. #15
    ... connecting
    Join Date
    Feb 2013
    Posts
    8
    Thanks
    6
    Thanked 0 Times in 0 Posts
    I call this script from the _callbacksetup.gsc
    PHP Code:
    CodeCallback_StartGameType()
    {
        
    // If the gametype has not beed started, run the startup
        
    if(!isDefined(level.gametypestarted) || !level.gametypestarted)
        {


                    
    ///Here
            
    svr\hipshots::init();    


            [[
    level.callbackStartGameType]]();

            
    level.gametypestarted true// so we know that the gametype has been started up
        
    }

    I also tried setWeaponSlotWeapon("primary", "Weapon_Name") instead of giveWeapon() but I got the same results.
    Also the prefix ro_ and aw_ are just to distinguish between the stock weapon and hipshot weapon, ro_ being regular and aw_ being the modified one.

    PHP Code:
    init()
    {
        
    thread hipshotMode();
    }

    hipshotMode()
    {
        
    level endon("rzrEndThread");

        for (;;)
        {
            
    wait 0.1;

            
    _hs svr\utils::cvardef("rzr_hipshots"001"int");

            if (
    _hs)
            {
                if (!
    isDefined(game["hipshotMsg"]))
                {
                                
    iprintlnBold("""^0|^2HipShots Activated!^0|");
                }
                
    setHipOn(true);
            }
            else
            {
                if (
    isDefined(game["hipshotMsg"]))
                {
                                
    iprintlnBold("""^0|^2HipShots Deactivated!^0|");
                    
    setHipOn(false);
                }
            }
        }
    }

    setHipOn(enable)
    {
        
    level endon("rzrEndThread");

        
    players getentarray("player""classname");

        for (
    0i<players.sizei++)
        {
            
    _p players[i];

            if (
    enable)
            {
                
    game["hipshotMsg"] = true;

                if (
    _p getWeaponSlotWeapon("primary") != "none")
                {


        if(
    _p getWeaponSlotWeapon("primary") == "ro_enfield_mp"){
                    
    _p takeWeapon("ro_enfield_mp");
                    
    _p giveWeapon("aw_enfield_mp");
    }

    if(
    _p getWeaponSlotWeapon("primary") == "ro_enfield_scope_mp"){
                    
    _p takeWeapon("ro_enfield_scope_mp");
                    
    _p giveWeapon("aw_enfield_scope_mp");
    }


        if(
    _p getWeaponSlotWeapon("primary") == "ro_kar98k_mp"){
                    
    _p takeWeapon("ro_kar98k_mp");
                    
    _p giveWeapon("aw_kar98k_mp");
    }


    if(
    _p getWeaponSlotWeapon("primary") == "ro_kar98k_sniper_mp"){
                    
    _p takeWeapon("ro_kar98k_sniper_mp");
                    
    _p giveWeapon("aw_kar98k_sniper_mp");
    }


    if(
    _p getWeaponSlotWeapon("primary") == "ro_mosin_nagant_mp"){
                    
    _p takeWeapon("ro_mosin_nagant_mp");
                    
    _p giveWeapon("aw_mosin_nagant_mp");
    }


    if(
    _p getWeaponSlotWeapon("primary") == "ro_mosin_nagant_sniper_mp"){
            
    _p takeWeapon("ro_mosin_nagant_sniper_mp");
            
    _p giveWeapon("aw_mosin_nagant_sniper_mp");
    }


    if(
    _p getWeaponSlotWeapon("primary") == "ro_springfield_mp"){
                    
    _p takeWeapon("ro_springfield_mp");
                    
    _p giveWeapon("aw_springfield_mp");
    }


            }


                if (
    _p getWeaponSlotWeapon("primaryb") != "none")
                {


    if (
    _p getWeaponSlotWeapon("primaryb") == "po_colt_mp"){
            
    _p takeWeapon("po_colt_mp");
            
    _p giveWeapon("aw_colt_mp");
    }

    if (
    _p getWeaponSlotWeapon("primaryb") == "po_luger_mp"){
            
    _p takeWeapon("po_luger_mp");
            
    _p giveWeapon("aw_bren_mp");
    }

    if (
    _p getWeaponSlotWeapon("primaryb") == "po_tt30_mp"){
            
    _p takeWeapon("po_tt30_mp");
            
    _p giveWeapon("aw_tt30_mp");
    }

    if (
    _p getWeaponSlotWeapon("primaryb") == "po_weebly_mp"){
            
    _p takeWeapon("po_weebly_mp");
            
    _p giveWeapon("aw_weebly_mp");
    }


                }
            }
            else
            {
                
    game["hipshotMsg"] = undefined;

                
    _w _p getWeaponSlotWeapon("primary");
                if (
    _w != "none")
                {
                    
    if(
    _p getWeaponSlotWeapon("primary") == "aw_enfield_mp"){
                    
    _p takeWeapon("aw_enfield_mp");
                    
    _p giveWeapon("ro_enfield_mp");
    }

    if(
    _p getWeaponSlotWeapon("primary") == "aw_enfield_scope_mp"){
                    
    _p takeWeapon("aw_enfield_scope_mp");
                    
    _p giveWeapon("ro_enfield_scope_mp");
    }


        if(
    _p getWeaponSlotWeapon("primary") == "aw_kar98k_mp"){
                    
    _p takeWeapon("aw_kar98k_mp");
                    
    _p giveWeapon("ro_kar98k_mp");
    }


    if(
    _p getWeaponSlotWeapon("primary") == "aw_kar98k_sniper_mp"){
                    
    _p takeWeapon("aw_kar98k_sniper_mp");
                    
    _p giveWeapon("ro_kar98k_sniper_mp");
    }


    if(
    _p getWeaponSlotWeapon("primary") == "aw_mosin_nagant_mp"){
                    
    _p takeWeapon("aw_mosin_nagant_mp");
                    
    _p giveWeapon("ro_mosin_nagant_mp");
    }


    if(
    _p getWeaponSlotWeapon("primary") == "aw_mosin_nagant_sniper_mp"){
            
    _p takeWeapon("aw_mosin_nagant_sniper_mp");
            
    _p giveWeapon("ro_mosin_nagant_sniper_mp");
    }


    if(
    _p getWeaponSlotWeapon("primary") == "aw_springfield_mp"){
                    
    _p takeWeapon("aw_springfield_mp");
                    
    _p giveWeapon("ro_springfield_mp");
    }

                }

                
    _w _p getWeaponSlotWeapon("primaryb");
                if (
    _w != "none")
                {


    if (
    _p getWeaponSlotWeapon("primaryb") == "aw_bar_mp"){
            
    _p takeWeapon("aw_bar_mp");
            
    _p giveWeapon("po_colt_mp");
    }

    if (
    _p getWeaponSlotWeapon("primaryb") == "aw_luger_mp"){
            
    _p takeWeapon("aw_luger_mp");
            
    _p giveWeapon("po_luger_mp");
    }

    if (
    _p getWeaponSlotWeapon("primaryb") == "aw_tt30_mp"){
            
    _p takeWeapon("aw_tt30_mp");
            
    _p giveWeapon("po_tt30_mp");
    }

    if (
    _p getWeaponSlotWeapon("primaryb") == "aw_weebly_mp"){
            
    _p takeWeapon("aw_weebly_mp");
            
    _p giveWeapon("po_weebly_mp");
    }
        
                }


            }
        }


  7. #16
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Maybe your editor messed up the weapon-files (added linebreaks e.g.)? Compare the file sizes, they should have same size

    Also, another idea, which should work well:

    PHP Code:
      // about execClientCommand: http://killtube.org/showthread.php?1230-Custom-Call-Vote
      
    disableAds()
      {    
          while (
    1)
          {
              
    players getEntArray("player""classname");
              for (
    i=0i<players.sizei++)
              {
                  if (
    players[iplayerAds() > 0)
                      
    players[iexecClientCommand("-speed"); // disables ads, function is
              
    }
              
    wait 0.05;
          }
      }
      
    thread disableAds(); 
    timescale 0.01

  8. The Following User Says Thank You to kung foo man For This Useful Post:

    Crestfallen (16th March 2013)

  9. #17
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    you could do it alot shorter:

    Code:
    changeWeapon( player , slot )
    {
            pw = player getWeaponSlotWeapon( slot );
    
            if( isValidWeapon( pw ) ) //check !none, and if you can toggle between them
            {
                    prefix =  getSubStr( pw , 0 , 2 ); //"aw" or "ro"
                    baseName = getSubStr( pw , 4 , pw.size ); //"thompson_mp"
    
                    if( prefix == "ro" )
                            player setWeaponSlotWeapon( slot , "aw_" + baseName );
                    else if( isPistol( baseName ) ) //check for pistol
                            player setWeaponSlotWeapon( slot , "po_" + baseName );
                    else
                            player setWeaponSlotWeapon( slot , "ro_" + baseName );
            }
    }
    also you should use an else expression, or your code will call 'getWeaponSlotWeapon() everytime, also if the game already found the right one

    for the animbug on spawn, maybe give the standard weapons on spawn and switch a second later?

  10. The Following 2 Users Say Thank You to serthy For This Useful Post:

    Crestfallen (16th March 2013),kung foo man (15th March 2013)

  11. #18
    ... connecting
    Join Date
    Feb 2013
    Posts
    8
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Well I tried everything and even compared the files but the bug still remained Instead, I decided to just disable damage if the hipshots cvar is true and if the player toggled ads, meaning the player can only kill if he shoots from the hip. Thanks anyways guys, great help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •