Thread: Simple WarmUp
View Single Post
tarsisd2
Veteran Member
Join Date: Feb 2016
Location: brazil
Old 04-22-2024 , 14:13   Re: Simple WarmUp
Reply With Quote #20

Quote:
Originally Posted by mlibre View Post
share such wonder

of course man

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <hamsandwich>

#define PLUGIN "Simple Knife Warmup"
#define VERSION "1.2"  // Version update
#define AUTHOR "Sn!ff3r EL3"

#define TASKID 1234
#define PLAYER_HEALTH 35
#define MAX_SPEED 250.0 // Adjusted max speed

new hudtimercvarhudhandlermp_freezetimevalue

// Error handling for critical functions
public plugin_init() 
{
    if (!
register_plugin(PLUGINVERSIONAUTHOR)) {
        
printf("Error: Could not register plugin %s"PLUGIN);
        return 
PLUGIN_FAILED;
    }

    if ((
cvar register_cvar("warmup_timer""30")) == INVALID_CVAR) {
        
printf("Error: Could not register cvar warmup_timer");
        return 
PLUGIN_FAILED;
    }
    
    
register_message(get_user_msgid("TextMsg"), "message_TextMsg");
    
register_dictionary("simple_warmup.txt");

    
hudhandler CreateHudSyncObj();

    
RegisterHam(Ham_Spawn"player""fw_spawn"1);
}

// Error handling for retrieving cvar pointer
public plugin_cfg() 
{
    if ((
mp_freezetime get_cvar_pointer("mp_freezetime")) == INVALID_CVAR) {
        
printf("Error: Could not retrieve cvar pointer for mp_freezetime");
        return 
PLUGIN_FAILED;
    }
    
    
set_task(10.0"read_vars");
}

public 
fw_spawn(id
{
    if(
task_exists(TASKID)) 
    {
        
set_user_health(idPLAYER_HEALTH);
        
set_user_maxspeed(idMAX_SPEED);
    }
}

public 
read_vars()
{    
    
value get_pcvar_num(mp_freezetime);
}

public 
message_TextMsg(const MsgId, const MsgDest, const MsgEntity)
{    
    static 
message[64];
    
get_msg_arg_string(2messagecharsmax(message));
    
    if(
equal(message"#Game_Commencing"))
    {
        
hudtimer get_pcvar_num(cvar);
        
        if(
hudtimer == -1)
            return;
        
        
formatex(messagecharsmax(message), "%L"LANG_PLAYER"WARUMP_START");    
        
set_msg_arg_string(2message);
        
        
set_task(1.0"restart"TASKID__"b");        
        
set_pcvar_num(mp_freezetime0);        
    }
    if(
equal(message"#Game_will_restart_in"))
    {
        
formatex(messagecharsmax(message), "%L"LANG_PLAYER"WARUMP_END");    
        
set_msg_arg_string(2message);
    }
}

public 
restart()
{            
    if(
hudtimer <= 0)
    {
        
remove_task(TASKID);
        
set_cvar_num("sv_restartround"1);
        
set_pcvar_num(mp_freezetimevalue);        
    } 
    else 
    {
        
hudtimer--;
        
set_hudmessage(255,255,255,-1.0,0.9,0,6.0,1.0,0.1,0.2);    
        
ShowSyncHudMsg(0hudhandler"%L"LANG_PLAYER"COUNTING"hudtimer);
    }    
}

public 
switchweapon(id)
{
    if(
task_exists(TASKID)) 
    {
        
engclient_cmd(id"weapon_knife");
    }
}

public 
reset_speed(id)
{
    if(
task_exists(TASKID)) 
    {
        
set_user_maxspeed(idMAX_SPEED);
    }

tarsisd2 is offline