PDA

View Full Version : [Help] RP commands /me /do


dovys11
24/06/2010, 08:33 AM
How to do these RP commands (/me /do)?

And an example scrip please :roll:

Thanks

TouR
24/06/2010, 08:36 AM
me:

if(strcmp(cmd, "/me", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
return 1;
}
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;
}
if(PlayerInfo[playerid][pMaskuse] == 1)
{
format(string, sizeof(string), "* Stranger %s", result);
}
else
{
format(string, sizeof(string), "* %s %s", sendername, result);
}
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
printf("%s", string);
}
return 1;
}


do:

if(strcmp(cmd, "/do", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
return 1;
}
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: /do [action]");
return 1;
}
if(PlayerInfo[playerid][pMaskuse] == 1)
{
format(string, sizeof(string), "* %s (( Stranger ))", result);
}
else
{
format(string, sizeof(string), "* %s (( %s ))", result, sendername);
}
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
printf("%s", string);
}
return 1;
}

Amine_Mejrhirrou
23/01/2011, 03:03 PM
:o 4 errors ...

Not available
23/01/2011, 03:06 PM
My eyes hurts when I see commands like that. This is an optional way using sscanf and ZCMD.


COMMAND:me(playerid, params[])
{
new text[128], string[128];
if(sscanf(params, "s[127]", text)) return SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /me [action]");
format(string, sizeof(string), "** %s %s", RemoveUnderScore(playerid), text);
NewProx(playerid, 0xC688D4AA, string, 30.0);
return 1;
}
COMMAND:do(playerid, params[])
{
new text[128], string[128];
if(sscanf(params, "s[127]", text)) return SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /do [action]");
format(string, sizeof(string), "** %s (( %s ))", text, RemoveUnderScore(playerid));
NewProx(playerid, 0xC688D4AA, string, 30.0);
return 1;
}
// This is used to send the message only to nearby players.
stock NewProx(playerid, color, string[], Float:radi)
{
new Float:pposx, Float:pposy, Float:pposz;
new Float:oldpposx, Float:oldpposy, Float:oldpposz;
new Float:temppposx, Float:temppposy, Float:temppposz;

GetPlayerPos(playerid, oldpposx, oldpposy, oldpposz);

for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
{
GetPlayerPos(i, pposx, pposy, pposz);
temppposx = (oldpposx -pposx);
temppposy = (oldpposy -pposy);
temppposz = (oldpposz -pposz);
if (((temppposx < radi) && (temppposx > -radi)) && ((temppposy < radi) && (temppposy > -radi)) && ((temppposz < radi) && (temppposz > -radi)))
{
SendClientMessage(i, color, string);
}
}
}
return 1;
}
// This will save you a lot of code, formats a "rp name" out of a playerid.
stock RemoveUnderScore(playerid)
{
new namewithoutunderscorename[MAX_PLAYER_NAME];
GetPlayerName(playerid,namewithoutunderscorename,s izeof(namewithoutunderscorename));
for(new i = 0; i < MAX_PLAYER_NAME; i++)
{
if(namewithoutunderscorename[i] == '_') namewithoutunderscorename[i] = ' ';
}
return namewithoutunderscorename;
}

Amine_Mejrhirrou
23/01/2011, 07:55 PM
... but ... i must creat a FS for that !! no?

Elviss
23/01/2011, 08:04 PM
//----------------------------------[ME]-----------------------------------------------
if(strcmp(cmd, "/me", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
return 1;
}
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;
}
if(PlayerInfo[playerid][pMaskuse] == 1)
{
format(string, sizeof(string), "* Stranger %s", result);
}
else
{
format(string, sizeof(string), "* %s %s", sendername, result);
}
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
printf("%s", string);
}
return 1;
}

//----------------------------------[Do]-----------------------------------------------
if(strcmp(cmd, "/do", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
return 1;
}
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: /do [action]");
return 1;
}
if(PlayerInfo[playerid][pMaskuse] == 1)
{
format(string, sizeof(string), "* %s (( Stranger ))", result);
}
else
{
format(string, sizeof(string), "* %s (( %s ))", result, sendername);
}
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPL E,COLOR_PURPLE);
printf("%s", string);
}
return 1;
}

Try this and to you have error reply this here :)

bestr32
03/04/2011, 05:26 PM
Why long /me? Use:
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;
}

bestr32
03/04/2011, 05:28 PM
same for do just:
if(!strcmp(cmdtext, "/do", true, 3)) // 3 is the length of /me
{
if(!cmdtext[3])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /do [action]");
new str[128];
GetPlayerName(playerid, str, sizeof(str));
format(str, sizeof(str), "* %s (( %s ))", str, cmdtext[4]);
SendClientMessageToAll(0xFFFF00AA, str);
return 1;
}

