AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Getting more than 1 model (https://forums.alliedmods.net/showthread.php?t=153253)

PrinceOf 03-20-2011 16:02

Getting more than 1 model
 
Hello allied mods,

I am trying to get 2 players from each T and CT team , and give them a vip model and announce it to the respectful teams with an hud .... , but what is happening is :
4-5 players in each team get the vip model or the Hud shows the other teams leader ... Plz help me :3

PHP Code:

#include <amxmodx>
#include <cstrike>

#define TASKID_CHOOSELEADER 153

#define PLUGIN "Ghost"
#define VERSION "1.0"
#define AUTHOR "Sam"

new g_maxplayers

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_logevent("logevent_round_start"2"1=Round_Start")
    
register_logevent("logevent_round_end"2"1=Round_End")
    
g_maxplayers get_maxplayers()
}

public 
plugin_precache()
{
    
precache_model("models/player/vip/vip.mdl")
}

public 
logevent_round_start()
{
    static 
id
    
for(id 1id <= g_maxplayersid++) if(is_user_alive(id))
    {
        
set_task(7.0"Leaders"id)
    }
}

public 
Leaders(id)
{
        if(
cs_get_user_team(id) == CS_TEAM_CT)
        {
            new 
iPlayers[32], iNumszName[32]
            
get_players(iPlayersiNum"ae""CT");
            if(
iNum
            {
                
CT(iPlayers[( iNum 1) ? random(iNum) : 0]); 
                
get_user_name(iNumszName31)
                
set_hudmessage(255000.300.3005.05.0)
                
show_hudmessage(id"%s is the Counter Terrorist Leader"szName)
            }
        }
        else if(
cs_get_user_team(id) == CS_TEAM_T)
        {
            new 
iPlayers1[32], iNum1szName1[32];
            
get_players(iPlayers1iNum1"ae""TERRORIST")
            if(
iNum1)
            {
                
T(iPlayers1[( iNum1 1) ? random(iNum1) : 0]); 
                
get_user_name(iNum1szName131)
                
set_hudmessage(255000.300.4005.05.0)
                
show_hudmessage(id"%s is the Terrorist Leader"szName1)
            }
        }
}

public 
CT(id)
{
    
cs_set_user_model(id"vip")
}

public 
T(id)
{
    
cs_set_user_model(id"vip")
}

public 
logevent_round_end()
{
    
remove_task(TASKID_CHOOSELEADER
    static 
id
    
for(id 1id <= g_maxplayersid++) if(is_user_connected(id))
    {
        
cs_reset_user_model(id)
    }



madeitout 03-23-2011 07:02

Re: Getting more than 1 model
 
PHP Code:

#include <amxmodx>
#include <cstrike>

#define PLUGIN "Ghost"
#define VERSION "1.0"
#define AUTHOR "Sam"

new g_maxplayersiLeaders[3][2];

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_logevent("logevent_round_start"2"1=Round_Start")
    
register_logevent("logevent_round_end"2"1=Round_End")
    
g_maxplayers get_maxplayers()
}

public 
plugin_precache()
{
    
precache_model("models/player/vip/vip.mdl")
}

public 
logevent_round_start()
/*{
    set_task(7.0, "Leaders");
}

public Leaders()*/
{
    new 
iTeams[3][16], iTeamCount[3], iduser_team;
    for (
id 1id <= g_maxplayersid++) // makes a list of all alive players split into teams
        
if (is_user_alive(id))
        {
            
user_team get_user_team(id);
            if (
<= user_team <= 2// player is 1 for t or 2 for ct
                
iTeams[user_team][iTeamCount[user_team]++] = id;
        }

    new 
ifoundoverflowpl;
    for (
13i++) // pulls leaders from the list of alive players for both teams
        
switch (iTeamCount[i])
        {
            case 
0iLeaders[i][0] = iLeaders[i][1] = 0;
            case 
1iLeaders[i][0] = iTeams[i][0], iLeaders[i][1] = 0;
            case 
2iLeaders[i][0] = iTeams[i][0], iLeaders[i][1] = iTeams[i][1];
            default: {
                
iLeaders[i][0] = iLeaders[i][1] = found overflow 0// clear leaders and vars
                
while (found && overflow++ < 300)
                {
                    
pl random(iTeamCount[i]);
                    if (
iTeams[i][pl] && iLeaders[i][0] != iTeams[i][pl]) // check if random player is real and if he wasnt already selected
                        
iLeaders[i][found++] = iTeams[i][pl];
                }
            }
        }

    new 
szNames[2][32];
    for (
13i++) // finish the leaders for each team
    
{
        if (!
iLeaders[i][0]) // no leaders were found for their team
            
break;

        for (
id 0id 2id++) // set the two leaders and get their names
            
if (iLeaders[i][id])
            {
                
get_user_name(iLeaders[i][id], szNames[id], 31);
                
cs_set_user_model(iLeaders[i][id], "vip");
            }

        for (
id 0id iTeamCount[i]; id++) // notify teams of their leaders
        
{
            
set_hudmessage((== 2) ? 25530, (== 2) ? 255 00.300.3005.05.0);
            if (
iLeaders[i][1]) // check to see if there were enough players for the 2nd leader
                
show_hudmessage(iTeams[i][id], "%s and %s are the %sTerrorist Leaders"szNames[0], szNames[1], (== 2) ? "Counter " "");
            else
                
show_hudmessage(iTeams[i][id], "%s is the %sTerrorist Leader"szNames[0], (== 2) ? "Counter " "");
        }
    }
}

public 
logevent_round_end()
{
    for (new 
team 1team 3team++) // reset models
        
for (new id 0id 2id++)
            if (
is_user_connected(iLeaders[team][id]))
                
cs_reset_user_model(iLeaders[team][id]);



PrinceOf 03-23-2011 11:28

Re: Getting more than 1 model
 
EH!!! , i wanted to know whats wrong with mine , its scripting help
(Thanks fot your script, but i wanna know whats wrong with mine)

Exolent[jNr] 03-23-2011 20:21

Re: Getting more than 1 model
 
Quote:

Originally Posted by PrinceOf (Post 1437998)
any1?

Don't bump until 2 weeks have passed since last post.


All times are GMT -4. The time now is 14:35.

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