help with team
#1

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!
Reply
#2

Someone? Then just please give me an example how can i do it by myself!
Reply
#3

I don't get what you want :/ explain better please
Reply
#4

How you define your teams in your gamemod?
Reply
#5

Like this:
#define TEAM_GREEN 1
#define TEAM_BLUE 2
Reply
#6

Well? Someone?
Reply
#7

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.
Reply
#8

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.
Reply
#9

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...
Reply
#10

Quote:
Originally Posted by knackworst
Посмотреть сообщение
where are your { and } brackets?
You can omit the braces when a single statement follows an expression.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)