[HELP!] MOTD - weird error
#1

Aight guys

I got this on top:
Код:
new motd[128];
Then - at OnPlayerConnect:
Код:
  motd = "|Server MOTD:: SA:MP 0.3 is here and it pwns.|";
	SendClientMessage(playerid, COLOR_GREEN, motd);
And as a command -


Код:
	if(strcmp(cmdtext, "/setmotd", true) == 0)
	{
	  if(IsPlayerAdmin(playerid))
	  {
    if(!cmdtext[8])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /setmotd [message]");
    motd = cmdtext[8];
    return 1;
    }
    else
		{
		SendClientMessage(playerid,COLOR_RED,"You are not an RCON admin!");
		}
	}
Why do I get this error?

error 033: array must be indexed (variable "motd")
Reply
#2

You have to use 'format' to change the motd variable:

pawn Код:
format(motd, sizeof(motd), "Blah");
Reply
#3

Well now Iґve got at OnPlayerConnect:
Код:
  format(motd, sizeof(motd), "Server MOTD:: SA:MP 0.3 is here and it pwns.");
	SendClientMessage(playerid, COLOR_GREEN, motd);
And I still get the same error..
Reply
#4

Quote:
Originally Posted by SpiderPork
You have to use 'format' to change the motd variable:

pawn Код:
format(motd, sizeof(motd), "Blah");
He doesn't have to use format.
Quote:
Originally Posted by Mo3
Well now Iґve got at OnPlayerConnect:
Код:
  format(motd, sizeof(motd), "Server MOTD:: SA:MP 0.3 is here and it pwns.");
	SendClientMessage(playerid, COLOR_GREEN, motd);
And I still get the same error..
What the exact line is?
Reply
#5

Well,

here

Код:
	if(strcmp(cmdtext, "/setmotd", true) == 0)
	{
	  if(IsPlayerAdmin(playerid))
	  {
    if(!cmdtext[8])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /setmotd [message]");
    motd = cmdtext[8]; //HERE is the error line - same error as above.
    return 1;
    }
    else
		{
		SendClientMessage(playerid,COLOR_RED,"You are not an RCON admin!");
		}
	}
Reply
#6

Be specific..
pawn Код:
strmid(motd,cmdtext[8],0,strlen(cmdtext[8]),128);
Reply
#7

Well, now the command is not working.
Reply
#8

pawn Код:
// Command
    if(strcmp(cmdtext, "/setmotd", true) == 0)
    {
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not an RCON admin!");
        if(!cmdtext[8]) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /setmotd [message]");
        format( motd, sizeof( motd ), "%s", cmdtext[8]);
        return 1;
    }

// OnPlayerConnect
    new string[ 128 ];
    format(string, sizeof(string), "Server MOTD:: %s", motd);
    SendClientMessage(playerid, COLOR_GREEN, string);
Reply
#9

Quote:
Originally Posted by MenaceX^
He doesn't have to use format.
I've had the same problem some time ago, and I've fixed it with format.
Reply
#10

Quote:
Originally Posted by SpiderPork
Quote:
Originally Posted by MenaceX^
He doesn't have to use format.
I've had the same problem some time ago, and I've fixed it with format.
With pawns arrays you can only make then equal (string = string2 if they are the same size
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)