Undefined Symbol: playerid
#1

pawn Код:
stock SendTeamMessage(color,const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) == 1) if(PlayerTeam[i] == PlayerTeam[playerid]) SendClientMessage(i, color, string);
    }
    return 1;
}
Anybody know how to improve this script? .. thanks..
Reply
#2

Well it's simple, playerid is not defined in that scope. You need to either define it or else change it where ever you are using it.

I'm not sure what you're trying to achieve though, but at a guess, I guess you want to send a message to all players in the same team as playerid? Well then you should add a playerid parameter to the SendTeamMessage stock. Like so:

pawn Код:
stock SendTeamMessage(playerid,color,const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) == 1) if(PlayerTeam[i] == PlayerTeam[playerid]) SendClientMessage(i, color, string);
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Well it's simple, playerid is not defined in that scope. You need to either define it or else change it where ever you are using it.

I'm not sure what you're trying to achieve though, but at a guess, I guess you want to send a message to all players in the same team as playerid? Well then you should add a playerid parameter to the SendTeamMessage stock. Like so:

pawn Код:
stock SendTeamMessage(playerid,color,const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) == 1) if(PlayerTeam[i] == PlayerTeam[playerid]) SendClientMessage(i, color, string);
    }
    return 1;
}
That's what I intend, but how I should use the function? Like..

pawn Код:
SendTeamMessage(?,COLOR_CYAN,team_string);
Reply
#4

Well who do you want to send it to? Do you want to send it to the persons team when he connects?

pawn Код:
SendTeamMessage(playerid,COLOR_CYAN,team_string);
In OnPlayerConnect. I don't really know what you're looking for here.
Reply
#5

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Well who do you want to send it to? Do you want to send it to the persons team when he connects?

pawn Код:
SendTeamMessage(playerid,COLOR_CYAN,team_string);
In OnPlayerConnect. I don't really know what you're looking for here.
Man, Sorry for not specying before.
I'll give you a snippet, you should have a idea in your head.
pawn Код:
if (PlayerTeam[playerid] == TEAM_JAPFLEET)
            {
                new string[128], name[28];
                GetPlayerName(playerid, name, sizeof(name));
                format(string,sizeof(string),"INFO: %s has turned into a spy and now he has the same color and skin of enemies, %s is still a team mate !",name, name);
                SendTeamMessage(COLOR_CYAN,string);
                IsSpy[playerid] = 1;
                SetPlayerColor(playerid,TEAM_AIRFORCEC);
                SetPlayerSkin(playerid,285);
                return 1;
            }
            else
            {
                new string[128], name[28];
                GetPlayerName(playerid, name, sizeof(name));
                format(string,sizeof(string),"INFO: %s has turned into a spy and now he has the same color and skin of enemies, %s is still a team mate !",name, name);
                SendTeamMessage(COLOR_CYAN,string);
                IsSpy[playerid] = 1;
                SetPlayerColor(playerid,TEAM_JAPFLEETC);
                SetPlayerSkin(playerid,287);
                return 1;
            }
Now you know what I mean?
Reply
#6

Yeah so just change it to

pawn Код:
SendTeamMessage(playerid,COLOR_CYAN,string);
To send it to the playerid's team.
Reply
#7

Thank you, it indeed worked !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)