/me command -
Hand-Scripter - 02.03.2012
Hi guys, I was thinking, how am I able to make /me command for Roleplay? I don't use zcmd or sscanf or anything like that, Because I am still learning about Pawn, and want to know how to make a /me command,
Hand.
Re: /me command -
Twisted_Insane - 02.03.2012
Hey, I just made one for you!

Change the colour if you want:
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]);
SendClientMessageToAll(0xFFFF00AA, str);
return 1;
}
return 0;
}
Hope I could help!
Re: /me command -
Hand-Scripter - 02.03.2012
Thanks alot, Youve helped me lol, everyone have the /me as pink, You know the pink code?
Re: /me command -
Twisted_Insane - 02.03.2012
https://sampforum.blast.hk/showthread.php?tid=157789
Simply replace "0xFFFF00AA" with the colour you want!
Re: /me command -
Hand-Scripter - 02.03.2012
Damn, Thanks alot.
EDIT: I got 26 errors, I have multiple commands;
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/rules", cmdtext, true, 6) == 0)
{
SendClientMessage(playerid,0x33AA33AA,"This is a RolePlay Server, We want you to RP the best you can!");
SendClientMessage(playerid,0x33AA33AA,"Cheating is strict forbidden, Doing it can lead to ban!");
SendClientMessage(playerid,0x33AA33AA,"Do not Spam/Provoke, Doing it can lead to punishment!");
SendClientMessage(playerid,0x33AA33AA,"Always Respect/Listen the Admins, They are here to help you!");
if (strcmp("/credits", cmdtext, true, 8) == 0)
SendClientMessage(playerid,0x33AA33AA,"Founder/Developer: Hand-Scripter");
if(!strcmp(cmdtext, "/me", true, 3))
{
if(!cmdtext[3])return SendClientMessage(playerid, 0xFFC0CBFF, "USAGE: /me [Action]");
new str[128];
GetPlayerName(playerid, str, sizeof(str));
format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
SendClientMessageToAll(0xFFC0CBFF, str);
return 1;
}
return 0;
}
Errors:
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(101) : warning 217: loose indentation
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(117) : warning 217: loose indentation
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(117) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(117) : error 004: function "OnPlayerEnterVehicle" is not implemented
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(122) : warning 225: unreachable code
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(122) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(122) : error 004: function "OnPlayerExitVehicle" is not implemented
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(127) : warning 225: unreachable code
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(127) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(127) : error 004: function "OnPlayerStateChange" is not implemented
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(132) : warning 225: unreachable code
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(132) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(132) : error 004: function "OnPlayerEnterCheckpoint" is not implemented
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(137) : warning 225: unreachable code
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(137) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(137) : error 004: function "OnPlayerLeaveCheckpoint" is not implemented
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(142) : warning 225: unreachable code
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(142) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(142) : error 004: function "OnPlayerEnterRaceCheckpoint" is not implemented
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(147) : warning 225: unreachable code
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(147) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(147) : error 004: function "OnPlayerLeaveRaceCheckpoint" is not implemented
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(152) : warning 225: unreachable code
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(152) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(152) : error 004: function "OnRconCommand" is not implemented
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(157) : warning 225: unreachable code
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(157) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(157) : error 004: function "OnPlayerRequestSpawn" is not implemented
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(162) : warning 225: unreachable code
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(162) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(162) : error 004: function "OnObjectMoved" is not implemented
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(167) : warning 225: unreachable code
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(167) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(167) : error 004: function "OnPlayerObjectMoved" is not implemented
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(172) : warning 225: unreachable code
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(172) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(172) : error 004: function "OnPlayerPickUpPickup" is not implemented
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(177) : warning 225: unreachable code
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(177) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(177) : error 004: function "OnVehicleMod" is not implemented
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
26 Errors.
Re: /me command -
ShOoBy - 02.03.2012
Hey Hand

I have a little advice for you , you should learn about strcmp
The command /me and further explanation about strcmp can be found here :
https://sampwiki.blast.hk/wiki/Using_strcmp() . Good Luck!
- ShOoBy
Re: /me command -
Twisted_Insane - 02.03.2012
Glad to help you!
When you'll become advanced in scripting, people will start to like your way of working and will give you reputation! That's why you should keep it up!
Better switch to ZCMD + sccanf2!
Re: /me command -
Hand-Scripter - 02.03.2012
Quote:
Originally Posted by Twisted_Insane
Glad to help you!
When you'll become advanced in scripting, people will start to like your way of working and will give you reputation! That's why you should keep it up!
Better switch to ZCMD + sccanf2!
|
Thanks, About the ZCMD and sscanf2, I don't understand thing about that, Even don't know where to install it, Please read my errors above Sho0by, Would be appriciated.
Re: /me command -
ShOoBy - 02.03.2012
About those ERRORS , here is the good code:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/rules", cmdtext, true, 6) == 0)
{
SendClientMessage(playerid,0x33AA33AA,"This is a RolePlay Server, We want you to RP the best you can!");
SendClientMessage(playerid,0x33AA33AA,"Cheating is strict forbidden, Doing it can lead to ban!");
SendClientMessage(playerid,0x33AA33AA,"Do not Spam/Provoke, Doing it can lead to punishment!");
SendClientMessage(playerid,0x33AA33AA,"Always Respect/Listen the Admins, They are here to help you!");
}
if (strcmp("/credits", cmdtext, true, 8) == 0)
{
SendClientMessage(playerid,0x33AA33AA,"Founder/Developer: Hand-Scripter");
}
if(!strcmp(cmdtext, "/me", true, 3))
{
if(!cmdtext[3])return SendClientMessage(playerid, 0xFFC0CBFF, "USAGE: /me [Action]");
new str[128];
GetPlayerName(playerid, str, sizeof(str));
format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
SendClientMessageToAll(0xFFC0CBFF, str);
return 1;
}
return 0;
}
Re: /me command -
Walsh - 02.03.2012
Quote:
Originally Posted by Twisted_Insane
Hey, I just made one for you!  Change the colour if you want:
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]); SendClientMessageToAll(0xFFFF00AA, str); return 1; } return 0; }
Hope I could help! 
|
This sends the message to all the player's online. This is not what he wants, he only wants it for people near the person.
Colors
pawn Код:
#define COLOR_LIGHTGRAY 0xD3D3D3FF
#define RP_CHATS 0xBE9BC1FF
Add this on top of your script.
pawn Код:
stock ProxDetector(Float:radi, playerid, string[],color)
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
foreach(Player,i)
{
if(!IsPlayerConnected(i))continue;
if(IsPlayerInRangeOfPoint(i,radi,x,y,z)) SendClientMessage(i,color,string);
}
}
Now this is the /me command. It works better than TwistedInsane's because it only sends the /me message to players who are near.
pawn Код:
CMD:me(playerid, params[])
{
new name[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, name, sizeof(name));
strreplace(name,'_',' ');
if(sscanf(params,"s[128]",str)) return SendClientMessage(playerid,COLOR_LIGHTGRAY,"USAGE: /me [action]");
format(str,sizeof(str),"*%s %s",name, params);
ProxDetector(30.0, playerid, str, RP_CHATS);
return 1;
}
Almost forgot add this string replacer to replace the _ in a RP name to the top of your script as well.
pawn Код:
stock strreplace(string[], find, replace)
{
for(new i=0; string[i]; i++) {
if(string[i] == find) {
string[i] = replace;
}
}
}