(NAME OFF) to zcmd
#1

Hello, I am trying to do a /name off and /name on command for my server, for example, donators and admins can turn their name off by /name off, and other player aint able to see their names, same as /name on, but I want it to be only for ADMINS / DONATORS.

I have something like this, but I need zcmd, and I think this is not even similiar for donator - admin thingy..
Код:
if (strcmp(cmd, "/name", true) ==0 )
    {
    if (PlayerInfo[playerid][pRank] >= 4)
    {
    tmp = strtok(cmdtext,idx);
    if(!strlen(tmp))
    {
    SendClientMessage(playerid, COLOR_WHITE, "[USAGE] /name off/on ");
    }
    else if(strcmp(tmp,"off",true) == 0)
    {
    for(new i=0;i<MAX_PLAYERS;i++) { ShowPlayerNameTagForPlayer(playerid,i,0); }
    SendClientMessage(playerid,COLOR_WHITE,"Your name tags are hidden.");
    return 1;
    }
    else if(strcmp(tmp,"on",true) == 0)
    {
    for(new i=0;i<MAX_PLAYERS;i++) { ShowPlayerNameTagForPlayer(i,playerid,1); }
    SendClientMessage(playerid,COLOR_WHITE,"Your name tags are viewable.");
    return 1;
    } else {
    SendClientMessage(playerid,COLOR_WHITE,"Your are not a high enough rank.");
    }
    }
    return 1;
    }
Reply
#2

pawn Код:
COMMAND:name(playerid, params[])
{
    if (PlayerInfo[playerid][pRank] >= 4)
    {
        new tmp[128];
        if(sscanf(params, "s", tmp)) return SendClientMessage(playerid, COLOR_WHITE, "[USAGE] /name off/on ");
        if(strcmp(tmp,"off",true) == 0)
        {
            for(new i=0;i<MAX_PLAYERS;i++)
            {
                ShowPlayerNameTagForPlayer(playerid,i,0)
                SendClientMessage(playerid,COLOR_WHITE,"Your name tags are hidden.");
                return 1;
            }
        }
        else if(strcmp(tmp,"on",true) == 0)
        {
            for(new i=0;i<MAX_PLAYERS;i++)
            {
                ShowPlayerNameTagForPlayer(i,playerid,1);
                SendClientMessage(playerid,COLOR_WHITE,"Your name tags are viewable.");
                return 1;
            }
        }
        else
        {
            SendClientMessage(playerid,COLOR_WHITE,"Your are not a high enough rank.");
        }
    }
    return 1;
}
Reply
#3

nvm.
Reply
#4

And:

Код:
C:\Documents and Settings\diingO\Ambiente de trabalho\SM-RPG V.1.0 R1\gamemodes\SM-RPG.pwn(11883) : error 017: undefined symbol "PlayerInfo"
C:\Documents and Settings\diingO\Ambiente de trabalho\SM-RPG V.1.0 R1\gamemodes\SM-RPG.pwn(11883) : warning 215: expression has no effect
C:\Documents and Settings\diingO\Ambiente de trabalho\SM-RPG V.1.0 R1\gamemodes\SM-RPG.pwn(11883) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\diingO\Ambiente de trabalho\SM-RPG V.1.0 R1\gamemodes\SM-RPG.pwn(11883) : error 029: invalid expression, assumed zero
C:\Documents and Settings\diingO\Ambiente de trabalho\SM-RPG V.1.0 R1\gamemodes\SM-RPG.pwn(11883) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Код:
Line 11883:     if (PlayerInfo[playerid][pRank] >= 4)
Fixed it to donator and rank 1.
Now I got this.
Код:
C:\Documents and Settings\diingO\Ambiente de trabalho\SM-RPG V.1.0 R1\gamemodes\SM-RPG.pwn(11892) : error 001: expected token: ";", but found "-identifier-"
C:\Documents and Settings\diingO\Ambiente de trabalho\SM-RPG V.1.0 R1\gamemodes\SM-RPG.pwn(11910) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Код:
11892 : SendClientMessage(playerid, WHITE,"Your name has been turned off");
11910 :     return 1;
Reply
#5

please someone? I need to fix it :3
Reply
#6

Before this line

pawn Код:
SendClientMessage(playerid, WHITE,"Your name has been turned off");
Add an ";" to this line

ShowPlayerNameTagForPlayer(playerid,i,0)

so it will be

ShowPlayerNameTagForPlayer(playerid,i,0);
Reply
#7

pawn Код:
COMMAND:name(playerid, params[])
{
    if (PlayerInfo[playerid][pRank] >= 4)
    {
        new tmp[128];
        if(sscanf(params, "s[128]", tmp)) return SendClientMessage(playerid, COLOR_WHITE, "[USAGE] /name off/on ");
        if(strcmp(tmp,"off",true) == 0)
        {
            for(new i=0;i<MAX_PLAYERS;i++)
            {
                ShowPlayerNameTagForPlayer(playerid,i,0);
                SendClientMessage(playerid,COLOR_WHITE,"Your name tags are hidden.");
                return 1;
            }
        }
        else if(strcmp(tmp,"on",true) == 0)
        {
            for(new i=0;i<MAX_PLAYERS;i++)
            {
                ShowPlayerNameTagForPlayer(i,playerid,1);
                SendClientMessage(playerid,COLOR_WHITE,"Your name tags are viewable.");
                return 1;
            }
        }
        else
        {
            SendClientMessage(playerid,COLOR_WHITE,"Your are not a high enough rank.");
        }
    }
    return 1;
}
Reply
#8

Код:
C:\Documents and Settings\diingO\Ambiente de trabalho\SM-RPG V.2 R1\gamemodes\SM-RPG.pwn(11911) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
Код:
11911:     return 1;
Reply
#9

Use "TAB" button to fix tabsizes warnings, https://sampforum.blast.hk/showthread.php?tid=251335 more information, and add this to your sscanf line to or it will give a warning just like clive did

pawn Код:
if(sscanf(params, "s[128]", tmp)) return SendClientMessage(playerid, COLOR_WHITE, "[USAGE] /name off/on ");
Reply
#10

added what u said, but the spaces are wrong at this?

Код:
SendClientMessage(playerid, WHITE, "1-3 are valid slots.");
	            }
	        }
	    }
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)