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



Problem strlen [FIXED] - Penait1 - 28.08.2011

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


Re: Problem strlen - [MG]Dimi - 28.08.2011

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


Re: Problem strlen - Kingunit - 28.08.2011

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;
}