GetPlayer Team
#1

Well, I really have no idea how can i get Team Name. I'm using skin in my script as Classid.

But i added a commands Where player can see player's team. I mean, Second player can see if first player is Cop or Civilian or blah.

But i don't know how does it work. I mean, How to save team names on mysql or getplayerteamname? something where it does show player team name.

Thanks!
Reply
#2

u can use player vaariable
Код:
new whatteam[MAX_PLAYERS];
and when they join team cop u set it to
Код:
 whatteam[playerid] = 1;
and when u need to get name of team of player u use it like this
Код:
if(whatteam[playerid] ==1)
{
SendClientMessage(playerid,-1,"This player is cop");
}
Reply
#3

Something like that:
pawn Код:
#define TEAM_POLICE         0
#define TEAM_MAFIA          1
#define TEAM_BLAH            2
#define TEAM_CIVILIAN       3


new teamNames[][] = {
    {"Police"},
    {"Mafia"},
    {"Blah"},
    {"Civilian"}
};

GetPlayerTeamName(playerid)
{
    new name[24];
    format(name, sizeof name, "%s", teamNames[GetPlayerTeam(playerid)]);
    return name;
}
Reply
#4

Well, I could do this before. But actually, I want to save team name in mysql.

I'm using like this:

PHP код:
new gTeam[MAX_PLAYERS];
new 
gPlayerClass[MAX_PLAYERS];
///Player Classes
forward SetPlayerTeamFromClass(playeridclassid);
public 
SetPlayerTeamFromClass(playeridclassid)
{
    
SetupPlayerForClassSelection(playerid,classid);
    
gPlayerClass[playerid] = classid;
    {
    if (
classid == || classid == || classid == || classid == || classid == || classid == || classid == || classid == || classid == || classid == || classid == 10 || classid == 11)
    {
         
gTeam[playerid] = COPS;
         
GameTextForPlayer(playerid"~b~POLICE OFFICER"6005);
        return 
1;
    }
    else if (
classid == 12 )
    {
         
gTeam[playerid] = ARMY;
         
GameTextForPlayer(playerid"~b~~h~ARMY"5005);
         return 
1;
     }
    else if (
classid == 13)
    {
         
gTeam[playerid] = FBI;
         
GameTextForPlayer(playerid"~b~FBI"5005);
         return 
1;
    }
    else if (
classid == 14 || classid == 15 || classid == 16)
    {
        
gTeam[playerid] = CIA;
            
GameTextForPlayer(playerid"~w~CIA"5005);
        return 
1;
    }
    else if (
classid == 17 || classid == 18 || classid == 19 || classid == 20)
    {
        
gTeam[playerid] = MEDICS;
            
GameTextForPlayer(playerid"~p~~h~MEDIC"5005);
        return 
1;
    }
    else if (
classid >= 21)
    {
        
gTeam[playerid] = CIVILIANS;
            
GameTextForPlayer(playerid"~w~CIVILIAN"5005);
        return 
1;
    }
    return 
1;
    }

im just confused what should i add here for get player team name

PHP код:
forward OnPlayerSave(playerid);
public 
OnPlayerSave(playerid)
{
    new 
query[500];
    if(
IsLoggedIn[playerid] == && playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid))
    {
        
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `Admin`=%d, `Vip`=%d, `Money`=%d, `Score`=%d, `Deaths`=%d, `Kills`=%d, `SkinID`=%d, `Robbed`=%d, `RobbedMoney`=%d, `GotRobbed`=%d, `GotRobbedMoney`=%d, `StoreRobbed`=%d, `StoreRobbedMoney`=%d, `FoodPurchased`=%d, `FoodPurchasedMoney`=%d, `WeaponsPurchased`=%d, `WeaponsPurchasedMoney`=%d WHERE `ID`=%d AND `user`='%e'",
        
pInfo[playerid][pAdmin],
        
pInfo[playerid][pVip],
        
GetPlayerMoney(playerid),
        
GetPlayerScore(playerid),
        
pInfo[playerid][pDeaths],
        
pInfo[playerid][pKills],
        
GetPlayerSkin(playerid),
        
pInfo[playerid][pRobbed],
        
pInfo[playerid][pRobbedMoney],
        
pInfo[playerid][pGotRobbed],
        
pInfo[playerid][pGotRobbedMoney],
        
pInfo[playerid][pStoreRobbed],
        
pInfo[playerid][pStoreRobbedMoney],
        
pInfo[playerid][pFoodPurchased],
        
pInfo[playerid][pFoodPurchasedMoney],
        
pInfo[playerid][pWeaponsPurchased],
        
pInfo[playerid][pWeaponsPurchasedMoney],
        
pInfo[playerid][pID],
        
PlayerName(playerid));
        
mysql_tquery(MySQLConquery"""");
        print(
query);
        
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `IsBanned`=%d WHERE `ID`=%d AND user='%e'"pInfo[playerid][pIsBanned], PlayerName(playerid));
        
mysql_tquery(MySQLConquery"""");
        
IsLoggedIn[playerid] = 0;
        if(
pInfo[playerid][pAdmin] >= 1)
        {
            
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `AdminName`=%s WHERE `ID`=%d AND `user`='%e'"pInfo[playerid][pAName]);
            return 
true;
        }
    }
    return 
1;

Reply
#5

Quote:
Originally Posted by [XST]O_x
Посмотреть сообщение
Something like that:
pawn Код:
#define TEAM_POLICE         0
#define TEAM_MAFIA          1
#define TEAM_BLAH            2
#define TEAM_CIVILIAN       3


new teamNames[][] = {
    {"Police"},
    {"Mafia"},
    {"Blah"},
    {"Civilian"}
};

GetPlayerTeamName(playerid)
{
    new name[24];
    format(name, sizeof name, "%s", teamNames[GetPlayerTeam(playerid)]);
    return name;
}
I have tried this. but it messed up. I mean, I'm civilian but it shows me Cop.
Reply
#6

what about this: new teamname[24];
PHP код:
if(gTeam[playerid] == COPSteamname "Cop";
if(
gTeam[playerid] == ARMYteamname "Army";
if(
gTeam[playerid] == FBIteamname "FBI";
if(
gTeam[playerid] == CIAteamname "CIA";
if(
gTeam[playerid] == CIVILIANSteamname "Civilian";
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `Team`=%s WHERE `ID`=%d AND user='%e'"teamnamepInfo[playerid][pID], PlayerName(playerid)); 
mysql_tquery(MySQLConquery""""); 
just add new column in database called Team and u can load it on login and store it to gTeam

PHP код:
GetPlayerTeamName(playerid)
{
        new 
teamname[24];
        if(
gTeam[playerid] == COPSteamname "Cop";
        if(
gTeam[playerid] == ARMYteamname "Army";
        if(
gTeam[playerid] == FBIteamname "FBI";
        if(
gTeam[playerid] == CIAteamname "CIA";
        if(
gTeam[playerid] == CIVILIANSteamname "Civilian";
    new 
name[24];
    
format(namesizeof name"%s"teamname);
    return 
name;

Reply
#7

Quote:
Originally Posted by STONEGOLD
Посмотреть сообщение
I have tried this. but it messed up. I mean, I'm civilian but it shows me Cop.
The order is specifically for what I have posted.
You need to change the order according to your code.
How do you define the teams in your script?
Reply
#8

//// Classes
#define COPS 1
#define CIVILIANS 0
#define CIA 3
#define MEDICS 4
#define ARMY 5
#define FBI 6
Reply
#9

Quote:
Originally Posted by STONEGOLD
Посмотреть сообщение
//// Classes
#define COPS 1
#define CIVILIANS 0
#define CIA 3
#define MEDICS 4
#define ARMY 5
#define FBI 6
then order it by this:
PHP код:
new teamNames[][] = {
    {
"Civilan"},
    {
"Cops"},
    {
"CIA"},
    {
"Medics"},
    {
"Army"},
    {
"FBI"}
}; 
PHP код:
#define CIVILIANS 0
#define COPS 1
#define CIA 2
#define MEDICS 3
#define ARMY 4
#define FBI 5 
Reply
#10

It's only reading 0. I mean, only #define CIVILIANS 0 .

When i m a cop so it doesn't show me anything. When i m civilian so it works fine.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)