/announce help
#1

Код:
		if(!strcmp(cmdtext, "/announce", true, 8))
    {
    new tString[256];
    if(cmdtext[9] != 32 || cmdtext[9] == EOS)
    {
		SendClientMessage(playerid, COLOR_BRIGHTRED, "USAGE: /announce <your announcement>");
 		}
		else
		{
    SendClientMessageToAll(COLOR_YELLOW,tString);
    format(tString,sizeof(tString), "| Announcement: | %s", tString);
    SendClientMessageToAll(COLOR_YELLOW,tString);
    return 1;
    }
}
Hmmm I don't get what's wrong with this. It keeps showing USAGE: /announce <your announcement>, even if I type something like /announce test.

Could somebody check this for me please?

Bye!

EDIT: The forums must hate me, my intendation keeps fucking here, sorry for that!
Reply
#2

pawn Код:
if(strcmp(cmd, "/announce", true) == 0)
        {
            new length = strlen(cmdtext);
            new idx;
            new string[128];
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /announce [TEXT]");
                return 1;
            }
            format(string,sizeof(string), "| Announcement: | %s", result);
            SendClientMessageToAll(COLOR_YELLOW,tString);
        return 1;
    }
Reply
#3

C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(156) : error 017: undefined symbol "idx"
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(206) : error 033: array must be indexed (variable "idx")
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(20 : error 022: must be lvalue (non-constant)
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(20 : warning 215: expression has no effect
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(210) : error 033: array must be indexed (variable "-unknown-")
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(212) : error 033: array must be indexed (variable "idx")
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(214) : error 033: array must be indexed (variable "idx")
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(215) : error 022: must be lvalue (non-constant)
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(215) : warning 215: expression has no effect
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(217) : error 033: array must be indexed (variable "idx")
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(223) : error 017: undefined symbol "string"
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(223) : error 017: undefined symbol "string"
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(223) : error 029: invalid expression, assumed zero
C:\Users\Matthias\Desktop\SA-MP Stuff\Servers\Los Santos TDM - Without IRC\gamemodes\LosSantos.pwn(223) : fatal error 107: too many error messages on one line

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


:<
Reply
#4

You pawn tags.

pawn Код:
new
string[128],
idx;
Under OnPlayerCommandText, above all commands.
Reply
#5

Should I remove that?
Reply
#6

No add that.
Reply
#7

Quote:
Originally Posted by GTA_Rules
Should I remove that?
You can't remove something that doesn't exist..
Reply
#8

use that, thats the best
pawn Код:
if(!strcmp(cmdtext, "/announce", true, 9))
{
    if(cmdtext[9] != 32 || cmdtext[10] == EOS)
        return SendClientMessage(playerid, COLOR_BRIGHTRED, "USAGE: /announce <your announcement>");
    new tString[128];
    format(tString, sizeof(tString), "| Announcement: | %s", cmdtext[10]);
    return SendClientMessageToAll(COLOR_YELLOW, tString);
}
and to your first post, if you dont understand how that works, dont use it!
Reply
#9

Код:
	if(strcmp(cmd, "/announce", true) == 0 || strcmp(cmd, "/gov", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			GetPlayerName(playerid, sendername, sizeof(sendername));
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[64];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/gov)ernment [text]");
				return 1;
			}
			SendClientMessageToAll(ColorHere, "-|_________________ Announcement _________________|-");
			SendClientMessageToAll(ColorHere, "Message Here");
		}
		return 1;
	}
that should work
Reply
#10

No zack, that won't work. You need a format().
Else it will send 1 basic message each time i do it.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)