GetPlayerTeamName custom function doesn't work
#1

Код:
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.
Reply
#2

Why do you use cases in large numbers?
Reply
#3

Quote:
Originally Posted by KayJ
Посмотреть сообщение
Why do you use cases in large numbers?
Because someone else here suggested it. Those are just the team IDs.
Reply
#4

Код:
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?
Reply
#5

Is there any way I can keep my custom function?
Reply
#6

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.
Reply
#7

Use strcat instead of equal sign. This is a string, not a number.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)