PDA

View Full Version : /me command


Hand-Scripter
02/03/2012, 08:57 AM
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.

Twisted_Insane
02/03/2012, 08:59 AM
Hey, I just made one for you!:D Change the colour if you want:


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!:D

Hand-Scripter
02/03/2012, 09:02 AM
Thanks alot, Youve helped me lol, everyone have the /me as pink, You know the pink code?

Twisted_Insane
02/03/2012, 09:06 AM
http://forum.sa-mp.com/showthread.php?t=157789

Simply replace "0xFFFF00AA" with the colour you want!

Hand-Scripter
02/03/2012, 09:10 AM
Damn, Thanks alot.

EDIT: I got 26 errors, I have multiple commands;

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 (c) 1997-2006, ITB CompuPhase


26 Errors.

ShOoBy
02/03/2012, 09:10 AM
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 : http://wiki.sa-mp.com/wiki/Using_strcmp() . Good Luck!
- ShOoBy

Twisted_Insane
02/03/2012, 09:11 AM
Glad to help you!:D

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!:D

Better switch to ZCMD + sccanf2!

Hand-Scripter
02/03/2012, 09:19 AM
Glad to help you!:D

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!:D

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.

ShOoBy
02/03/2012, 09:21 AM
About those ERRORS , here is the good code:

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;
}

Hand-Scripter
02/03/2012, 09:39 AM
5 errors:

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 strictly forbidden, Doing it can lead to ban!");
SendClientMessage(playerid,0x33AA33AA,"Do not Spam/Provoke, Doing that can lead to punishment!");
SendClientMessage(playerid,0x33AA33AA,"Always Respect/Listen Admins, They are here to help you!");
}
if (strcmp("/credits", cmdtext, true, 8) == 0)
{
SendClientMessage(playerid,0x33AA33AA,"Founder/Developer: Hand-Scripter");
}
if (strcmp("/me", true, 3))
{
if(!cmtext,[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(105) : error 035: argument type mismatch (argument 2)
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(107) : error 017: undefined symbol "cmtext"
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(107) : warning 215: expression has no effect
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(107) : error 001: expected token: ";", but found "]"
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(107) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\pawno\Tierra Robada Roleplay1.pwn(107) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


5 Errors.

Walsh
02/03/2012, 12:26 PM
Hey, I just made one for you!:D Change the colour if you want:


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!:D


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
#define COLOR_LIGHTGRAY 0xD3D3D3FF
#define RP_CHATS 0xBE9BC1FF

Add this on top of your script.
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.

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.
stock strreplace(string[], find, replace)
{
for(new i=0; string[i]; i++) {
if(string[i] == find) {
string[i] = replace;
}
}
}

Hand-Scripter
02/03/2012, 05:31 PM
Thank you, But I don't habe ProxDetector installed, Does that matter?

Chrillzen
02/03/2012, 05:33 PM
Just put this somewhere int he script, yes you need proxdetector.

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);
}
}

Hand-Scripter
02/03/2012, 06:07 PM
Thank you but Walsh hes explanation takes me more far than yours (no offense)

Anyway, I've searched for ProxDetector but couldn't find the download page..

Mike_Peterson
02/03/2012, 06:35 PM
Am I the only one seeing that Chrillzen posted the ProxDetector function here?


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);
}
}

Walsh
02/03/2012, 09:21 PM
The ProxDetector function is in my post.....

Grant.
03/03/2012, 02:57 AM
Hit up the SA:MP wiki For some tutorials and such. it helps out ALOT!

Dirtybit36
28/05/2013, 05:05 PM
Try this one

if(strcmp(cmd, "/me", true) == 0)
{
new length=strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[128];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_ERROR, "Syntax: /me (action)");
return 1;
}
new msg[156];
format(msg,sizeof(msg),"* %s(%d) %s *", PlayerName(playerid),playerid,result);
SendClientMessageToAll(COLOR_WHITE, msg);
return 1;
}

Guest123
29/05/2013, 01:08 AM
use this


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 strictly forbidden, Doing it can lead to ban!");
SendClientMessage(playerid,0x33AA33AA,"Do not Spam/Provoke, Doing that can lead to punishment!");
SendClientMessage(playerid,0x33AA33AA,"Always Respect/Listen 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)) // 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;
}