PDA

View Full Version : GetPlayerTeamName custom function doesn't work


stormchaser206
09/03/2018, 11:23 PM
GetPlayerTeamName(playerid)
{
new szString[24];
new team;
team = GetPlayerTeam(playerid);

switch(team)
{
case 5000: szString = "United States";
case 5001: szString = "Canada";
case 5002: szString = "Britain";
case 5003: szString = "Australia";
case 5004: szString = "Russia";
case 5005: szString = "Germany";
case 5006: szString = "Italy";
case 5007: szString = "France";
case 5008: szString = "China";
case 5009: szString = "India";
}
return szString;
}

I have that as a custom function but whenever I use it, it doesn't put anything in-game. Just blank.

Example: https://i.imgur.com/ZTBoUHJ.png
The team name should be at the end.

KayJ
10/03/2018, 04:49 AM
Why do you use cases in large numbers?

stormchaser206
10/03/2018, 05:43 PM
Why do you use cases in large numbers?

Because someone else here suggested it. Those are just the team IDs.

Stuntff
10/03/2018, 05:53 PM
new const gTeamName[10][15] =
{
"United States",
"Canada",
"Britain",
"Australia",
"Russia",
"Germany",
"Italy",
"France",
"China",
"India"
};

printf("team name = %s", gTeamName[GetPlayerTeam(playerid)-5000]);


No?

stormchaser206
11/03/2018, 03:50 AM
Is there any way I can keep my custom function?

Sew_Sumi
11/03/2018, 04:02 AM
There's no point to your function if you use the method he's shown.

You could integrate what he's shown into your function, but it sort of defeats the purpose of the method he's shown you in the first place.

Dayrion
11/03/2018, 04:02 AM
Use strcat instead of equal sign. This is a string, not a number.