06.01.2016, 23:06
Fiz um comando e nele eu queria colocar um limite de caracteres a ser inserido no motivo em qual o ADM deu o /slap(/tapa), se o motivo passar de 24 caracteres retornar a mensagem dizendo que ultrapassou o limite, tentei usar o strlen sу que consigo passar o limite =/, fiz alguma coisa errada?, alguem ajuda?
if(strlen(reason) > 24) return SendClientMessage(playerid, -1, "[SERVER]: Reason limit is 24 characters!");
if(strlen(reason) > 24) return SendClientMessage(playerid, -1, "[SERVER]: Reason limit is 24 characters!");
PHP код:
CMD:slap(playerid, params[])
{
new reason[24], str[140], Float:X, Float:Y, Float:Z;
if(pInfo[playerid][pConectado] == false) return SendClientMessage(playerid, -1, "[SERVER]: You are not logged in!");
if(pInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, -1, "[SERVER]: You are not allowed to use this command!");
if(sscanf(params,"us[24]", params[0], reason)) return SendClientMessage(playerid, -1, "[SYNTAX]: /slap [Player ID] [Reason]");
if(strlen(reason) > 24) return SendClientMessage(playerid, -1, "[SERVER]: Reason limit is 24 characters!");
if(!IsPlayerConnected(params[0])) return SendClientMessage(playerid, -1, "[SERVER]: Player not connected!");
GetPlayerPos(params[0], X, Y, Z), SetPlayerPos(params[0], X, Y, Z+10);
format(str, sizeof(str), "[SERVER]: {8CACDE}%s {628DD1}has been slapped, Reason: {8CACDE}%s.", PegarNome(params[0]), reason);
SendClientMessage(playerid, COLOR_ADMIN, str);
format(str, sizeof(str), "[SERVER]: Admin {8CACDE}%s {628DD1}has slapped you, Reason: {8CACDE}%s.", PegarNome(playerid), reason);
SendClientMessage(params[0], COLOR_ADMIN, str);
return 1;
}