if(strcmp(cmd, "/pm", true) == 0 || strcmp(cmd, "/p", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet!");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/p)m [playerid/PartOfName] [text]");
return 1;
}
giveplayerid = GetPlayerID(tmp);
if (IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
if(HidePM[giveplayerid] > 1)
{
SendClientMessage(playerid, COLOR_GREY, " That player is blocking messages!");
return 1;
}
GetPlayerName(playerid, sendername, sizeof(sendername));
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
if(giveplayerid == playerid)
{
return SendClientMessage(playerid, COLOR_GREY, " You can`t send private message to yourself.");
}
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/p)m [playerid/PartOfName] [text]");
return 1;
}
/*new namestring = strfind(result, ":", true);
if(namestring != -1)
{
new pmsplit[4][256];
new str[256];
for(new l=0;l<256;l++) str[l]=result[l];
split((str), pmsplit, '.');
if(strval(pmsplit[1]) != 0 && strval(pmsplit[2]) != 0)
{
new year, month,day;
getdate(year, month, day);
format(string, sizeof(string), "AdmCmd: %s was kicked, reason: Server advert in PM(%d-%d-%d)", giveplayer, sendername, (result),day,month,year);
KickLog(string);
SendClientMessageToAll(COLOR_LIGHTRED, string);
Kick(playerid);
return 1;
}
}*/
CheckPM(playerid,(result));
format(string, sizeof(string), "[ID:%d] %s pm: %s", playerid, sendername, (result));
SendClientMessage(giveplayerid, 0xBBA033AA, string);
format(string, sizeof(string), "PM sent to [ID:%d]%s: %s", giveplayerid, giveplayer, (result));
SendClientMessage(playerid, 0xE5C43EAA, string);
format(string, sizeof(string), ">>PM from [%d]%s to [%d]%s: %s", playerid,sendername,giveplayerid, giveplayer, (result));
PMLog(string);
for(new z=0;z<MAX_PLAYERS;z++)
if (BigEar[z])
SendClientMessage(z, 0x1ED5C7FF, string);
return 1;
}
}
else
{
format(string, sizeof(string), " %d is not an active player.", giveplayerid);
SendClientMessage(playerid, COLOR_GRAD1, string);
}
}
return 1;
}
if(strcmp(cmd, "/pm", true) == 0 || strcmp(cmd, "/p", true) == 0) { if(IsPlayerConnected(playerid)) { if(gPlayerLogged[playerid] == -1) { SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet!"); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/p)m [playerid/PartOfName] [text]"); return 1; } giveplayerid = GetPlayerID(tmp); if (IsPlayerConnected(giveplayerid)) { if(giveplayerid != INVALID_PLAYER_ID) { if(HidePM[giveplayerid] > 1) { SendClientMessage(playerid, COLOR_GREY, " That player is blocking messages!"); return 1; } GetPlayerName(playerid, sendername, sizeof(sendername)); GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); if(giveplayerid == playerid) { return SendClientMessage(playerid, COLOR_GREY, " You can`t send private message to yourself."); } new length = strlen(cmdtext); while ((idx < length) && (cmdtext[idx] <= ' ')) { idx++; } new offset = idx; new result[64]; while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) { result[idx - offset] = cmdtext[idx]; idx++; } result[idx - offset] = EOS; if(!strlen(result)) { SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/p)m [playerid/PartOfName] [text]"); return 1; } /*new namestring = strfind(result, ":", true); if(namestring != -1) { new pmsplit[4][256]; new str[256]; for(new l=0;l<256;l++) str[l]=result[l]; split((str), pmsplit, '.'); if(strval(pmsplit[1]) != 0 && strval(pmsplit[2]) != 0) { new year, month,day; getdate(year, month, day); format(string, sizeof(string), "AdmCmd: %s was kicked, reason: Server advert in PM(%d-%d-%d)", giveplayer, sendername, (result),day,month,year); KickLog(string); SendClientMessageToAll(COLOR_LIGHTRED, string); Kick(playerid); return 1; } }*/ CheckPM(playerid,(result)); format(string, sizeof(string), "[ID:%d] %s pm: %s", playerid, sendername, (result)); SendClientMessage(giveplayerid, 0xBBA033AA, string); format(string, sizeof(string), "PM sent to [ID:%d]%s: %s", giveplayerid, giveplayer, (result)); SendClientMessage(playerid, 0xE5C43EAA, string); format(string, sizeof(string), ">>PM from [%d]%s to [%d]%s: %s", playerid,sendername,giveplayerid, giveplayer, (result)); PMLog(string); for(new z=0;z<MAX_PLAYERS;z++) if (BigEar[z]) SendClientMessage(z, 0x1ED5C7FF, string); return 1; } } else { format(string, sizeof(string), " %d is not an active player.", giveplayerid); SendClientMessage(playerid, COLOR_GRAD1, string); } } return 1; }
Originally Posted by mansonh
No its nothing to do with that. It seems to be something to do with tmp being "0" and GetPlayerID.
A quick fix would be to do giveplayerid = (strval(tmp)==0) ? 0 : GetPlayerID(tmp); Although it would be better to figure out why that is happening, haven't used this that much. |