My teamchat fails
#1

Hai there!

I'm wondering if somebody could help me with this. I want a teamchat and I tried creating one, but it epicly failed.



As you can see in the pic it shouldn't be like that. I want it to be ! <text>. (And you can't see you typed ! <text). And if possible something like (TEAM) <Name>: <Histext>.

This is what I have now already:

Код:
public OnPlayerText(playerid, text[])
{
	new string[256];
  if(text[0] == '!')
  {
    for(new i = 0; i <= MAX_PLAYERS; i++ )
    {
      if(gTeam[playerid] == gTeam[i])
      format(string, sizeof(string), "(Team) %s", text[1]);
      SendPlayerMessageToPlayer(i, playerid, string);
    }
    return 0; 
  }

  return 1; 
}
Thanks in advantage!

Bye
Reply
#2

pawn Код:
public OnPlayerText(playerid, text[])
{
  new string[256];
  new playername[MAX_PLAYER_NAME];
  if(text[0] == '!' && text[1] != 0)
  {
    GetPlayerName( playerid, playerame, MAX_PLAYER_NAME );
    format( string, 128, "(Team) %s: %s", playername, text[1] );
    for(new i = 0; i < MAX_PLAYERS; i++ )
    {
      if( IsPlayerConnected(i) && gTeam[playerid] == gTeam[i] )
        SendClientMessage( i, COLOR/*change me*/, string );
    }
    return 0;
  }

  return 1;
}
Reply
#3

Thanks mate! it worked perfectly.

Код:
public OnPlayerStateChange(playerid, newstate, oldstate) // This function checks if the state of a player is changing.
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new numero = GetPlayerVehicleID(playerid);
        if(numero == BallasVeh)
        {
            if(gTeam[playerid] == TEAM_BALLA)
            {
                SendClientMessage(playerid,0xFF0000AA, "You can't steal your own gang car!");
                RemovePlayerFromVehicle(playerid);
            }
            else if(gTeam[playerid] == TEAM_GROVE)
            {
            		new grovename[MAX_PLAYER_NAME];
             		new string[256];
             		new str[256];
             		GetPlayerName(playerid, grovename, sizeof(grovename));
                SetPlayerCheckpoint(playerid, 2412.2483,-1854.1670,1.1559, 6.5);
                SendClientMessage(playerid, 0x33AA33AA, "You have stolen Ballas' gang vehicle! Get it to the checkpoint!");
       					if (gTeam[playerid] == TEAM_GROVE)
    							{
    							format(string, sizeof(string), "(TEAM) *** Your teammate ( %s ) is stealing Ballas' gang vehicle! Go help him! ***", grovename);
      							SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
									}
     						if (gTeam[playerid] == TEAM_BALLA)
									{
 									format(str, sizeof(str), "(TEAM) *** %s is stealing your gang vehicle! Stop him before he enters the checkpoint! ***", grovename);
      							SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
									}
            }
        }
        else if(numero == GroveVeh)
        {
            if(gTeam[playerid] == TEAM_GROVE)
            {
                SendClientMessage(playerid,0xFF0000AA, "You can't steal your own gang car!");
                RemovePlayerFromVehicle(playerid);
            }
            else if(gTeam[playerid] == TEAM_BALLA)
            {
                new ballasname[MAX_PLAYER_NAME];
                new string[256];
                new str[256];
                GetPlayerName(playerid, ballasname, sizeof(ballasname));
                SendClientMessage(playerid, 0x33AA33AA, "You have stolen the Grove's gang vehicle! Get it to the checkpoint!");
    						SetPlayerCheckpoint(playerid, 2412.2483,-1854.1670,1.1559, 6.5);
                if (gTeam[playerid] == TEAM_BALLA)
									{
    							format(string, sizeof(string), "(TEAM) *** Your teammate ( %s ) is stealing Grove's gang vehicle! Go help him! ***", ballasname);
      							SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
									}
     						if (gTeam[playerid] == TEAM_GROVE)
									{
 									format(str, sizeof(str), "(TEAM) *** %s is stealing your gang vehicle! Stop him before he enters the checkpoint! ***", ballasname);
      							SendClientMessage(playerid, COLOR_LIGHTBLUE, str);
									}
            }
        }
    }
    else if(newstate == PLAYER_STATE_ONFOOT)
    {
      DisablePlayerCheckpoint(playerid);
      SetVehicleParamsForPlayer(GroveVeh,playerid,0,0);
    	SetVehicleParamsForPlayer(BallasVeh,playerid,0,0);
    }
    return 1;
}
One more questoin, in this script the gang message is only sent to the playerid in the car. How can i make it sent the message to everybody?
Reply
#4

