PDA

View Full Version : How to enable name tags for a specific playerid?


rangerxxll
19/03/2014, 07:57 AM
I'm creating a dynamic area and I'd like everyone who is within the area to have their name tags shown to the person who created the area. I'm a tad confused on how to do this - Any help would be appreciated.

This is what I have so far:


public OnPlayerEnterDynamicArea(playerid, areaid)
{
for(new i; i != GetMaxPlayers(); i++)
{
if(areaid == OBJECT_PROXIMITY_AREA[i]) //Just ignore this, as it works properly.
{
SCM(playerid,COLOR_RED, "You've stepped on a proximity bomb.");
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, Float:x, Float:y, Float:z);
CreateExplosion(x, y, z, 2, 10.0);
DestroyDynamicObject(OBJECT_PROXIMITY[i]);
DestroyDynamicArea(OBJECT_PROXIMITY_AREA[i]);
}
if(areaid == OBJECT_SENSOR_AREA[i]) //This is the area we are looking at
{
SCM(playerid,COLOR_RED, "You've entered a monitored area.");
SetPlayerMarkerForPlayer( i, i, ( GetPlayerColor( 1 ) | 0x000000FF )); // <---
}
}
return 1;
}

public OnPlayerLeaveDynamicArea(playerid, areaid)
{
foreach(Player, i)
{
ShowPlayerNameTagForPlayer(i, i, 0);
}
SCM(playerid,COLOR_GREEN, "You've exited a monitored area.");
}


//This is when a player creates the actual area.
if(dialogid == INVENTORY_MOTIONSENSOR) //
{
if(!response) return ShowPlayerDialog(playerid,INVENTORY_MAIN,DIALOG_ST YLE_LIST, "Inventory", invstring, "Select", "Cancel");
if(motionsensor[playerid] == 0) return SCM(playerid,COLOR_GREY, "Error: You don't have any motion sensors");
if(listitem == 0) //lay sensor
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, Float:x, Float:y, Float:z);
OBJECT_SENSOR[playerid] = CreateObject(16782, x, y, z-0.8, 0.00000, -90.00000, 0.00000);
OBJECT_SENSOR_AREA[playerid] = CreateDynamicCircle(x, y, 15.0, -1, -1, -1);
TogglePlayerDynamicArea(playerid, OBJECT_SENSOR_AREA[playerid], 1);
SCM(playerid,COLOR_GREEN, "You've activated your motion sensor. Anyone near it will show on your radar.");
motionsensor[playerid] --;
}
}

MP2
19/03/2014, 09:58 AM
SetPlayerMarkerForPlayer only affects the player's radar blip - not their nametag. Use ShowPlayerNameTagForPlayer.

rangerxxll
19/03/2014, 06:58 PM
I meant radar blip, sorry.

Aerotactics
19/03/2014, 09:13 PM
I meant radar blip, sorry.

This is what I was going to suggest, thanks for clarification.

Raisingz
19/03/2014, 09:24 PM
Have you set the player's color before? Important Note: GetPlayerColor will return nothing unless SetPlayerColor has been used!

rangerxxll
19/03/2014, 09:29 PM
Have you set the player's color before? Important Note: GetPlayerColor will return nothing unless SetPlayerColor has been used! It's used in a admin filterscript my team has developed. Could I add it under OnPlayerEnterDynamicArea?

Raisingz
19/03/2014, 09:41 PM
Why not OnPlayerConnect? You could just set his color for White in the beggining, doesn't hurt I guess.

rangerxxll
19/03/2014, 10:03 PM
I've added it under onplayer connect, then attempted to show their blip when they enter the area. Nothing happens as usual. Any other fix...?

Raisingz
19/03/2014, 10:08 PM
Wait, wtf you're doing SetPlayerMarkerForPlayer( i, i, ( GetPlayerColor( 1 ) | 0x000000FF ));~

when it should be SetPlayerMarkerForPlayer( playerid, i, ( GetPlayerColor( 1 ) | 0x000000FF ));

rangerxxll
19/03/2014, 10:43 PM
Doesn't work either way bud.