help with team - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: help with team (
/showthread.php?tid=279118)
help with team -
Setkus - 25.08.2011
Hey guys,
Here is the code:
new vardas[128], stringas[128];
GetPlayerName(playerid, vardas, sizeof(vardas));
format(stringas, sizeof(stringas), "%s says I need help!", vardas,);
SendClientMessageToAll(0xE6E6FAFF, stringas);
return 1;
}
And there is two teams. Blue team and Green team. All I want is how to do that stringas says: from (playerteam) Team (playername) says I need help!
I hope you understand me. Thanks for helping!
Re: help with team -
Setkus - 25.08.2011
Someone? Then just please give me an example how can i do it by myself!
Re: help with team -
knackworst - 25.08.2011
I don't get what you want :/ explain better please
Re: help with team -
Dragony92 - 25.08.2011
How you define your teams in your gamemod?
Re: help with team -
Setkus - 25.08.2011
Like this:
#define TEAM_GREEN 1
#define TEAM_BLUE 2
Re: help with team -
Setkus - 25.08.2011
Well? Someone?
Re: help with team -
iggy1 - 25.08.2011
Here is an example using OnPlayerText Callback. Anything after '#' is typed will be sent to that players gang.
pawn Код:
public OnPlayerText(playerid, text[])
{
if(text[0] == '#')
{
new
szStr[128],
szPName[MAX_PLAYER_NAME];
GetPlayerName(playerid, szPName, MAX_PLAYER_NAME);
format(szStr, sizeof(szStr), "|TEAM| (%d)%s: %s", playerid, szPName, text[1]);
for(new i; i < MAX_PLAYERS; i++)//if you use foreach use that, if you don't - then you should start.
if(IsPlayerConnected(i))
if(gTeam[playerid] == gTeam[i])//swap "gTeam" for the var you use to store the players gang/team.
SendClientMessage(playerid, 0x00FF00AA, szStr);
return 0;
}
return 1;
}
EDIT: I forgot to return zero, that's fixed now.
Re: help with team -
Setkus - 25.08.2011
What's wrong? Please, help:
new vardas[128], komanda[128], stringas[128];
GetPlayerName(playerid, vardas, sizeof(vardas));
GetPlayerTeam(playerid, komanda, sizeof(komanda));
if(GetPlayerTeam == 1) komanda = "Green";
if(GetPlayerTeam == 2) komanda = "Blue";
format(stringas, sizeof(stringas), "From %s Team %s says I need help!", komanda, vardas);
SendClientMessageToAll(0xE6E6FAFF, stringas);
return 1;
}
The error:
D:\GTA SA\USA vs MEC\gamemodes\map4.pwn(522) : warning 202: number of arguments does not match definition
D:\GTA SA\USA vs MEC\gamemodes\map4.pwn(522) : warning 202: number of arguments does not match definition
D:\GTA SA\USA vs MEC\gamemodes\map4.pwn(523) : error 076: syntax error in the expression, or invalid function call
D:\GTA SA\USA vs MEC\gamemodes\map4.pwn(524) : error 076: syntax error in the expression, or invalid function call
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
Re: help with team -
knackworst - 25.08.2011
where are your { and } brackets?
EDIT:
what about this?
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/help", cmdtext, true, 10) == 0)
{
new vardas[128], komanda[128], stringas[128];
GetPlayerName(playerid, vardas, sizeof(vardas));
GetPlayerTeam(playerid, komanda, sizeof(komanda));
format(stringas, sizeof(stringas), "From %s Team %s says I need help!", komanda, vardas);
SendClientMessageToAll(0xE6E6FAFF, stringas);
return 1;
}
return 0;
}
if someone types /help everyone gets the following message: "From %s Team %s says I need help!"
I think it should work, but I didn't test it...
Re: help with team -
iggy1 - 25.08.2011
Quote:
Originally Posted by knackworst
where are your { and } brackets?
|
You can omit the braces when a single statement follows an expression.