for(new i = 0; i < MAX_PLAYERS; i++)
{
if(GetPlayerVehicleID(i) == numero)
{
SendClientMessage(i,color,"blahblahblah");
}
}
Reply
#5

Код:
public OnPlayerStateChange(playerid, newstate, oldstate) // This function checks if the state of a player is changing.
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new numero = GetPlayerVehicleID(playerid);
        if(numero == BallasVeh)
        {
            if(gTeam[playerid] == TEAM_BALLA)
            {
                SendClientMessage(playerid,0xFF0000AA, "You can't steal your own gang car!");
                RemovePlayerFromVehicle(playerid);
            }
            else if(gTeam[playerid] == TEAM_GROVE)
            {
            		new grovename[MAX_PLAYER_NAME];
             		new string[256];
             		new str[256];
            			for(new i = 0; i < MAX_PLAYERS; i++)
             		GetPlayerName(playerid, grovename, sizeof(grovename));
                SetPlayerCheckpoint(playerid, 2412.2483,-1854.1670,1.1559, 6.5);
                SendClientMessage(playerid, 0x33AA33AA, "You have stolen Ballas' gang vehicle! Get it to the checkpoint!");
       					if (gTeam[playerid] == TEAM_GROVE)
    							{
    							format(string, sizeof(string), "(TEAM) *** Your teammate ( %s ) is stealing Ballas' gang vehicle! Go help him! ***", grovename);
      							SendClientMessage(i, COLOR_LIGHTBLUE, string);
									}
     						if (gTeam[playerid] == TEAM_BALLA)
									{
 									format(str, sizeof(str), "(TEAM) *** %s is stealing your gang vehicle! Stop him before he enters the checkpoint! ***", grovename);
      							SendClientMessage(i, COLOR_LIGHTBLUE, str);
									}
            }
        }
        else if(numero == GroveVeh)
        {
            if(gTeam[playerid] == TEAM_GROVE)
            {
                SendClientMessage(playerid,0xFF0000AA, "You can't steal your own gang car!");
                RemovePlayerFromVehicle(playerid);
            }
            else if(gTeam[playerid] == TEAM_BALLA)
            {
                new ballasname[MAX_PLAYER_NAME];
                new string[256];
                new str[256];
                	for(new i = 0; i < MAX_PLAYERS; i++)
                GetPlayerName(playerid, ballasname, sizeof(ballasname));
                SendClientMessage(playerid, 0x33AA33AA, "You have stolen the Grove's gang vehicle! Get it to the checkpoint!");
    						SetPlayerCheckpoint(playerid, 2412.2483,-1854.1670,1.1559, 6.5);
                if (gTeam[playerid] == TEAM_BALLA)
									{
    							format(string, sizeof(string), "(TEAM) *** Your teammate ( %s ) is stealing Grove's gang vehicle! Go help him! ***", ballasname);
      							SendClientMessage(i, COLOR_LIGHTBLUE, string);
									}
     						if (gTeam[playerid] == TEAM_GROVE)
									{
 									format(str, sizeof(str), "(TEAM) *** %s is stealing your gang vehicle! Stop him before he enters the checkpoint! ***", ballasname);
      							SendClientMessage(i, COLOR_LIGHTBLUE, str);
									}
            }
        }
    }
    else if(newstate == PLAYER_STATE_ONFOOT)
    {
      DisablePlayerCheckpoint(playerid);
      SetVehicleParamsForPlayer(GroveVeh,playerid,0,0);
    	SetVehicleParamsForPlayer(BallasVeh,playerid,0,0);
    }
    return 1;
}
Using that I get these errors:

Код:
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(669) : error 017: undefined symbol "i"
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(674) : error 017: undefined symbol "i"
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(697) : error 017: undefined symbol "i"
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(702) : error 017: undefined symbol "i"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#6

