This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Plugin Random Player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-09-2024 , 19:22   Re: Plugin Random Player
Reply With Quote #1

Here's an adjusted version. I also added some cvars so you can easily modify the prefix, health and armor values. Once again, untested.

PHP Code:
#include <amxmodx>
#include <fun>
#include <cstrike>

#pragma semicolon 1

#define pluginName "RandomPlayerBenefits"
#define pluginVersion "1.0.0"
#define pluginAuthor "LadderGoat"

#define taskID 20874

new messagePrefix;
new 
terroristHealth;
new 
terroristArmor;
new 
counterTerroristHealth;
new 
counterTerroristArmor;

public 
plugin_init()
{
    
register_plugin(pluginNamepluginVersionpluginAuthor);
    
register_logevent("roundStart"2"1=Round_Start");
    
register_logevent("roundEnd"2"1=Round_End");

    
messagePrefix register_cvar("rpb_prefix""AMXx");

    
terroristHealth register_cvar("rpb_thealth""200");
    
terroristArmor register_cvar("rpb_tarmor""100");
    
counterTerroristHealth register_cvar("rpb_cthealth""250");
    
counterTerroristArmor register_cvar("rpb_ctarmor""150");
}

public 
roundStart()
{
    if(
task_exists(taskID))
        
remove_task(taskID);

    
set_task(60.0"randomPlayerSelection" ,taskID);   
}

public 
roundEnd()
{
    if(
task_exists(taskID))
        
remove_task(taskID);
}

public 
randomPlayerSelection()
{
    new 
tPlayers[MAX_PLAYERS], tPlayerCountctPlayers[MAX_PLAYERS], ctPlayerCount;
    new 
playerName[MAX_NAME_LENGTH];
    new 
teamSelector random(1);
    new 
chatPrefix[9]; // 10 characters for a prefix should be more than enough. 
    
    
get_players(tPlayerstPlayerCount"ae""TERRORIST");
    
get_players(ctPlayersctPlayerCount"ae""CT");
    
get_pcvar_string(messagePrefixchatPrefixcharsmax(chatPrefix));
    
    if(
teamSelector == && tPlayerCount)
    {
        new 
tHealth get_pcvar_num(terroristHealth);
        new 
tArmor get_pcvar_num(terroristArmor);
        new 
randomTerrorist tPlayers[random(tPlayerCount)];

        
set_user_health(randomTerroristget_user_health(randomTerrorist) + 200);
        
set_user_armor(randomTerroristget_user_armor(randomTerrorist) + 100);
        
get_user_name(randomTerroristplayerNamecharsmax(playerName));
        
client_print_color(0print_team_red"^4[%s]^3 %s^1 was randomly picked and received an extra %i health and %i armor."chatPrefixplayerNametHealthtArmor);
    }

    else if(
teamSelector == && ctPlayerCount)
    {
        new 
ctHealth get_pcvar_num(counterTerroristHealth);
        new 
ctArmor get_pcvar_num(counterTerroristArmor);
        new 
randomCt ctPlayers[random(ctPlayerCount)];

        
set_user_health(randomCtget_user_health(randomCt) + ctHealth);
        
set_user_armor(randomCtget_user_armor(randomCt) + ctArmor);
        
get_user_name(randomCtplayerNamecharsmax(playerName));
        
client_print_color(0print_team_blue"^4[%s]^3 %s^1 was randomly picked and received an extra %i health and %i armor."chatPrefixplayerNamectHealthctArmor);
    }

__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
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 08:21.


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