AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Team Name (https://forums.alliedmods.net/showthread.php?t=205736)

tyin 01-13-2013 22:17

Team Name
 
What should plugin do:
This is CSO Like connect announce to other users.
When new player connect on server other players will see this message
"name" connected
When new player choose team and join the server other players will see this message
"name" joined the "teamname" force
When player left the server other players will see this message
"name" has left the game

Problem with my plugin is @ client_putinserver
When new player choose a team and class other players don't see
"name" joined the "teamname" force

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

public client_connect(id)
{
    new 
name[32];
    
get_user_name(idnamecharsmax(name));

    
client_print(0print_chat"%s connected"name);
}

public 
client_putinserver(id)
{
    new 
name[32], teamname[32], arg1[32];
    new 
player cmd_target(idarg12);
    
get_user_name(idnamecharsmax(name));
    
read_argv(1arg131)

    if ( 
cs_get_user_team(player) == CS_TEAM_T )
    {
        
teamname "Terrorist"
    
}
    else if ( 
cs_get_user_team(player) == CS_TEAM_CT )
    {
        
teamname "Counter-Terrorist"
    
}

    
client_print(0print_chat"%s is joining the %s force"nameteamname);
}

public 
client_disconnect(id)
{
    new 
name[32];
    
get_user_name(idnamecharsmax(name));

    
client_print0print_chat"%s has left the game"name );



fysiks 01-14-2013 01:22

Re: Team Name
 
Quote:

Originally Posted by tyin (Post 1873147)
When new player connect on server other players will see this message
"name" connected
When new player choose team and join the server other players will see this message
"name" joined the "teamname" force
When player left the server other players will see this message
"name" has left the game

This is how it already works IIRC.

About the code, it is all written wrong. client_putinserver() is called when the player is put in the server, not when they join a team. You are using cmd_target() wrong, the variable "player" is always 0 and will cause a run-time error. You should not assign strings to arrays with the equal sign. In this case, you should use a global array of strings for your team names. Use a switch() statement when using cs_get_user_team() instead of inefficiently using two if statements.


All times are GMT -4. The time now is 13:44.

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