SA-MP Forums Archive
idx error. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: idx error. (/showthread.php?tid=493059)



idx error. - Mititel - 06.02.2014

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


Re: idx error. - Mititel - 07.02.2014

Nobody? UP !?!?


Re: idx error. - xdec0de - 08.02.2014

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;
    }



Re: idx error. - Mititel - 08.02.2014

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...


Re: idx error. - Mititel - 09.02.2014

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



Re: idx error. - Mititel - 10.02.2014

bump


Re: idx error. - SwisherSweet - 10.02.2014

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


Re: idx error. - Mititel - 10.02.2014

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


Re: idx error. - CuervO - 10.02.2014

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.


Re: idx error. - Mititel - 22.02.2014

Код:
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.