20.02.2015, 03:49
Is it possible to set setnametagdistance for a particular player?
SetTimer("NameTagCheck", 1000, true);
forward NameTagCheck();
public NameTagCheck()
{
// Code
}
foreach(Player, i)
{
foreach(Player, o)
{
new Float:ix, Float:iy, Float:iz;
GetPlayerPos(i, ix, iy, iz);
if(IsPlayerInRangeOfPoint(o, 5, ix, iy, iz) ShowPlayerNameTagForPlayer(o, i, 1);
else ShowPlayerNameTagForPlayer(o, i, 0);
}
}
new NameTagLowered[MAX_PLAYERS], NameTagTimer[MAX_PLAYERS];
// Creates 2 variables which we will need
CMD:lowernametagdistance(playerid, params[])
{
switch(NameTagLowered[playerid])
// Switches through "NameTagLowered", checking what value it is set to
{
case 0:
// If it is set to 0 (AKA the player hasn't enabled the "nametag limit")
{
NameTagLowered[playerid] = 1;
// Sets the "NameTagLowered" variable to 1, indicating that the function is enabled
NameTagTimer[playerid] = SetTimer("NameTagCheck", 1000, true);
// Starts the "NameTagCheck"-timer, which will only display the nametag to players close enough
SendClientMessage(playerid, -1, "Your nametag is now only shown to players close enough.");
// Sends a message to the player, letting him know he's limited his nametag
}
case 1:
// If it is set to 1 (AKA the player has enabled the "nametag limit")
{
NameTagLowered[playerid] = 0;
// Sets the "NameTagLowered" variable to 0, indicating that the function isn't enabled
KillTimer(NameTagTimer[playerid])
// Stops the "NameTagTimer[playerid]" timer, that we defined above, making the nametag of the player visible to everyone again
foreach(Player, i) ShowPlayerNameTagForPlayer(playerid, i, 1);
// Loops through all players, and shows the name tag globally again
SendClientMessage(playerid, -1, "Your nametag is now shown normally again.");
// Sends a message to the player, letting him know he's disabled the limit on his nametag
}
}
return 1;
}
forward NameTagCheck(playerid);
// Forwards the public function "NameTagCheck", you have to forward public functions
public NameTagCheck(playerid)
{
new Float:x, Float:y, Float:z;
// Creates 3 floats, "x", "y", and "z"
GetPlayerPos(playerid, x, y, z);
// Stores the player's coordinates in the 3 floats we created
foreach(Player, i)
// Loops through all players, and defines them as "i"
{
if(IsPlayerInRangeOfPoint(i, 5, x, y, z) ShowPlayerNameTagForPlayer(i, playerid, 1);
// Checks if "i" is in range of the player by 5 GTA SA units, if so, it shows the nametag
else ShowPlayerNameTagForPlayer(i, playerid, 0);
// Otherwise it hides the nametag
}
return 1;
}