Raised This Month: $51 Target: $400
 12% 

All player speed on round start


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 06-11-2023 , 14:49   All player speed on round start
Reply With Quote #1

Hello, i cant get this to work, basically for 10 seconds on round start all players have like x5 speed.
Can anyone tell me what im doing wrong here?
PHP Code:
#include <amxmodx>
#include <fun>

#define SPEED_BOOST 5.0 // Speed multiplier for boost
#define DURATION 10.0
#define MAX_PLAYERS 32

new Float:g_fBoostEnd[MAX_PLAYERS+1]; // Array to store the boost end time for each player

public plugin_init()
{
    
register_plugin("Round Speed Boost""1.0""LVNDR");
    
register_event("HLTV""event_round_start""ab""1=0""2=0")
}

public 
event_round_start(id, const name[], bool:restarting)
{
    new 
iPlayer get_user_userid(id);

    if (!
is_user_connected(iPlayer) || !is_user_alive(iPlayer))
        return;

    
g_fBoostEnd[iPlayer] = get_gametime() + DURATION;

    
set_user_maxspeed(iPlayerSPEED_BOOST);
    
set_task(DURATION"reset_speed"iPlayer);
}

public 
reset_speed(iPlayer)
{
    if (!
is_user_connected(iPlayer) || !is_user_alive(iPlayer))
        return 
PLUGIN_HANDLED;

    
set_user_maxspeed(iPlayer0.0);
    return 
PLUGIN_HANDLED;

HowToRuski is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 06-11-2023 , 16:13   Re: All player speed on round start
Reply With Quote #2

1. you don't have any parameters when hooking round start event.
2. you must pass through all players and set a boolean variable true (like g_bHasSpeed) using get_players/get_playersex
3. you must use hamsandwich
4. use set_user_speed in this ham hook
Code:
    /**
     * Description:     Resets the player's max speed.
     * Forward params:  function(this);
     * Return type:     None.
     * Execute params:  ExecuteHam(Ham_CS_Player_ResetMaxSpeed, this);
     */
    Ham_CS_Player_ResetMaxSpeed,
https://forums.alliedmods.net/showthread.php?t=136908

5. you don't need get_gametime() + duration method, this is often used in setting entities next think hook.
lexzor is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:32.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode