Results 1 to 7 of 7

Thread: [CoD2] If user press F then sprint

  1. #1
    Private
    Join Date
    Nov 2019
    Posts
    22
    Thanks
    2
    Thanked 3 Times in 3 Posts

    [CoD2] If user press F then sprint

    How can I change the player's speed if he press F key? I know how to detect if player pressed F but I can't change the player's speed:

    PHP Code:
    self endon("disconnect");

    while(
    1)
    {
        if(
    self useButtonPressed())
        {
        
    self iprintlnBold("Sprint activated!");
        }
       
    wait 10;


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

    kung foo man (2nd November 2020)

  3. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Most mods do it by giving the user a different weapon with no model/potatoe.

    Which is why you see your gun disappear.

    For libcod, you can set a per-player speed (player setg_speed(newspeed)). Make sure to set the client-side g_speed cvar too or else you have a laggy user.
    Dont forget to reset it at the end of the sprint time.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  4. The Following User Says Thank You to IzNoGoD For This Useful Post:

    kung foo man (2nd November 2020)

  5. #3
    Private
    Join Date
    Nov 2019
    Posts
    22
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Ummm sadly I don't using libcod yet. But I trying to figure out.

    It seems to work fine but I'm not sure that's the right way and if I'm die while sprinting then I have infinite sprint so the g_speed cvar isn't change back.

    PHP Code:
    init()
    {
    self endon("disconnect");

    while(
    1)
    {
        if(
    self useButtonPressed())
        {
        
    self endon("death");
        
    self setclientcvar("g_speed","300");
        
    self iprintlnBold("Sprint activated!!");
        
    wait 10;
        
    self setclientcvar("g_speed","190");
        
    wait 20;
        }
    }


  6. The Following User Says Thank You to Toxys For This Useful Post:

    kung foo man (2nd November 2020)

  7. #4
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    download some mod that has sprint in it. Look at how it's handled there.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  8. The Following User Says Thank You to IzNoGoD For This Useful Post:

    kung foo man (2nd November 2020)

  9. #5
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    Quote Originally Posted by Toxys View Post
    Ummm sadly I don't using libcod yet. But I trying to figure out.

    It seems to work fine but I'm not sure that's the right way and if I'm die while sprinting then I have infinite sprint so the g_speed cvar isn't change back.

    PHP Code:
    init()
    {
    self endon("disconnect");

    while(
    1)
    {
        if(
    self useButtonPressed())
        {
        
    self endon("death");
        
    self setclientcvar("g_speed","300");
        
    self iprintlnBold("Sprint activated!!");
        
    wait 10;
        
    self setclientcvar("g_speed","190");
        
    wait 20;
        }
    }

    really, download released mod, test, check, look script (how work)
    exists few methods for make "player sprint", but before talk about it you need understand some

    https://killtube.org/showthread.php?...ghlight=sprint
    https://killtube.org/showthread.php?...ghlight=sprint
    https://killtube.org/showthread.php?...ghlight=sprint
    Last edited by maxdamage99; 2nd November 2020 at 06:11.
    PHP Code:
    class CoronaVirus 
    {
       
    CoronaVirus(int m 1): multi(m) { Peoples.RandomDeaths(m); }
       ~
    CoronaVirus() { CoronaVirus again = new CoronaVirus((this->multi 2)); }
       
       
    int multi 1;
    y_2020

  10. The Following User Says Thank You to maxdamage99 For This Useful Post:

    kung foo man (2nd November 2020)

  11. #6
    Private
    Join Date
    Nov 2019
    Posts
    22
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Yes, I saw all of them but I want to activate once after useButtonPressed and not just the "change weapon" method I want to give at least 400x speed just for 10 seconds and the player can't cancel the sprint.

  12. #7
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    458
    Thanks
    79
    Thanked 122 Times in 101 Posts
    Quote Originally Posted by Toxys View Post
    Yes, I saw all of them but I want to activate once after useButtonPressed and not just the "change weapon" method I want to give at least 400x speed just for 10 seconds and the player can't cancel the sprint.
    PHP Code:
    onPlayerSpawned() //function when player spawned
    {
        
    /* ... */
        
        
    self.isSprint false;
        
    self setclientcvar("g_speed""190"); //libcod: self setg_speed(190);
        
        /* ... */
    }

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

        if (!
    isDefined(self.isSprint))
            
    self.isSprint false;
        
        while(
    1)
        {
            if (
    self useButtonPressed() && !self.isSprint)
                
    self thread Sprint();
            
            
    wait .025;
        }
    }

    Sprint()
    {
        
    self endon("disconnect");
        
    self endon("dead"); //put your event ind when player dead from codeCallBack_PlayerKilled(), killed_player, player_killed idc :)
        
        
    self.isSprint true;
        
    self setclientcvar("g_speed""300"); //libcod: self setg_speed(300);
        
    self iprintlnBold("Sprint activated!!");
        
        
    wait 10;
        
        
    self setclientcvar("g_speed""190"); //libcod: self setg_speed(190);
        
        //wait 10; //sprint cooldown if you need, coldown reset if player dead
        
        
    self.isSprint false;

    PHP Code:
    class CoronaVirus 
    {
       
    CoronaVirus(int m 1): multi(m) { Peoples.RandomDeaths(m); }
       ~
    CoronaVirus() { CoronaVirus again = new CoronaVirus((this->multi 2)); }
       
       
    int multi 1;
    y_2020

  13. The Following User Says Thank You to maxdamage99 For This Useful Post:

    Toxys (3rd November 2020)

Tags for this Thread

Posting Permissions

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