AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved team name (https://forums.alliedmods.net/showthread.php?t=324116)

tepegoz 05-06-2020 14:17

team name
 
I want to show team names as T,CT,SPEC but it is showing 1,2,3. How to change 1,2,3 to T,CT,SPEC ?


PHP Code:

new team get_user_team(z)
new 
lFirstSaid[64];

   
format(lFirstSaid63"%s - %i: %i: %i - %i -",anameg_s[z][TIME_MINUTES], g_s[z][TIME_SECONDS], g_s[z][TIME_MSECONDS],team


MagNNusS 05-06-2020 15:26

Re: team name
 
PHP Code:

new TeamNames[MAX_TEAMS][] =
{
    
"Spectator",
    
"Terrorist",
    
"Counter-Terrorist"


Then:

PHP Code:

new team get_user_team(z)
new 
lFirstSaid[64];

   
format(lFirstSaid63"%s - %i: %i: %i - %s -",anameg_s[z][TIME_MINUTES], g_s[z][TIME_SECONDS], g_s[z][TIME_MSECONDS], TeamNames[team]) 


Bugsy 05-06-2020 15:26

Re: team name
 
Quote:

Originally Posted by tepegoz (Post 2698545)
I want to show team names as T,CT,SPEC but it is showing 1,2,3. How to change 1,2,3 to T,CT,SPEC ?


PHP Code:

new team get_user_team(z)
new 
lFirstSaid[64];

   
format(lFirstSaid63"%s - %i: %i: %i - %i -",anameg_s[z][TIME_MINUTES], g_s[z][TIME_SECONDS], g_s[z][TIME_MSECONDS],team


In your code, 'team' is the integer representation/index of the team.
0 = unassigned
1 = T
2 = CT
3 = Spec

You also need to use %s, not %i to format a string value

Add #include <cstrike>
PHP Code:

new CsTeams:team cs_get_user_team(z)
new 
lFirstSaid[64];
new const 
szTeamsCsTeams ][] = { "UNASSIGNED" "T" "CT" "SPEC" };

formatex(lFirstSaidcharsmax(lFirstSaid), "%s - %i: %i: %i - %s -",anameg_s[z][TIME_MINUTES], g_s[z][TIME_SECONDS], g_s[z][TIME_MSECONDS],szTeamsteam ] ) 


tepegoz 05-08-2020 09:13

Re: team name
 
thanks

OnePL 05-09-2020 18:36

Re: team name
 
PHP Code:

new szTeam[16], lFirstSaid[64];
get_user_team(zszTeamcharsmax(szTeam));

format(lFirstSaid63"%s - %i: %i: %i - %s -",anameg_s[z][TIME_MINUTES], g_s[z][TIME_SECONDS], g_s[z][TIME_MSECONDS], szTeam); 


Napoleon_be 05-09-2020 18:41

Re: team name
 
Quote:

Originally Posted by OnePL (Post 2699140)
PHP Code:

new szTeam[16], lFirstSaid[64];
get_user_team(zszTeamcharsmax(szTeam));

format(lFirstSaid63"%s - %i: %i: %i - %s -",anameg_s[z][TIME_MINUTES], g_s[z][TIME_SECONDS], g_s[z][TIME_MSECONDS], szTeam); 


If you're trying to be smarter than bugsy, please be correct. As bugsy mentioned before, that code will output integers 0, 1, 2 or 3. And why are you hardcoding array lengths?

Bugsy 05-09-2020 19:05

Re: team name
 
get_user_team() can retrieve the team name into a string, but I remember there being issues with get_user_team() sometimes returning incorrect values so I always use cs_get_user_team().

Natsheh 05-10-2020 07:33

Re: team name
 
Yes bugsy it return false values depending on the player last team when he was alive it doesn't follow the offset until he get respawned basically it get updated to the offset when the player get respawned.

I think get_user_team gets player team from the scoreboard info

OnePL 05-10-2020 12:40

Re: team name
 
Only teamId is gets from ScoreInfo


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

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