Team display on stats.
#1

Hi, I am kind of having a problem with pTeam when I use it to display the team name on stats. If I use %s for the string, it gives me a blank sentence only saying Team:

If I use %d it gives me the number used to define the team.

My code.

if(IsPlayerConnected(playerid))
{
new team = pTeam[playerid];
new str[500];
format(string,sizeof(string),"Team: %s", team);
SendClientMessage(playerid, -1, string);
}
return 1;

I am using a Y_Ini system to save the teams, and it only works if I use pTeam[playerid] in the info.
such as this

INI_Int("Team",pTeam[playerid]);

Now my team defines.
#define TEAM_R 1
#define TEAM_CIVILIANS 2
#define TEAM_REBELS 3
#define TEAM_ARMY 4

How would I make it display the names instead of the numbers?
Reply
#2

pawn Код:
#define MAX_TEAM_NAME 128

stock GetTeam(teamid)
{
    new string[MAX_TEAM_NAME];
    switch(teamid)
    {
        case 0: format(string, sizeof(string), "SWAT");
        case 1: format(string, sizeof(string), "FBI");
    }
    return string;
}
Example: format(string,sizeof(string),"Team: %s", GetTeam(pTeam[playerid]));
Reply
#3

I remember that i got this from one guy, but I can't remember his name..
pawn Код:
stock GetTeamName(playerid)
{
    new teamname[14];
    switch(GetPlayerTeam(playerid))
    {
        case 0: format(teamname, sizeof(teamname), "R");
        case 1: format(teamname, sizeof(teamname), "Civilians");
        case 2: format(teamname, sizeof(teamname), "Rebels");
        case 3: format(teamname, sizeof(teamname), "Army");
    }
    return teamname;
}
Your code should look like this then;
pawn Код:
if(IsPlayerConnected(playerid))
{
new str[24];
format(string,sizeof(string),"Team: %s", GetTeamName(playerid));
SendClientMessage(playerid, -1, string);
}
EDIT: SickAttack was faster
Reply
#4

Example :

pawn Код:
stock GetPlayerTeamName(playerid)
{
    new szString[28];
    switch(PlayerInfo[playerid][pTeam])
    {
        case 0: szString = "None";
        case 1: szString = "Groove Street;
        case 2: szString = "
Ballas";
        case 3: szString = "
Aztec";
        case 4: szString = "
China";
        case 5: szString = "
Police";

    }
    return szString;
}

CMD:Showteamid(playerid,params[])
{
    new string[100];
    format(string,sizeof(string),"
Your team is: %s",GetPlayerTeamName(playerid));
    SendClientMessage(playerid,COLOR,string);
    return 1;
}
EDIT:TO LATE D
Reply
#5

Thanks alot guys, I really appreciate this , Its working now, thanks for all of your responses, <3
Repped all
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)