Name off
#1

Hello there!
I'm using this command for name off but tags dissapeard only for one second:
pawn Код:
if (strcmp(cmd, "/nameoff", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {

            if(PlayerInfo[playerid][pLevel] < 5)
        {
            SendClientMessage(playerid, COLOR_GRAD1, " You are not able to use it.");
            return 1;
        }
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
            if(IsPlayerConnected(i))
            {
                nameofftimer = ShowPlayerNameTagForPlayer(i, playerid, 0);
               
                }
            }
            PlayerInfo[playerid][pTags] = 1;
            SendClientMessage(playerid, COLOR_WHITE, "[TAGS] Your tags has been disabled");

        }
        return 1;
    }

    if(strcmp(cmd, "/nameon", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {

        if(PlayerInfo[playerid][pLevel] < 5)
        {
            SendClientMessage(playerid, COLOR_GRAD1, "You are not able to use it.");
            return 1;
        }
        for(new i = 0; i < MAX_PLAYERS; i++)
            {
            if(IsPlayerConnected(i))
            {
                    ShowPlayerNameTagForPlayer(i, playerid, 1);
                }
            }
            PlayerInfo[playerid][pTags] = 0;
            SendClientMessage(playerid, COLOR_WHITE, "[TAGS] Your tags has been enabled.");

        }
        return 1;
    }
Whats the problem?
Thanks
Reply
#2

Quote:
Originally Posted by killerx100
Hello there!
I'm using this command for name off but tags dissapeard only for one second:
Код:
if (strcmp(cmd, "/nameoff", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {

	 		if(PlayerInfo[playerid][pLevel] < 15)
	  	{
	   		SendClientMessage(playerid, COLOR_GRAD1, "You cannot use that command yet.");
	    	return 1;
	  	}
			for(new i = 0; i < MAX_PLAYERS; i++)
 			{
 		  	if(IsPlayerConnected(i))
 		  	{
		 		nameofftimer = ShowPlayerNameTagForPlayer(i, playerid, 0);
		 		
				}
			}
			PlayerInfo[playerid][pTags] = 1;
			SendClientMessage(playerid, COLOR_WHITE, "[TAGS] Your tags has been disabled");

		}
		return 1;
	}

	if(strcmp(cmd, "/nameon", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {

	  	if(PlayerInfo[playerid][pLevel] < 5)
	  	{
	    	SendClientMessage(playerid, COLOR_GRAD1, "You cannot use that command yet."");
	    	return 1;
	  	}
	  	for(new i = 0; i < MAX_PLAYERS; i++)
 			{
 		  	if(IsPlayerConnected(i))
 		  	{
		 			ShowPlayerNameTagForPlayer(i, playerid, 1);
				}
			}
			PlayerInfo[playerid][pTags] = 0;
			SendClientMessage(playerid, COLOR_WHITE, "[TAGS] Your tags has been enabled.");

		}
		return 1;
	}
Whats the problem?
Thanks
Reply
#3

try changing this
pawn Код:
nameofftimer = ShowPlayerNameTagForPlayer(i, playerid, 0);
to this
pawn Код:
ShowPlayerNameTagForPlayer(i, playerid, 0);
Reply
#4

Quote:
Originally Posted by lrZ^ aka LarzI
try changing this
pawn Код:
nameofftimer = ShowPlayerNameTagForPlayer(i, playerid, 0);
to this
pawn Код:
ShowPlayerNameTagForPlayer(i, playerid, 0);
My fault this timer i added to try something its same if i delete it.. Name tags dissapeard for second then come back.
Reply
#5

Now I made like that
pawn Код:
public NameOff(playerid)
{
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
            if(IsPlayerConnected(i))
            {
                ShowPlayerNameTagForPlayer(i, playerid, 0);

                }
            }
            return 1;
  }
public NameOn(playerid)
{
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
            if(IsPlayerConnected(i))
            {
                ShowPlayerNameTagForPlayer(i, playerid, 1);

                }
            }
            return 1;
  }
pawn Код:
if (strcmp(cmd, "/nameoff", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {

            if(PlayerInfo[playerid][pLevel] < 5)
        {
                SendClientMessage(playerid, COLOR_GRAD1, " You are not able to use it.");
            return 1;
        }
            NameOff(playerid);
            PlayerInfo[playerid][pTags] = 1;
            SendClientMessage(playerid, COLOR_WHITE, "[TAGS] Your tags has been disabled");

        }
        return 1;
    }

    if(strcmp(cmd, "/nameon", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {

        if(PlayerInfo[playerid][pLevel] < 5)
        {
            SendClientMessage(playerid, COLOR_GRAD1, "You are not able to use it.");
            return 1;
        }
            NameOn(playerid);
            PlayerInfo[playerid][pTags] = 0;
            SendClientMessage(playerid, COLOR_WHITE, "[TAGS] Your tags has been enabled.");

        }
        return 1;
    }
pawn Код:
SetTimer("NameOff",999999, 1);
Still won't dissapeard
Reply
#6

I have the same problem, please help me!!!!! Thx
Reply
#7

SetTimer("NameOff",999999, 1);
=
Set a timer with the name "NameOff" which executes after 999999 milliseconds, then it'll repeat

SetTimer("NameOff",999999, 0);
=
Set a timer with the name "NameOff" which executes after 999999 milliseconds, then it does nothing
Reply
#8

Why are you guys using 999999 milliseconds? Shouldnt you use something that updates a little more?

Here is how you do it.


At the top of your script.
pawn Код:
new NameDisplay[MAX_PLAYERS];
new maxplayer;
new timer;
forward Timer();
forward NameOn(playerid);
forward NameOff(playerid);
OnGameModeInit
pawn Код:
timer = SetTimer("Timer", 10000, true);
  maxplayer = GetMaxPlayers();
OnPlayerConnect.
pawn Код:
NameDisplay[playerid] = 1;
  NameAlreadyOn = 0;
  NameAlreadyOff = 0;
Add the callbacks.
pawn Код:
public Timer()
{
  for(new i=0; i<=maxplayer; i++)
  {
    if(NameDisplay[i] == 0 && NameAlreadyOff[i] == 0)
    {
      NameOff(i);
    }
    if(NameDisplay[i] == 1 && NameAlreadyOn[i] == 0;)
    {
      NameOn(i);
  }
  return 1;
}

public NameOff(playerid)
{
  for(new i=0; i<=maxplayer; i++)
  {
    ShowPlayerNameTagForPlayer(i, playerid, 0);
    NameAlreadyOff[playerid] = 1;
    NameAlreadyOn[playerid] = 0;
  }
  return 1;
}

public NameOn(playerid)
{
  for(new i=0; i<=maxplayer; i++)
  {
    ShowPlayerNameTagForPlayer(i, playerid, 1);
    NameAlreadyOff[playerid] = 0;
    NameAlreadyOn[playerid] = 1;
  }
  return 1;
}
In OnPlayerCommandText
pawn Код:
if(strcmp(cmdtext, "/name", true) == 0)
  {
    if(NameDisplay[playerid] == 0)
    {
      NameDisplay[playerid] = 1;
      SendClientMessage(playerid, 0xffffffff, " >> Name Displaying turned on.");
      return 1;
    }
    if(NameDisplay[playerid] == 1)
    {
      NameDisplay[playerid] = 0;
      SendClientMessage(playerid, 0xffffffff, " >> Name Displaying turned off.");
      return 1;
    }
    return 1;
  }

Reply
#9

He posted with 999999 so I didn't change it, maybe because that's what he wants ?
Reply
#10

Kinetic I can't compile your name off ..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)