SA-MP Forums Archive
Problem... - 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: Problem... (/showthread.php?tid=327757)



Problem... - jimis - 22.03.2012

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.


Re: Problem... - Basssiiie - 22.03.2012

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.


Re: Problem... - Jack.7331 - 22.03.2012

Beat me to it ^


Re: Problem... - jimis - 22.03.2012

Thanks,its work now