idx error.
#1

Hi!

I tried to make an order, only for leaders, but that faction player when connecting the server I want to show "X Faction News: Tomorrow at 14:00 war", I tried to make onplayerlogin, but it gives me error and do not know how to do.

Command:
Код:
if(strcmp(cmd, "/factionanunt", true) == 0 || strcmp(cmd, "/facan", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pRank] < 5)
            {
                SendClientMessage(playerid, COLOR_GREY, "   Trebuie sa ai rankul in factiune mai mare ca 5 !");
                return 1;
            }
            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: (/fac)tionanunt [text]");
                return 1;
            }
            if(PlayerInfo[playerid][pMember] == 1||PlayerInfo[playerid][pLeader] == 1)
            {
                format(string, sizeof(string), "Anunt Factiune:  %s", result);
                SendClientMessageToAll(COLOR_DBLUE, string);
            }
        }
        return 1;
    }
Error:
Код:
C:\Documents and Settings\vlad\Desktop\vladgm\vladgm\gamemodes\gf.p wn(1913 : error 017: undefined symbol "idx"
C:\Documents and Settings\vlad\Desktop\vladgm\vladgm\gamemodes\gf.p wn(19140) : error 017: undefined symbol "idx"
C:\Documents and Settings\vlad\Desktop\vladgm\vladgm\gamemodes\gf.p wn(19142) : error 017: undefined symbol "idx"
C:\Documents and Settings\vlad\Desktop\vladgm\vladgm\gamemodes\gf.p wn(19142) : error 017: undefined symbol "idx"
C:\Documents and Settings\vlad\Desktop\vladgm\vladgm\gamemodes\gf.p wn(19142) : error 029: invalid expression, assumed zero
C:\Documents and Settings\pwaah\Desktop\vladgm\vladgm\gamemodes\gf. pwn(19142) : fatal error 107: too many error messages on one line
PS: i defined IDX ,but it still gives me errors

Sorry for my bad english. i need help
Reply
#2

Nobody? UP !?!?
Reply
#3

Try this:

Код:
	if(strcmp(cmd, "/factionanunt", true) == 0 || strcmp(cmd, "/facan", true) == 0)
 	{
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pRank] < 5)
            {
                SendClientMessage(playerid, COLOR_GREY, "   Trebuie sa ai rankul in factiune mai mare ca 5 !");
                return 1;
            }
            new idx;
			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, -1, "USAGE: (/fac)tionanunt [text]");
				return 1;
			}
            if(PlayerInfo[playerid][pMember] == 1)
            {
            	format(string, sizeof(string), "Anunt Factiune:  %s", result);
                SendClientMessageToAll(COLOR_DBLUE, string);
            }
        }
        return 1;
    }
Reply
#4

No,no,no..

I want the format (message to be placed on onplayerlogin):
Код:
format(string, sizeof(string), "Anunt Factiune:  %s", result);
                SendFamilyMessage(1, COLOR_DBLUE, string);
This code to be placed on onplayerlogin.

On my server there are 16 factions and I want this message to each of the items...

Again ,sorry for my bad english...
Reply
#5

Quote:
Originally Posted by Mititel
Посмотреть сообщение
Nobody? UP !?!?
Reply
#6

bump
Reply
#7

how is anyone supposed to know what idx means? From the look of it you ripped that code off another script...
Reply
#8

Quote:
Originally Posted by SwisherSweet
Посмотреть сообщение
how is anyone supposed to know what idx means? From the look of it you ripped that code off another script...
OMG !

Help me or go away
Reply
#9

Quote:
Originally Posted by Mititel
Посмотреть сообщение
OMG !

Help me or go away
That's not how it works around this neighberhood.

1) Upgrade to sscanf (which is incredibly easier than strtok).

2) As for what you want: you need to add simple conditional statements. (if, else if) or switch ones which essentially are the same.
Reply
#10

Код:
C:\Documents and Settings\vladgm\Desktop\gf.pwn(21880) : error 035: argument type mismatch (argument 1)
C:\Documents and Settings\vladgm\Desktop\gf.pwn(21881) : error 028: invalid subscript (not an array or too many subscripts): "cmdtext"
C:\Documents and Settings\vladgm\Desktop\gf.pwn(21881) : error 029: invalid expression, assumed zero
C:\Documents and Settings\vladgm\Desktop\gf.pwn(21881) : error 029: invalid expression, assumed zero
C:\Documents and Settings\vladgm\Desktop\gf.pwn(21881) : fatal error 107: too many error messages on one line

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


5 Errors.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)