GameTextForAll
#1

Why doesnt this command work.. i get no errors when i compile
when i type "/ann text" in-game nothing happends but when i type /ann the
"SYNTAX: /ann [message]" shows so it must be something with the "GameTextForAll"

Код:
command(ann, playerid, params[])
{
	new Announcement[128], string[ 128 ];
	if( sscanf( params, "z", Announcement) )
	{
		if( Player[playerid][AdminLevel] >= 1 )
	    {
			SendClientMessage( playerid, WHITE, "SYNTAX: /ann [message]" );
		}
	}
	else
	{
	    if( Player[playerid][AdminLevel] >= 1)
	    {
			if(strlen(Ann) >= 1)
			{
			    format( string, sizeof( string ), " %s ", Announcement );
			    GameTextForAll( string, 5000, 3 );
			}
			else
			{
			    SendClientMessage( playerid, WHITE, "SYNTAX: /ann [message]" );
			}
		}
	}
	return 1;
}
Reply
#2

pawn Код:
if(strlen(Ann) >= 1)
Bad

pawn Код:
if(strlen(Announcement) >= 1)
Good

You are checking the length, of a non existing string, thats why you don't see anything


Also if you are using the sscanf2 plugin, use 's[128]' instead of 'z' Its outdated.
Reply
#3

Plus, you don't need the string, waste of 128 cells

pawn Код:
GameTextForAll( Announcement, 5000, 3 );
Will do exactly the same.
Reply
#4

Quote:
Originally Posted by [XST]O_x
Посмотреть сообщение
Plus, you don't need the string, waste of 128 cells

pawn Код:
GameTextForAll( Announcement, 5000, 3 );
Will do exactly the same.
Quote:
Originally Posted by playbox12
Посмотреть сообщение
pawn Код:
if(strlen(Ann) >= 1)
Bad

pawn Код:
if(strlen(Announcement) >= 1)
Good

You are checking the length, of a non existing string, thats why you don't see anything


Also if you are using the sscanf2 plugin, use 's[128]' instead of 'z' Its outdated.
Okay well here is my code now:

Код:
command(ann, playerid, params[])
{
	new Announcement[128], string[ 128 ];
	if( sscanf( params, "z", Announcement) )
	{
		if( Player[playerid][AdminLevel] >= 1 )
	    {
			SendClientMessage( playerid, WHITE, "SYNTAX: /ann [message]" );
		}
	}
	else
	{
	    if( Player[playerid][AdminLevel] >= 1)
	    {
			if(strlen(Announcement) >= 1)
			{
			    GameTextForAll( string, 5000, 3 );
			}
			else
			{
			    SendClientMessage( playerid, WHITE, "SYNTAX: /ann [message]" );
			}
		}
	}
	return 1;
}
Still not working tryed to add "[128]" if i add that it just keep sending "SYNTAX: /ann [message]"
no matter what you type.. but with "z" no responds at all :/
Reply
#5

Sigh, please read a bit better, I am quite getting tired so I just fix your code


pawn Код:
command(ann, playerid, params[])
{
    new Announcement[128];
    if( sscanf( params, "s[128]", Announcement) )
    {
        if( Player[playerid][AdminLevel] >= 1 )
        {
            SendClientMessage( playerid, WHITE, "SYNTAX: /ann [message]" );
        }
    }
    else
    {
        if( Player[playerid][AdminLevel] >= 1)
        {
            if(strlen(Announcement) >= 1)
            {
                GameTextForAll(Announcement, 5000, 3 );
            }
            else
            {
                SendClientMessage( playerid, WHITE, "SYNTAX: /ann [message]" );
            }
        }
    }
    return 1;
}
YES!!
Reply
#6

Quote:
Originally Posted by playbox12
Посмотреть сообщение
Sigh, please read a bit better, I am quite getting tired so I just fix your code


pawn Код:
command(ann, playerid, params[])
{
    new Announcement[128];
    if( sscanf( params, "s[128]", Announcement) )
    {
        if( Player[playerid][AdminLevel] >= 1 )
        {
            SendClientMessage( playerid, WHITE, "SYNTAX: /ann [message]" );
        }
    }
    else
    {
        if( Player[playerid][AdminLevel] >= 1)
        {
            if(strlen(Announcement) >= 1)
            {
                GameTextForAll(Announcement, 5000, 3 );
            }
            else
            {
                SendClientMessage( playerid, WHITE, "SYNTAX: /ann [message]" );
            }
        }
    }
    return 1;
}
YES!!
Hmm.. Thank you but still not working. if i type "/ann test" it just say "SYNTAX: /ann [message]" as a ClientMessage.
Reply
#7

Okay it works now but now the "SYNTAX /ann [message]" dosnt show

Код:
command(ann, playerid, params[])
{
    new Announcement[128];    
    if( sscanf( params, "s[128]", Announcement) )
    {
        if( Player[playerid][AdminLevel] >= 1 )
        {
            GameTextForAll(Announcement, 5000, 3 );
        }
    }
    else
    {
        if( Player[playerid][AdminLevel] >= 1)
        {
            if(strlen(Announcement) >= 1)
            {
                SendClientMessage( playerid, WHITE, "SYNTAX: /ann [message]" );
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)