How can I script a /me CMD? | Beginner Scripter -
B-rian - 31.08.2011
I wanted to know how I can script a /me cmd like the ones in an RP server, i would appreciate a tutorial or a detailed post Thank you
Re: How can I script a /me CMD? | Beginner Scripter -
Jafet_Macario - 31.08.2011
Uhm, you use zcmd/ycmd/dcmd/strcmp . .?
Re: How can I script a /me CMD? | Beginner Scripter -
Scenario - 31.08.2011
Seriously? Search before you post! More information on
searching can be found
here.
Re: How can I script a /me CMD? | Beginner Scripter -
=WoR=Bruno - 31.08.2011
https://sampforum.blast.hk/showthread.php?tid=280380
Why open the same thread twice? ^^
Re: How can I script a /me CMD? | Beginner Scripter -
Speed - 31.08.2011
pawn Код:
if(strcmp(cmd, "/me", true) == 0)
{
if(IsPlayerConnected(playerid))
{
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_GRAD2, "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;
}
Here you go
Re: How can I script a /me CMD? | Beginner Scripter -
Amel_PAtomAXx - 31.08.2011
pawn Код:
if(strcmp(cmdtext,"/me",true,3)== 0)
{
if ( cmdtext[ 3 ] != ' ' || !cmdtext[ 4 ] )
return SendClientMessage( playerid, -1, "USAGE: /me (action)" );
new pName[MAX_PLAYER_NAME],string[128];
GetPlayerName(playerid,pName,sizeof(pName));
format(string,sizeof(string),"**%s%s.",pName,cmdtext[3]);
SendClientMessageToAll(0xFFFFFFFF,string);
return 1;
}
Re: How can I script a /me CMD? | Beginner Scripter -
Kingunit - 31.08.2011
Quote:
Originally Posted by Speed
pawn Код:
if(strcmp(cmd, "/me", true) == 0) { if(IsPlayerConnected(playerid)) { 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_GRAD2, "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; }
Here you go 
|
He probably don't have that proxdetector.
Re: How can I script a /me CMD? | Beginner Scripter -
AustinJ - 31.08.2011
I recommend using sscanf and zcmd. The way you could do this with these is....
PHP код:
CMD:me(playerid, params[])
{
new action[256], string[256], name[24], Float:x, Float:y, Float:z;
if(sscanf(params, "s[256]", action))
{
SendClientMessage(playerid, COLOR, "USAGE: /me [action]");
}
else
{
GetPlayerName(playerid, name, 24);
GetPlayerPos(playerid, x, y, z);
format(string, 256, "* %s %s *", name, action);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 10, x, y, z))
{
SendClientMessage(i, COLOR, string);
}
}
}
return 1;
}
Re: How can I script a /me CMD? | Beginner Scripter -
B-rian - 01.09.2011
Guys thanks for the tips and codes! I managed to do it now

Also sry for double posting this thread, it was a fail of my PC vry sorry
Re: How can I script a /me CMD? | Beginner Scripter -
Scenario - 01.09.2011
Quote:
Originally Posted by AustinJ
I recommend using sscanf and zcmd. The way you could do this with these is....
PHP код:
CMD:me(playerid, params[])
{
new action[256], string[256], name[24], Float:x, Float:y, Float:z;
if(sscanf(params, "s[256]", action))
{
SendClientMessage(playerid, COLOR, "USAGE: /me [action]");
}
else
{
GetPlayerName(playerid, name, 24);
GetPlayerPos(playerid, x, y, z);
format(string, 256, "* %s %s *", name, action);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 10, x, y, z))
{
SendClientMessage(i, COLOR, string);
}
}
}
return 1;
}
|
No. You don't need to use sscanf for such a simple command.
You can use "params" and run a "strlen" check to see if it's too long...