if(strcmp(cmd, "/lchat", true) == 0 || strcmp(cmd, "/limparchat", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] < 3)
{
SendClientMessage(playerid, COLOR_GREY, "Vocк nгo й um admin!");
return true;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USE: /limparchat [motivo]");
return true;
}
if(admtrampando[playerid] < 1 && PlayerInfo[playerid][pAdmin] != DONO)
{
SendClientMessage(playerid, COLOR_GRAD1, " Vocк nгo estб em modo Admin USE: /jogar");
return true;
}
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i)) ClearChatbox(i, 100);
}
new result[64];
format(string, sizeof(string), "O admin %s limpou o chat, motivo: %s", PlayerName(playerid), result);
SendClientMessageToAll(COLOR_WHITE, string);
}
return true;
}
E ai galera, й o seguinte, eu tinha um comando /limparchat que nгo precisava colocar o motivo, mas ai resolvi colocar motivo, estб dando tudo certo, ta limpando o Chat e ta pedindo pra colocar o motivo, porйm, nгo estб aparecendo o motivo na mensagem "motivo:" serб que vocкs podem me ajudar?
PHP код:
|
new result[64];
format(string, sizeof(string), "O admin %s limpou o chat, motivo: %s", PlayerName(playerid), result);
SendClientMessageToAll(COLOR_WHITE, string);
if(strcmp(cmd, "/lchat", true) == 0 || strcmp(cmd, "/limparchat", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] < 3)
{
SendClientMessage(playerid, COLOR_GREY, "Vocк nгo й um admin!");
return true;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USE: /limparchat [motivo]");
return true;
}
if(admtrampando[playerid] < 1 && PlayerInfo[playerid][pAdmin] != DONO)
{
SendClientMessage(playerid, COLOR_GRAD1, " Vocк nгo estб em modo Admin USE: /jogar");
return true;
}
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i)) ClearChatbox(i, 100);
}
format(string, sizeof(string), "O admin %s limpou o chat, motivo: %s", PlayerName(playerid), tmp);
SendClientMessageToAll(COLOR_WHITE, string);
}
return true;
}
Eu nгo uso e nem pretendo usar strrok, mas acho que isso resolve.
PHP код:
|
if(strcmp(cmd, "/lchat", true) == 0 || strcmp(cmd, "/limparchat", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] < 3)
{
SendClientMessage(playerid, COLOR_GREY, "Vocк nгo й um admin!");
return true;
}
tmp = strrest(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USE: /limparchat [motivo]");
return true;
}
if(admtrampando[playerid] < 1 && PlayerInfo[playerid][pAdmin] != DONO)
{
SendClientMessage(playerid, COLOR_GRAD1, " Vocк nгo estб em modo Admin USE: /jogar");
return true;
}
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i)) ClearChatbox(i, 100);
}
format(string, sizeof(string), "O admin %s limpou o chat, motivo: %s", PlayerName(playerid), tmp);
SendClientMessageToAll(COLOR_WHITE, string);
}
return true;
}
stock strrest(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[128];
while ((index < length) && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
stock strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
sera que ele tem q formatar a string assim ?
format(string, sizeof(string), "O admin %s limpou o chat, motivo: %s", PlayerName(playerid), idx); isso й, se idx foi criado como uma string nй, tipo new idx[128]; ta meio confuso |