20.02.2015, 10:32
Oh yeah sorry, i got dragged too much into it and ended up re-creating the normal global SetNameTagDrawDistance...
Ignore what i created there.
Here's an example how you could put it in a zcmd command:
And then in the timer:
That, unlike the other one i created, should work perfectly fine, although i haven't tested it, as i can't test it alone.
Ignore what i created there.
Here's an example how you could put it in a zcmd command:
pawn Код:
new NameTagLowered[MAX_PLAYERS], NameTagTimer[MAX_PLAYERS];
// Creates 2 variables which we will need
pawn Код:
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;
}
pawn Код:
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;
}