03.03.2009, 10:06
the thing is, I made a /w command to do whispers just like this, and it works fine. I take out the fact of the playerid being in there and it doesnt work...
pawn Код:
if(strcmp(cmd, "/w", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
PlayerMessage(playerid, pgreen5, "/w [playerid] [whisper text]");
return 1;
}
new name[maxplayername];
new targetname[maxplayername];
new targetid = ReturnUser(tmp);
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(targetid, targetname, sizeof(targetname));
if (IsPlayerConnected(targetid))
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[128];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
format(str, sizeof(str), "/w [%s] [whisper text]", targetname);
PlayerMessage(playerid, pgreen5, str);
return 1;
}
format(str, sizeof(str), "%s(%d) whispers : %s", name, playerid, result);
PlayerMessage(targetid, pblue3, str);
format(str, sizeof(str), "You whisper to %s : %s", targetname, result);
PlayerMessage(playerid, pblue3, str);
return 1;
}
return 1;
}