SA-MP Forums Archive
Can someone tell me whats wrong here? 4 Errors. - 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: Can someone tell me whats wrong here? 4 Errors. (/showthread.php?tid=360444)



Can someone tell me whats wrong here? 4 Errors. - ArmandoRamiraz - 17.07.2012

I have tired everything I know and I still cannot figure out why I get these error messages. Hopefully someone else knows and can explain it to me?? Thanks in advance.

Error Messages:
Код:
C:\Users\Owner\Desktop\NGRP\gamemodes\NGRP.pwn(1341) : error 029: invalid expression, assumed zero
C:\Users\Owner\Desktop\NGRP\gamemodes\NGRP.pwn(1341) : warning 215: expression has no effect
C:\Users\Owner\Desktop\NGRP\gamemodes\NGRP.pwn(1341) : error 001: expected token: ";", but found ")"
C:\Users\Owner\Desktop\NGRP\gamemodes\NGRP.pwn(1341) : error 029: invalid expression, assumed zero
C:\Users\Owner\Desktop\NGRP\gamemodes\NGRP.pwn(1341) : fatal error 107: too many error messages on one line

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


4 Errors.
Code:
Код:
	
        new i = 0;
	while(i < sizeof(arrForbiddenNames)) if(strcmp(arrForbiddenNames[i++], GetPlayerNameExt(playerid), true) == 0) {
		SetPlayerName(playerid, "InvalidNick");
		SendClientMessage(playerid, COLOR_RED, "You have been kicked & logged for using a forbidden username.");
		Kick(playerid);
		return 0;

	}
	return 1;
}



Re: Can someone tell me whats wrong here? 4 Errors. - [KHK]Khalid - 17.07.2012

pawn Код:
new i = 0;
while(i < sizeof(arrForbiddenNames))
{ // you forgot this
    if(strcmp(arrForbiddenNames[i++], GetPlayerNameExt(playerid), true) == 0)
    {
        SetPlayerName(playerid, "InvalidNick");
        SendClientMessage(playerid, COLOR_RED, "You have been kicked & logged for using a forbidden username.");
        Kick(playerid);
        return 0;
    }
    return 1;
}



Re: Can someone tell me whats wrong here? 4 Errors. - ArmandoRamiraz - 17.07.2012

Quote:
Originally Posted by HellSphinX
Посмотреть сообщение
pawn Код:
new i = 0;
while(i < sizeof(arrForbiddenNames))
{ // you forgot this
    if(strcmp(arrForbiddenNames[i++], GetPlayerNameExt(playerid), true) == 0)
    {
        SetPlayerName(playerid, "InvalidNick");
        SendClientMessage(playerid, COLOR_RED, "You have been kicked & logged for using a forbidden username.");
        Kick(playerid);
        return 0;
    }
    return 1;
}

I did that but I still get the same errors.


Re: Can someone tell me whats wrong here? 4 Errors. - [KHK]Khalid - 17.07.2012

Weird I compiled the code and it didn't give me errors except undefined symbols COLOR_RED and GetPlayerNameExt because I don't have those.. Uhmm I defined arrForbiddenNames like this new arrForbiddenNames[100]; may you show how is yours defined?


Re: Can someone tell me whats wrong here? 4 Errors. - ArmandoRamiraz - 17.07.2012

Mine is defined like this: new arrForbiddenNames[][]


Re: Can someone tell me whats wrong here? 4 Errors. - [KHK]Khalid - 17.07.2012

Still no errors.

Can you point me to the line 1341 ?


Edit:


Where are you placing this code?


Re: Can someone tell me whats wrong here? 4 Errors. - ArmandoRamiraz - 17.07.2012

Right under the new defines. Here is the whole code.

Код:
//forward strfind(const string[],const sub[],bool:ignorecase=false,pos=0);

stock InvalidNameCheck(playerid)
	{
	new arrForbiddenNames[][] = {
			"com1", "com2", "com3", "com4",
			"com5", "com6", "com7", "com8",
			"com9", "lpt4", "lpt5", "lpt6",
			"lpt7", "lpt8", "lpt9", "nul",
			"clock$", "aux", "prn", "con",
			"InvalidNick"
                };

	        new i = 0;
	        while(i < sizeof(arrForbiddenNames))
	        { // you forgot this
line 1342--------	if(strcmp(arrForbiddenNames[i++], GetPlayerNameExt(playerid), true) == 0);
                {
                SetPlayerName(playerid, "InvalidNick");
                SendClientMessage(playerid, COLOR_RED, "You have been kicked & logged for using a forbidden username.");
                Kick(playerid);
              return 0;
          }
    return 1;
}



Re: Can someone tell me whats wrong here? 4 Errors. - [KHK]Khalid - 17.07.2012

You missed a brace and there was a semi-colon right after the if statement which I removed. Should work now as it did right here.

pawn Код:
stock InvalidNameCheck(playerid)
{
    new arrForbiddenNames[][] = {
            "com1", "com2", "com3", "com4",
            "com5", "com6", "com7", "com8",
            "com9", "lpt4", "lpt5", "lpt6",
            "lpt7", "lpt8", "lpt9", "nul",
            "clock$", "aux", "prn", "con",
            "InvalidNick"
     };

    new i = 0;
    while(i < sizeof(arrForbiddenNames))
    { // you forgot this
        if(strcmp(arrForbiddenNames[i++], GetPlayerNameExt(playerid), true) == 0) // removed a ;
        {
            SetPlayerName(playerid, "InvalidNick");
            SendClientMessage(playerid, COLOR_RED, "You have been kicked & logged for using a forbidden username.");
            Kick(playerid);
            return 0;
        }
    } // added
    return 1;
}



Re: Can someone tell me whats wrong here? 4 Errors. - ArmandoRamiraz - 17.07.2012

:/ still didnt work. I dont understand...I have tried everything lol