Command problem
#1

Hello guys!
I have a problem with a command. I've coded a VIP system for my server with some new commands and also, I've introduced a /vipchat command. Because I didn't want to waste time, I've copied the /adminchat command and just replaced some lines. The problem is that when I use /vipchat in game, it does work, but it is also followed by the "SERVER: Unknown command" message and I just don't understand why. Bellow is the script, please help me.
Thanks in advance!



Код:
//===============================================================================================//
	if(strcmp(cmd, "/vipchat", true) == 0 || strcmp(cmd, "/vc", true) == 0 || strcmp(cmd, "/vchat", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(gPlayerLogged[playerid] == 0)
	        {
	            SendClientMessage(playerid, COLOR_WHITE, "You havent logged in yet");
	            return 1;
	        }
  			if (PlayerInfo[playerid][pVIP]==0 && PlayerInfo[playerid][pAdmin] < 1)
			{
				SendClientMessage(playerid, COLOR_WHITE, "You are not a VIP member");
				return 1;
			}
			if(PlayerInfo[playerid][pMuted] == 1)
			{
				SendClientMessage(playerid, TEAM_CYAN_COLOR, "You can't speak, you have been silenced");
				return 1;
			}
			new result[64];
			GetPlayerName(playerid, sendername, sizeof(sendername));
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, COLOR_GREY, "USAGE: /(v)ip©hat [text]");
				return 1;
			}
			format(string, sizeof(string), "{FFFFFF}» {F3FF02}[VIP CHAT] %s: {FFFFFF}%s", sendername, result);
			for(new i=0; i<=MAX_PLAYERS; i++) {
				if(PlayerInfo[i][pVIP]==1)
				  SendClientMessage(i, -1, string);
			}
						
		}
		 return 1;
	}
//===============================================================================================//
Reply
#2

Add return 1; above the last }
Reply
#3

return 1; is already added for the if(strcmp...) ... look in the code.
Reply
#4

Try to add this:

pawn Код:
new string[380]
Reply
#5

I think you have to use return 0;
Reply
#6

@XGreen @MrJunkiTM Did both of those things and still nothing ...
Reply
#7

I got to say, your indentation is fucked up.
Reply
#8

Try This:
pawn Код:
if(strcmp(cmd, "/vipchat", true) == 0 || strcmp(cmd, "/vc", true) == 0 || strcmp(cmd, "/vchat", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_WHITE, "You havent logged in yet");
        if (PlayerInfo[playerid][pVIP]==0 && PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_WHITE, "You are not a VIP member");
        if(PlayerInfo[playerid][pMuted] == 1) return SendClientMessage(playerid, TEAM_CYAN_COLOR, "You can't speak, you have been silenced");
        if(sscanf(params, "uds[50]", cmdtext)) return SendClientMessage(playerid, 0xFFFFFFFF, "Correct usage: /(v)ip©hat [text]");
        new result[64];
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "{FFFFFF}» {F3FF02}[VIP CHAT] %s: {FFFFFF}%s", sendername, result);
        for(new i=0; i<=MAX_PLAYERS; i++) {
        if(PlayerInfo[i][pVIP]==1)
        SendClientMessage(i, -1, string);
    }
    }
    return 1;
}

Also, I Suggest To You To Use zcmd, it's much easier in creating commands.
Reply
#9

Y... I know. I've solve the indentation afther the problem is solved.
Reply
#10

Quote:
Originally Posted by XGreen
Посмотреть сообщение
Try to add this:

pawn Код:
new string[380]
Please check out this thread.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)