Problem strlen
#1

Hi, i made a command /me. It should give a error if you dont fill in the params.. But it doesnt give the error?
Code:

Код:
CMD:me(playerid, params[])
{
	if(!strlen(params))
	{
        SendClientMessage(playerid, COLOR_RED, "[ERROR] "green"Usage: /me [TEXT]");
        return 1;  //Stopt het commando
	}
	else
	{
		new pname[24];
   		new string[128];
   		GetPlayerName(playerid, pname, sizeof(pname));
    	format(string, sizeof(string), "[ME] "yellow"%s "green"%s "grey"(/Me [TEXT])", pname, params);
		SendClientMessageToAll(COLOR_RED, string);
	}
	return 1;
}
Thanks
Penait1
Reply
#2

I'm still learning ZCMD but just replace it with
PHP код:
if(strlen(cmdtext) < 5
EDIT: Didn't see it's fixed xD
Reply
#3

This is a better one
pawn Код:
CMD:me(playerid, params[])
{
    new pName[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, pName, sizeof(pName));
    if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /me [Action]");
    format(string, sizeof(string), "* %s %s", pName, params);
    SendClientMessageToAll(COLOR_WHITE,string);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)