Team Chat help[rep] -
[SU]Spartan - 07.09.2014
hi so i got these teams:
Код:
#define TEAM_TERROR 0
#define TEAM_SWAT 1
#define TEAM_ARMY 2
#define TEAM_CIA 4
#define TEAM_FBI 5
I want the symbol ! to be team chat.
When a player types ! a
this sentence will be sent only to player's team.
Re: Team Chat help[rep] -
Fred1993 - 07.09.2014
You can make a command like /t [message]
/t means Teamchat
Re: Team Chat help[rep] -
[SU]Spartan - 07.09.2014
I need help with the system.
Re: Team Chat help[rep] -
iFarbod - 07.09.2014
It's very easy.
pawn Код:
#include <a_samp>
#include <YSI\y_va>
public OnPlayerText(playerid, text[])
{
if(msg[0] = '!')
{
for (new i = 0; i != MAX_PLAYERS; ++i)
{
if(IsPlayerConnected(i) && (gTeam[i] == gTeam[playerid])
Msg(playerid, 0xC8C8C8FF, "[Team Msg] %s: %s", PlayerNameEx(playerid), msg[1]);
}
return 0;
}
return 1;
}
stock PlayerNameEx(playerid)
{
new
playerName[MAX_PLAYER_NAME+1],
string[MAX_PLAYER_NAME+1+7];
GetPlayerName(playerid, playerName, sizeof(playerName));
format(string, sizeof(string), "%s (%d)", playerName, playerid);
return string;
}
stock Msg(playerid, color, const fmat[], va_args<>)
{
return SendClientMessage(playerid, color, va_return(fmat, va_start<3>));
}
Hope i helped.
If a player types "!hello" it will be sent to their team in this format: "[Team Chat] Name (ID): hello"
Re: Team Chat help[rep] -
[SU]Spartan - 07.09.2014
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(172) : error 025: function heading differs from prototype
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(174) : warning 211: possibly unintended assignment
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(179) : error 001: expected token: ")", but found "-identifier-"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
Re: Team Chat help[rep] -
iFarbod - 07.09.2014
Oh, my bad.
change
pawn Код:
public OnPlayerText(playerid, msg[])
to
pawn Код:
public OnPlayerText(playerid, text[])
Re: Team Chat help[rep] -
[SU]Spartan - 07.09.2014
now i got more errors:
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(174) : error 017: undefined symbol "msg"
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(174) : warning 215: expression has no effect
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(174) : error 001: expected token: ";", but found "]"
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(174) : error 029: invalid expression, assumed zero
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(174) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Re: Team Chat help[rep] -
iFarbod - 07.09.2014
Try this one:
pawn Код:
#include <a_samp>
#include <YSI\y_va>
public OnPlayerText(playerid, text[])
{
if(text[0] = '!' && strlen(text[1]))
{
for (new i = 0; i != MAX_PLAYERS; ++i)
{
if(IsPlayerConnected(i) && (gTeam[i] == gTeam[playerid])
Msg(playerid, 0xC8C8C8FF, "[Team Msg] %s: %s", PlayerNameEx(playerid), text[1]);
}
return 0;
}
return 1;
}
stock PlayerNameEx(playerid)
{
new
playerName[MAX_PLAYER_NAME+1],
string[MAX_PLAYER_NAME+1+7];
GetPlayerName(playerid, playerName, sizeof(playerName));
format(string, sizeof(string), "%s (%d)", playerName, playerid);
return string;
}
stock Msg(playerid, color, const fmat[], va_args<>)
{
return SendClientMessage(playerid, color, va_return(fmat, va_start<3>));
}
Re: Team Chat help[rep] -
[SU]Spartan - 07.09.2014
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(174) : warning 211: possibly unintended assignment
C:\Users\John\Desktop\BlueZ Community Servers Scripts(RP,STUNT & TRUCKING\dm\gamemodes\TDM.pwn(179) : error 001: expected token: ")", but found "-identifier-"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
Re: Team Chat help[rep] -
iFarbod - 07.09.2014
Sorry for that, i wrote this in the SA-MP Editor.
pawn Код:
#include <a_samp>
#include <YSI\y_va>
public OnPlayerText(playerid, text[])
{
if(text[0] == '!' && strlen(text[1]))
{
for (new i = 0; i != MAX_PLAYERS; ++i)
{
if(IsPlayerConnected(i) && (gTeam[i] == gTeam[playerid]))
Msg(playerid, 0xC8C8C8FF, "[Team Msg] %s: %s", PlayerNameEx(playerid), text[1]);
}
return 0;
}
return 1;
}
stock PlayerNameEx(playerid)
{
new
playerName[MAX_PLAYER_NAME+1],
string[MAX_PLAYER_NAME+1+7];
GetPlayerName(playerid, playerName, sizeof(playerName));
format(string, sizeof(string), "%s (%d)", playerName, playerid);
return string;
}
stock Msg(playerid, color, const fmat[], va_args<>)
{
return SendClientMessage(playerid, color, va_return(fmat, va_start<3>));
}