AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Round master (https://forums.alliedmods.net/showthread.php?t=128849)

reinert 06-06-2010 06:14

Round master
 
Hey, I've made a code that should select a player every round from both teams, and give them +hp +ap +speed, but it doesn't work.

here is my code:

PHP Code:

#include <amxmodx>
#include <fun>
#include <hamsandwich>
#include <cstrike>

#define PLUGIN "Round boss"
#define VERSION "1.0"
#define AUTHOR "addinol"

new Boss:PlayerMode[33];

new 
hpapbspeed

enum Boss
{
    
boss 1
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHamHam_Spawn"player""FwdHamPlayerSpawnPost");
    
hp register_cvar("inch_bosshp","200")
    
ap register_cvar("inch_bossap","200")
    
bspeed register_cvar("inch_bosssp","30.0")
    
register_event("CurWeapon""Event_CurWeapon""be","1=1");
}

public 
FwdHamPlayerSpawnPost(id)
{
   if(
cs_get_user_team(id) == CS_TEAM_T){
        
PlayerMode[id] = Boss:random);
   }else if(
cs_get_user_team(id) == CS_TEAM_CT){
        
PlayerMode[id] = Boss:random);
   }
   if(
PlayerMode[id] == Boss)
   {
       
client_print(idprint_chat"This round you will be the chosen one")
        if(
get_pcvar_num(hp) != 0){
    
set_user_health(id get_pcvar_num(hp));
    }else{
    }
    if(
get_pcvar_num(ap) != 0){
    
set_user_armor(id get_pcvar_num(ap));
    }else{
    }
    }
}


public 
Event_CurWeapon(id)
{
    if(
PlayerMode[id] == Boss)
    {
    if(
get_pcvar_float(bspeed) != 0){
    new 
Float:speed get_user_maxspeed(id) + get_pcvar_float(bspeed);
    
set_user_maxspeed(id speed);
    }else{
    
    }
    
}


Where the hell is problem ?

Sylwester 06-06-2010 07:12

Re: Round master
 
I would do it this way:
PHP Code:

#include <amxmodx>
#include <fun>
#include <hamsandwich>
#include <cstrike>

#define PLUGIN "Round boss"
#define VERSION "1.0"
#define AUTHOR "addinol"

new bool:g_is_boss[33]
new 
g_max_players
new hpapbspeed

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_logevent("logevent_round_start"2"1=Round_Start")
    
register_event("HLTV""event_new_round""a""1=0""2=0")
    
register_event("CurWeapon""Event_CurWeapon""be","1=1");
    
g_max_players get_maxplayers()
    
    
hp register_cvar("inch_bosshp","200")
    
ap register_cvar("inch_bossap","200")
    
bspeed register_cvar("inch_bosssp","30.0")
}


public 
event_new_round(){
    for(new 
i=0i<=g_max_playersi++)
        
g_is_boss[i] = false
}


public 
logevent_round_start(){
    static 
players[32], pnum
    get_players
(playerspnum"ae""CT")
    if(
pnum>0)
        
make_boss(playersrandom(pnum) ])

    
get_players(playerspnum"ae""TERRORIST")
    if(
pnum>0)
        
make_boss(playersrandom(pnum) ])
}


public 
make_boss(id){
    
set_user_health(id get_pcvar_num(hp))
    
cs_set_user_armor(idget_pcvar_num(ap), CS_ARMOR_VESTHELM)
    
g_is_boss[id] = true
}


public 
Event_CurWeapon(id){
    if(
g_is_boss[id])
        
set_user_maxspeed(id get_user_maxspeed(id) + get_pcvar_float(bspeed));



reinert 06-06-2010 09:28

Re: Round master
 
Thanks, hope it works :p

EDIT: why master gets even faster when he is shooting ar running ? my maxspeed is then about 400 instead of 250+30


All times are GMT -4. The time now is 05:16.

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