PDA

View Full Version : Help


karoliko
08/05/2016, 05:24 PM
I need a system to my TDM server, i have 2 teams and i use gTeam (My teams are Policias and Terroristas)
I want to each team only can see on the map his team players
Example:
Player of Policias team can only see the other Policias
Please help me with this:(

TheSimpleGuy
08/05/2016, 05:44 PM
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && GetPlayerTeam(i) == GetPlayerTeam(playerid))
{
SetPlayerMarkerForPlayer(playerid, i, 0xFF0000FF); //select color
}
}

Place in any callback which you would like to start.

karoliko
08/05/2016, 05:56 PM
In wich callback? Can you write example please...
Can you edit it to me to gTeam (Team 1: Policias, team 2: Terroristas)
Because i want to each team have one color, Azul (Blue) for Policias and Rojo (Red) for Terroristas.
static gTeam[MAX_PLAYERS];
#define Policias 1
#define Terroristas 2

#define RojoMarcado 0xFF0000FF //Colour for Terroristas
#define AzulMarcado 0x0000FFFF //Colour for Policias

DTV
08/05/2016, 06:09 PM
You could use something like:

OnPlayerSpawn(playerid)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(gTeam[playerid] == 1) //Police team
{
SetPlayerMarkerForPlayer(playerid, i, COLOR_RED);
}
else SetPlayerMarkerForPlayer(playerid, i, COLOR_BLUE);
}
return 1;
}


Note that you'll have to define COLOR_RED and COLOR_BLUE to actually work.

karoliko
08/05/2016, 06:29 PM
And if someone new join the server? This will update showing new players?

karoliko
09/05/2016, 05:22 PM
BUMP

Dayrion
09/05/2016, 06:56 PM
This will not update marker for the player until he spawn again.

karoliko
09/05/2016, 07:39 PM
This will not update marker for the player until he spawn again.
Any mode to do it?

Dayrion
09/05/2016, 08:17 PM
Any mode to do it?

You can try to set a timer and include the function in this timer. Something like that.

karoliko
09/05/2016, 08:22 PM
Can you do the code, i don't know... :3

Dayrion
09/05/2016, 11:10 PM
Try to search by yourself.
You have to create a function with this ;
for(new i=0; i<MAX_PLAYERS; i++)
{
if(gTeam[playerid] == 1) //Police team
{
SetPlayerMarkerForPlayer(playerid, i, COLOR_RED);
}
else SetPlayerMarkerForPlayer(playerid, i, COLOR_BLUE);
}
return 1;
Set a timer with this function (SetTimerEx (https://wiki.sa-mp.com/wiki/SetTimerEx)) every 500 ms.
Try to do it, even it's false try and post the code here. You don't learn something without training. :)

Nin9r
10/05/2016, 09:27 AM
You can use this callback. You don't need any timer to do it.

public OnPlayerStreamIn(playerid, forplayerid)
{
if(gTeam[playerid] == 1 && gTeam[forid] == 1)
{
SetPlayerMarkerForPlayer( playerid, forplayerid, GetPlayerColor( forplayerid ) );
SetPlayerMarkerForPlayer( forplayerid, playerid, GetPlayerColor( playerid ) );
}
return 1;
}

karoliko
10/05/2016, 07:54 PM
You can use this callback. You don't need any timer to do it.

public OnPlayerStreamIn(playerid, forplayerid)
{
if(gTeam[playerid] == 1 && gTeam[forid] == 1)
{
SetPlayerMarkerForPlayer( playerid, forplayerid, GetPlayerColor( forplayerid ) );
SetPlayerMarkerForPlayer( forplayerid, playerid, GetPlayerColor( playerid ) );
}
return 1;
}
Can you edit it for my gTeams Policias and Terroristas please?

#define Policias 1
#define Terroristas 2

PD: Can i edit the distance, i want make it everywhere on the map.

Sew_Sumi
10/05/2016, 08:55 PM
https://wiki.sa-mp.com/wiki/ShowPlayerMarkers to global to see everywhere on map.

Use markers enabled, and simply hide the opposite teams markers on spawn by setting their player marker color to 0x00000000 when they spawn.

When the players connect, they can go through and make every connected players marker for the opposite team to invisible in the same manner.


Everyone is over thinking this, and making it a lot harder than it needs to be.


OnPlayerSpawn(playerid)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(gTeam[playerid] != gTeam[i]&&IsPlayerConnected[i])
{
SetPlayerMarkerForPlayer(i, playerid, 0x00000000);
SetPlayerMarkerForPlayer(playerid, i, 0x00000000);
}
}
return 1;
}


That should work... It is untested, but it should cover people who connect after the start of the match.

You'll just need to SetPlayerColor for everyone to blue or red on joining, depending on which team they are in. The color of their name should stay the same, as setting the marker to 0x00000000 makes it invisible, whilst retaining the player color.