public OnPlayerText(playerid, text[])
{
new string[256];
if(text[0] == '!')
{
for(new i = 0; i <= MAX_PLAYERS; i++ )
{
if(gTeam[playerid] == gTeam[i])
format(string, sizeof(string), "(Team) %s", text[1]);
SendPlayerMessageToPlayer(i, playerid, string);
}
return 0;
}

return 0;
}
Reply
#7

Euhm, that even gave more errors.

And does that have anything to do with the 'i' errors?
Reply
#8

Quote:
Originally Posted by IntrozeN
public OnPlayerText(playerid, text[])
{
new string[256];
if(text[0] == '!')
{
for(new i = 0; i <= MAX_PLAYERS; i++ )
{
if(gTeam[playerid] == gTeam[i])
format(string, sizeof(string), "(Team) %s", text[1]);
SendPlayerMessageToPlayer(i, playerid, string);
}
return 0;
}

return 0;
}
Did you even read the other posts? He already fixed that problem. And this code will make it to where you can't ever talk unless it's team chat.
Reply
#9

Anyone?
Reply
#10

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate) // This function checks if the state of a player is changing.
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new numero = GetPlayerVehicleID(playerid);
        if(numero == BallasVeh)
        {
            if(gTeam[playerid] == TEAM_BALLA)
            {
                SendClientMessage(playerid,0xFF0000AA, "You can't steal your own gang car!");
                RemovePlayerFromVehicle(playerid);
            }
            else if(gTeam[playerid] == TEAM_GROVE)
            {
                new grovename[MAX_PLAYER_NAME];
                new string[256];
                new str[256];
                GetPlayerName(playerid, grovename, sizeof(grovename));
                SetPlayerCheckpoint(playerid, 2412.2483,-1854.1670,1.1559, 6.5);
                SendClientMessage(playerid, 0x33AA33AA, "You have stolen Ballas' gang vehicle! Get it to the checkpoint!");
                format(string, sizeof(string), "(TEAM) *** Your teammate ( %s ) is stealing Ballas' gang vehicle! Go help him! ***", grovename);
                format(str, sizeof(str), "(TEAM) *** %s is stealing your gang vehicle! Stop him before he enters the checkpoint! ***", grovename);
                for(new i = 0; i < MAX_PLAYERS; i++){
                    if (gTeam[i] == TEAM_GROVE)
                        SendClientMessage(i, COLOR_LIGHTBLUE, string);
                    else if (gTeam[i] == TEAM_BALLA)
                        SendClientMessage(i, COLOR_LIGHTBLUE, str);
                }
            }
        }
        else if(numero == GroveVeh)
        {
            if(gTeam[playerid] == TEAM_GROVE)
            {
                SendClientMessage(playerid,0xFF0000AA, "You can't steal your own gang car!");
                RemovePlayerFromVehicle(playerid);
            }
            else if(gTeam[playerid] == TEAM_BALLA)
            {
                new ballasname[MAX_PLAYER_NAME];
                new string[256];
                new str[256];
                GetPlayerName(playerid, ballasname, sizeof(ballasname));
                SendClientMessage(playerid, 0x33AA33AA, "You have stolen the Grove's gang vehicle! Get it to the checkpoint!");
                SetPlayerCheckpoint(playerid, 2412.2483,-1854.1670,1.1559, 6.5);
                format(string, sizeof(string), "(TEAM) *** Your teammate ( %s ) is stealing Grove's gang vehicle! Go help him! ***", ballasname);
                format(str, sizeof(str), "(TEAM) *** %s is stealing your gang vehicle! Stop him before he enters the checkpoint! ***", ballasname);
                for(new i = 0; i < MAX_PLAYERS; i++){
                    if (gTeam[i] == TEAM_BALLA)
                        SendClientMessage(i, COLOR_LIGHTBLUE, string);
                    else if (gTeam[i] == TEAM_GROVE)
                        SendClientMessage(i, COLOR_LIGHTBLUE, str);
                }
            }
        }
    }
    else if(newstate == PLAYER_STATE_ONFOOT)
    {
        DisablePlayerCheckpoint(playerid);
        SetVehicleParamsForPlayer(GroveVeh,playerid,0,0);
        SetVehicleParamsForPlayer(BallasVeh,playerid,0,0);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)