GTAOnline.net

San Andreas Multiplayer (sa:mp) => Scripting SA-MP [Pawn center] => Discussion démarrée par: Jcvag44800 le 22 Décembre 2010, 23:51:04

Titre: Beug radio entre 2 factions
Posté par: Jcvag44800 le 22 Décembre 2010, 23:51:04
Bonjour,

Je viens de crée une radio pour que 2 factions puissent se parler entre elles.
J'ai donc fait ceci
if(strcmp(cmd, "/ryb", true) == 0 || strcmp(cmd, "/ryb", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/ryb) texte");
return 1;
}
else if(PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pMember] == 16 || PlayerInfo[playerid][pLeader] == 16 || PlayerInfo[playerid][pLeader] == 8) // L'ID faction 8 & 16 : Les chefs et les membres reçoivent et parler dans la radio
{
if(PlayerInfo[playerid][pRank] == 6) { format(string, sizeof(string), "**%s(radio): %s **", sendername, result); }
else if(PlayerInfo[playerid][pRank] == 5) { format(string, sizeof(string), "**%s : %s **", sendername, result); }
else if(PlayerInfo[playerid][pRank] == 4) { format(string, sizeof(string), "**%s(radio): %s **", sendername, result); }
else if(PlayerInfo[playerid][pRank] == 3) { format(string, sizeof(string), "**%s(radio): %s **", sendername, result); }
else if(PlayerInfo[playerid][pRank] == 2) { format(string, sizeof(string), "**%s(radio): %s **", sendername, result); }
else if(PlayerInfo[playerid][pRank] == 1) { format(string, sizeof(string), "**%s(radio): %s **", sendername, result); }
else
{
format(string, sizeof(string), "**%s(radio): %s, terminé. **", sendername, result);
}
ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
SendRadioMessage(16, TEAM_RADIO_COLOR, string);
printf("%s", string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, " Tu n'est pas un membre Yakuza ou BaySide Street");
return 1;
}
}
return 1;
}

La commande marche bien MAIS , si par exemple je fait : /ryg blabla , l'autre faction ne reçois pas le méssage OR eux s'ils écrivent un méssage genre blabla2 je le reçoi .......
Je ne vois pas vraiment où serais mon érreurs  :-\

Aidez moi s'il vous plait ^^
Titre: Re : Beug radio entre 2 factions
Posté par: Leonidas300 le 23 Décembre 2010, 00:08:05
Code: (pawn) [Sélectionner]
SendRadioMessage(16, TEAM_RADIO_COLOR, string);
tu envoie le message seulement à la faction 16 lol, c'est normale, envoie le message à l'id de l'autre faction aussi ;)
Titre: Re : Beug radio entre 2 factions
Posté par: Jcvag44800 le 23 Décembre 2010, 00:14:17
AH oui , comme ceci sa pourrais aller ?
SendRadioMessage(16, TEAM_RADIO_COLOR, string);
SendRadioMessage(8, TEAM_RADIO_COLOR, string);
Titre: Re : Beug radio entre 2 factions
Posté par: Leonidas300 le 23 Décembre 2010, 00:22:12
nan, se que tu peux faire c'est sa:

en haut;
Code: (pawn) [Sélectionner]
forward Envoyeraudeuxfactions(member, color, string[]);
Code: (pawn) [Sélectionner]
public Envoyeraudeuxfactions(member, color, string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
   if(PlayerInfo[i][pMember] == 8|| PlayerInfo[i][pLeader] == 8|| PlayerInfo[i][pMember] == 16|| PlayerInfo[i][pLeader] == 16)// on vérifie qu'il sont bien dans la faction ID...
   {
SendClientMessage(i, color, string);//on envoie le msg au deux factions
}
}
}
}

et donc tu fait:

Code: (pawn) [Sélectionner]
ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
Envoyeraudeuxfactions(playerid, TEAM_RADIO_COLOR, string);
printf("%s", string);
return 1;

Voila, amicalement
Titre: Re : Beug radio entre 2 factions
Posté par: Pixect le 23 Décembre 2010, 00:28:57
Salut,

Tant de lignes pour représenter seulement 2 lignes comme l'a montré Jcvag, donc, je pense que ta méthode est bonne Jcvag.

++
Lloyd
Titre: Re : Beug radio entre 2 factions
Posté par: Jcvag44800 le 23 Décembre 2010, 00:38:07
J'ai fait ma méthode et elle marche ^^

Merci comme même Leonidas  :snip
Tu m'aide toujours en me donnant des codes, c'est simpas  ::)
Titre: Re : Beug radio entre 2 factions
Posté par: Leonidas300 le 23 Décembre 2010, 00:38:51
Derien  :cheers