Setnametagdrawdistance help
#1

Is it possible to set setnametagdistance for a particular player?
Reply
#2

Could you precise more.
Reply
#3

What i want to say is that i want to make namtags drawdistance such that only player using a command can see players from far away,for example

Player A uses command /superid now he can see all players nametag from far away,only he
Reply
#4

There's not a function in SAMP for that, only the global one.
You could however create a timer that checks if a player is close enough to another player, and then use ShowPlayerNameTagForPlayer.
Reply
#5

can you explain a bit more,little hard for me to understand as i am new
Reply
#6

Under OnGameModeInit, you could use SetTimer to create a repeating timer of 1-sec or something.
pawn Код:
SetTimer("NameTagCheck", 1000, true);
Then create the public function, which we're gonna call each second with the timer, and forward it above:
pawn Код:
forward NameTagCheck();
public NameTagCheck()
{
    // Code
}
Then loop through all players in that public function, and check if they're close enough to another player, if they are, ShowPlayerNameTagForPlayer.
And if not, hide it.

Im not 100% sure how you could do the last bit though, my thought is something like this:
pawn Код:
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);
    }
}
You can try it if you want, but i don't think it'll work properly.
Reply
#7

So if do this then i would be able to see their nametag or id from far away when i use /superid?

i am confused because idk how shownametagplayerforplayer will increase drawdistance
Reply
#8

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:
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;
}
And then in the timer:

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;
}
That, unlike the other one i created, should work perfectly fine, although i haven't tested it, as i can't test it alone.
Reply
#9

ah dude,you still didn't understand what i want

Have you seen nametag.cs which increases draw distance of players when activated,i want that,i just want to know how can we script something like that since there is no function to increase drawdistance for a singe player..
Reply
#10

bump
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)