Setnametagdrawdistance help
#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


Messages In This Thread
Setnametagdrawdistance help - by Nabster - 20.02.2015, 03:49
Re: Setnametagdrawdistance help - by TunisianoGamer - 20.02.2015, 04:07
Re: Setnametagdrawdistance help - by Nabster - 20.02.2015, 04:16
Re: Setnametagdrawdistance help - by CalvinC - 20.02.2015, 07:19
Re: Setnametagdrawdistance help - by Nabster - 20.02.2015, 09:32
Re: Setnametagdrawdistance help - by CalvinC - 20.02.2015, 09:52
Re: Setnametagdrawdistance help - by Nabster - 20.02.2015, 10:05
Re: Setnametagdrawdistance help - by CalvinC - 20.02.2015, 10:32
Re: Setnametagdrawdistance help - by Nabster - 21.02.2015, 02:02
Re: Setnametagdrawdistance help - by Nabster - 22.02.2015, 04:03

Forum Jump:


Users browsing this thread: 2 Guest(s)