Problem...
#1

When i am writting this
pawn Code:
PHP код:
if (strcmp("/mycmd"cmdtexttrue5) == 0)
    {
        new 
pname[20];
        
GetPlayerName(playerid,pname,sizeof(pname));
       if(
strcmp(pname,"jimis",true) == 0) && if(strcmp(pname,"name2",true) == 0) && if(strcmp(pname,"name3",true)== )
        {
            
//All other command codes goes here like:
            
SendClientMessage(playerid,-1,"Hi jimis, command is only for you :).");
        }
        else
        {
            
SendClientMessage(playerid,-1,"Command is only for jimis.");
        }
        return 
1;
    } 

i am having the following errors ,what its wrong?

C:\Users\Дзмзфсзт\Desktop\server4\gamemodes\newtes t.pwn(2813) : error 029: invalid expression, assumed zero
C:\Users\Дзмзфсзт\Desktop\server4\gamemodes\newtes t.pwn(2813) : warning 215: expression has no effect
C:\Users\Дзмзфсзт\Desktop\server4\gamemodes\newtes t.pwn(2813) : error 001: expected token: ";", but found "if"
C:\Users\Дзмзфсзт\Desktop\server4\gamemodes\newtes t.pwn(2813) : error 029: invalid expression, assumed zero
C:\Users\Дзмзфсзт\Desktop\server4\gamemodes\newtes t.pwn(2813) : fatal error 107: too many error messages on one line

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


4 Errors.
Reply
#2

The problem is here:
Код:
if(strcmp(pname,"jimis",true) == 0) && if(strcmp(pname,"name2",true) == 0) && if(strcmp(pname,"name3",true)== 0 )
First, you can't use multiple 'if's on one line. Second, you're asking if the player is called 'jimis', but also 'name2' and 'name3' at the same time. Obviously you can't have three names at the same time.

This should be good:
Код:
if(!strcmp(pname,"jimis",true) || !strcmp(pname,"name2",true) || !strcmp(pname,"name3",true))
I also changed '== 0' to just a exclamation mark ('!') before the function, which both just give the same effect, but it makes the line a bit shorter.
Reply
#3

Beat me to it ^
Reply
#4

Thanks,its work now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)