Luis-
03/04/2011, 05:29 PM
The long one's are used in GM's like PR-RP, Pen-LS, Godfather and so on.

Mean
03/04/2011, 05:34 PM
CMD:me( playerid, params[ ] ) {
new string[ 128 ], pName[ 24 ]; GetPlayerName( playerid, pName, 24 );
format( string, sizeof string, "%s %s", pName, params ); return SendClientMessageToAll( 0xAAAAAA, string ); // change the color
}

RoBy41
17/12/2012, 07:02 PM
CMD:me( playerid, params[ ] ) {
new string[ 128 ], pName[ 24 ]; GetPlayerName( playerid, pName, 24 );
format( string, sizeof string, "%s %s", pName, params ); return SendClientMessageToAll( 0xAAAAAA, string ); // change the color
}Thanks, can you post /do command as example for this please ?

Chanishyy
17/02/2013, 11:50 AM
They is 4 errors for the filterscripts of /me and /do

iManakoss
17/02/2013, 01:07 PM
stock NAMEGET(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
for(new i = 0; i < MAX_PLAYER_NAME; i++)
{
if(name[i] == '_') name[i] = ' ';
}
return name;
}
CMD:me(playerid, params[])
{
new textv2[128];
if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /me [action]");
format(textv2, sizeof(textv2), "* %s %s", NAMEGET(playerid), params);
NearMessageSender(playerid, 6, textv2, COLOR_BLUELIGHT1,COLOR_BLUELIGHT2,COLOR_BLUELIGHT3 ,COLOR_BLUELIGHT4,COLOR_BLUELIGHT5);
return 1;
}
CMD:do(playerid, params[])
{
new string[128], action[100], name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
if(sscanf(params, "s[100]", action))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /do [ACTION]");

return 1;
}
else
{
format(string, sizeof(string), "* %s (( %s ))", action,name);
ProxDetector(30, playerid, string, COLOR_BLUELIGHT1,COLOR_BLUELIGHT2,COLOR_BLUELIGHT3 ,COLOR_BLUELIGHT4,COLOR_BLUELIGHT5);
}
return 1;
}
stock NearMessageSender(playerid, Float:radius, string[], col1, col2, col3, col4, col5)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
new Float:ix, Float:iy, Float:iz;
new Float:cx, Float:cy, Float:cz;
foreach(Player, i)
{
if(GetPlayerInterior(playerid) == GetPlayerInterior(i) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
{
GetPlayerPos(i, ix, iy, iz);
cx = (x - ix);
cy = (y - iy);
cz = (z - iz);
if(((cx < radius/16) && (cx > -radius/16)) && ((cy < radius/16) && (cy > -radius/16)) && ((cz < radius/16) && (cz > -radius/16)))
{
SendClientMessage(i, col1, string);
}
else if(((cx < radius/8) && (cx > -radius/8)) && ((cy < radius/8) && (cy > -radius/8)) && ((cz < radius/8) && (cz > -radius/8)))
{
SendClientMessage(i, col2, string);
}
else if(((cx < radius/4) && (cx > -radius/4)) && ((cy < radius/4) && (cy > -radius/4)) && ((cz < radius/4) && (cz > -radius/4)))
{
SendClientMessage(i, col3, string);
}
else if(((cx < radius/2) && (cx > -radius/2)) && ((cy < radius/2) && (cy > -radius/2)) && ((cz < radius/2) && (cz > -radius/2)))
{
SendClientMessage(i, col4, string);
}
else if(((cx < radius) && (cx > -radius)) && ((cy < radius) && (cy > -radius)) && ((cz < radius) && (cz > -radius)))
{
SendClientMessage(i, col5, string);
}
}
}
return 1;
}
forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);

public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
{
if(IsPlayerConnected(playerid))
{
new Float:posx, Float:posy, Float:posz;
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
//radi = 2.0; //Trigger Radius
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
{
GetPlayerPos(i, posx, posy, posz);
tempposx = (oldposx -posx);
tempposy = (oldposy -posy);
tempposz = (oldposz -posz);
//printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
{
SendClientMessage(i, col1, string);
}
else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
{
SendClientMessage(i, col2, string);
}
else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
{
SendClientMessage(i, col3, string);
}
else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
{
SendClientMessage(i, col4, string);
}
else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
SendClientMessage(i, col5, string);
}
}
else
{
SendClientMessage(i, col1, string);
}
}
}//not connected
return 1;
}

You need ZCMD