SA-MP Forums Archive
Code won't work - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Code won't work (/showthread.php?tid=131964)



Code won't work - Bob_Mars - 06.03.2010

Hello I'm trying to block a name (of a few) from connecting to my server because it freezes my server and i tried this code but I get errors and idk how to fix them.

Код:
   public OnPlayerConnect(playerid)
   {
       new pName[MAX_PLAYER_NAME];
       GetPlayerName(playerid,pName,sizeof(pName);//probably messed that up bad
       if(pName == "con"){
       Kick(playerid);
       }
       //rest of player connect
       return 1;
}
Errors:

Quote:

C:\Users\Alex\Desktop\HydraX\Stunt Paradise 0.3a\pawno\include\cps.inc(140) : warning 208: function with tag result used before definition, forcing reparse
C:\Users\Alex\Desktop\Stunt Paradise 0.3a\gamemodes\SP.pwn(1021) : error 027: invalid character constant
C:\Users\Alex\Desktop\Stunt Paradise 0.3a\gamemodes\SP.pwn(1021) : error 017: undefined symbol "on"
C:\Users\Alex\Desktop\Stunt Paradise 0.3a\gamemodes\SP.pwn(1021 -- 1022) : error 029: invalid expression, assumed zero
C:\Users\Alex\Desktop\Stunt Paradise 0.3a\gamemodes\SP.pwn(1021 -- 1022) : 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: Code won't work - Correlli - 06.03.2010

Check the sa:mp wiki and search for strcmp function (you can use it to compare two strings) and also check PAWN basics.


Re: Code won't work - Bob_Mars - 06.03.2010

Quote:
Originally Posted by Don Correlli
Check the sa:mp wiki and search for strcmp function (you can use it to compare two strings) and also check PAWN basics.
I need someone to fix it for me.


Re: Code won't work - CJ101 - 06.03.2010

Код:
   public OnPlayerConnect(playerid)
   {
       new pName[MAX_PLAYER_NAME];
       GetPlayerName(playerid,pName,sizeof(pName));//probably messed that up bad
       if(strcmp(pName,"con",true)) Kick(playerid);
       //rest of player connect
       return 1;
}



Re: Code won't work - Bob_Mars - 06.03.2010

Quote:
Originally Posted by CJ101
Код:
   public OnPlayerConnect(playerid)
   {
       new pName[MAX_PLAYER_NAME];
       GetPlayerName(playerid,pName,sizeof(pName));//probably messed that up bad
       if(strcmp(pName,"con",true)) Kick(playerid);
       //rest of player connect
       return 1;
}
Thanks but I'm getting errors can you add it for me in my GM? Here's the GM.. http://pastebin.com/3MdM4rmU