Simple test cmds
#1

Ok, i'm trying to see if i can make it so only people with a certain name can use it, i've seen it done before, and everything i'm trying won't work. What am i doing wrong?

Код:
CMD:test(playerid)
{
	new playername[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
	if(strcmp("Jay_Dixon,"playername, true, 10) == 0)
	{
	    SendClientMessage(playerid, COLOR_LIGHTBLUE, "i'm awesome!");
	    return 1;
	}
	else
	{
	    SendClientMessage(playerid, COLOR_LIGHTRED, "   YOU'RE NOT JAY!");
	}
	return 1;
}
Код:
C:\Users\Jay\Desktop\FRP\gamemodes\FRP.pwn(34693) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\Jay\Desktop\FRP\gamemodes\FRP.pwn(34693) : warning 215: expression has no effect
C:\Users\Jay\Desktop\FRP\gamemodes\FRP.pwn(34693) : warning 215: expression has no effect
C:\Users\Jay\Desktop\FRP\gamemodes\FRP.pwn(34693) : warning 215: expression has no effect
C:\Users\Jay\Desktop\FRP\gamemodes\FRP.pwn(34693) : error 001: expected token: ";", but found ")"
C:\Users\Jay\Desktop\FRP\gamemodes\FRP.pwn(34693) : error 029: invalid expression, assumed zero
C:\Users\Jay\Desktop\FRP\gamemodes\FRP.pwn(34693) : 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

if (strcmp("Jay_Dixon", playername, true, 10) == 0) and i tell you for info that the string's length (10) is optional parameter.
Reply
#3

pawn Код:
CMD:test(playerid)
{
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
    if(strcmp("Jay_Dixon",playername, false) == 0)
    {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "i'm awesome!");
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "   YOU'RE NOT JAY!");
    }
    return 1;
}
Reply
#4

Everyone else got to it, but you have the comma inside of the quotes in this line:

Код:
if(strcmp("Jay_Dixon,"playername, true, 10) == 0)
Also as stated, I would remove the 10. I also like writing mine as such:

Код:
if(!strcmp("Jay_Dixon", playername, true))
Does the same thing, checks for zero.
Reply
#5

Try :

pawn Код:
CMD:test(playerid)
{
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
    if(!strcmp("Jay_Dixon", playername, true))
    {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "i'm awesome!");
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "   YOU'RE NOT JAY!");
    }
    return 1;
}
EDIT: Late, Late, Too late.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)