24.02.2010, 15:48
Код:
if(strcmp("/pm", cmd, true) == 0) { tmp = strtok(cmdtext,idx); if(!strlen(tmp) || strlen(tmp) > 5) { SendClientMessage(playerid,COLOR_GREEN,"Usage: /pm [id] (Message)"); return 1; } id = strval(tmp); tmp = strtok(cmdtext,idx); if(!strlen(tmp)) { SendClientMessage(playerid,COLOR_GREEN,"Usage: /pm [id] [Message]"); return 1; } if(!IsPlayerConnected(id)) { SendClientMessage(playerid,COLOR_RED,"Bad player ID"); return 1; } if(playerid != id) { GetPlayerName(id,iName,sizeof(iName)); GetPlayerName(playerid,pName,sizeof(pName)); format(Message,sizeof(Message),">> %s(%d): %s",iName,id,gMessage); SendClientMessage(playerid,COLOR_PURPLE,Message); format(Message,sizeof(Message),"** %s(%d): %s",pName,playerid,gMessage); SendClientMessage(id,COLOR_ORANGE,Message); PlayerPlaySound(id,1085,0.0,0.0,0.0); printf("PM: %s",Message); } else { SendClientMessage(playerid,YELLOW,"You cannot PM yourself"); } return 1; } return 0; } 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; }