if(strcmp(cmdtext, "/me", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new string[256];
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
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_RED, "USAGE: /me [action]");
return 1;
}
format(string, sizeof(string), "* %s %s", sendername, result);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
printf("%s", string);
}
return 1;
}
dcmd_me(playerid,params[])
{
new string[99],Playername[MAX_PLAYER_NAME],action[99],Float:PosX, Float:PosY, Float:PosZ;
if(sscanf(params,"z",action)) return SendClientMessage(playerid,COLOR_RED,"* Syntax Error: /me [action]");
else
{
for(new i =0; i < MAX_PLAYERS; i++)
{
GetPlayerRPName(playerid,Playername,sizeof(Playername));
GetPlayerPos(playerid,PosX,PosY,PosZ);
if(IsPlayerInRangeOfPoint(i,20,PosX,PosY,PosZ))
{
format(string,sizeof(string),"* %s %s",Playername,action);
SendClientMessage(i,COLOR_LIGHTGREY,string);
}
}
}
return 1;
}
if(strcmp(cmdtext, "/me", true) == 0)
if(!strcmp(cmdtext, "/me", true) == 0)//with a '!'
dcmd_me(playerid,params[])
{
new string[128],Playername[MAX_PLAYER_NAME],action[104];
if(sscanf(params,"s[104]",action)) return SendClientMessage(playerid,COLOR_RED,"* Syntax Error: /me [action]");
else
{
GetPlayerName(playerid,Playername,sizeof(Playername));
format(string,sizeof(string),"* %s %s",Playername,action);
SendClientMessageToAll(COLOR_LIGHTGREY,string);
}
return 1;
}
Originally Posted by wiki.sa-mp.com
pawn Код:
|
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/me", true, 3)) // 3 is the length of /me
{
if(!cmdtext[3])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
new str[128];
GetPlayerName(playerid, str, sizeof(str));
format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
ProxDetector(30.0, playerid, str, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
return 0;
}
if(!strcmp(cmdtext, "/me", true, 3))
{
new string[128]; GetPlayerName(playerid, string, sizeof string);
format(string, sizeof string, "** %s %s", string, cmdtext[4]);
SendClientMessageToAll(COLOR_GREEN, string);
return 1;
}