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
MrPower
Member
Join Date: Feb 2016
Old 05-08-2024 , 12:49   Plugin Random Player
Reply With Quote #1

Hellos

I would also like a radom player plugin, that is, for tero to choose a radom player and give 200 hp + 100 ap and for ct to give a radom player 250 hp + 150 ap, yes I would like a radom player (tero and ct) to appear after 60 sec.
MrPower is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-08-2024 , 14:29   Re: Plugin Random Player
Reply With Quote #2

Quote:
Originally Posted by MrPower View Post
Hellos

I would also like a radom player plugin, that is, for tero to choose a radom player and give 200 hp + 100 ap and for ct to give a radom player 250 hp + 150 ap, yes I would like a radom player (tero and ct) to appear after 60 sec.
How do you want this to happen? Every round? Using a command?
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
v120kaaimcfg
Member
Join Date: Apr 2024
Old 05-08-2024 , 16:24   Re: Plugin Random Player
Reply With Quote #3

Quote:
Originally Posted by MrPower View Post
Hellos

I would also like a radom player plugin, that is, for tero to choose a radom player and give 200 hp + 100 ap and for ct to give a radom player 250 hp + 150 ap, yes I would like a radom player (tero and ct) to appear after 60 sec.
Here

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

public plugin_init() 
{
    
register_plugin("Random player bonus HP & AP""1""")
    
register_event("HLTV""event_new_round""a""1=0""2=0")
}

public 
event_new_round()
{
    if(
task_exists(987654))
    {
        
remove_task(987654)
    }
    
set_task(60.0"random_bonus_HP_AP"987654)
}

public 
random_bonus_HP_AP()
{
    new 
players_CT[32], numCTplayers_T[32], numT
    get_players
(players_CTnumCT"aeh""CT")
    
get_players(players_TnumT"aeh""TERRORIST")

    if(
numCT)
    {
        new 
randCT players_CT[random(numCT)]
        
set_user_health(randCTget_user_health(randCT) + 250)
        
cs_set_user_armor(randCTget_user_armor(randCT) + 150CS_ARMOR_VESTHELM)
        
client_print(0print_chat"%n won 250HP + 150AP bonus!"randCT)
    }
    if(
numT)
    {
        new 
randT players_T[random(numT)]
        
set_user_health(randTget_user_health(randT) + 200)
        
cs_set_user_armor(randTget_user_armor(randT) + 100CS_ARMOR_VESTHELM)
        
client_print(0print_chat"%n won 200HP + 100AP bonus!"randT)
    }

v120kaaimcfg is offline
MrPower
Member
Join Date: Feb 2016
Old 05-09-2024 , 08:57   Re: Plugin Random Player
Reply With Quote #4

I want each round to receive a radome ct or tero as I wrote above
MrPower is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-09-2024 , 10:51   Re: Plugin Random Player
Reply With Quote #6

Untested as i have no server setup atm.

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

#pragma semicolon 1

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

#if !defined MAX_PLAYERS
    #define MAX_PLAYERS 32
#endif

#define taskID 20874

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

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;
    
get_players(tPlayerstPlayerCount"ae""TERRORIST");
    
get_players(ctPlayersctPlayerCount"ae""CT");
    new 
teamSelector random(1);
    
    if(
teamSelector == && tPlayerCount)
    {
        new 
randomTerrorist tPlayers[random(tPlayerCount)];
        
set_user_health(randomTerroristget_user_health(randomTerrorist) + 200);
        
set_user_armor(randomTerroristget_user_armor(randomTerrorist) + 100);
    }

    else if(
teamSelector == && ctPlayerCount)
    {
        new 
randomCt ctPlayers[random(ctPlayerCount)];
        
set_user_health(randomCtget_user_health(randomCt) + 250);
        
set_user_armor(randomCtget_user_armor(randomCt) + 150);
    }

__________________

Last edited by Napoleon_be; 05-09-2024 at 10:55.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
MrPower
Member
Join Date: Feb 2016
Old 05-09-2024 , 11:10   Re: Plugin Random Player
Reply With Quote #7

It works, yes, I would like a message to appear on the tero and on the ct, that is, a message in the chat [AMXX] Player The name Random player received 200 hp and 100 ap. In the name where the name of the player is written, the name of the player should appear.
MrPower is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 05-09-2024 , 19:22   Re: Plugin Random Player
Reply With Quote #8

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 09:48.


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