PDA

View Full Version : Simple RP script issue


nmader
21/11/2011, 05:29 AM
Alright, so I got a bit of help, originally this was a Wiki /me script, but I edited it to what I thought would work:

Should look somewhat like this IG. Eating ((Nathan Mader)) when I type /do, but instead it has been looking like: [b]/do Eating ((an_Mader))


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))", cmdtext, str[4]);
SendClientMessageToAll(0xC2A2DAAA, str);
return 1;
}

So, if someone could help me, it would be greatly appreciated, thank you all!

Calgon
21/11/2011, 05:35 AM
format(str, sizeof(str), "%s ((%s))", cmdtext[3], str);

Remove the '[4]', that's to get the number of characters in to a string and onwards. And add the '[3]'.

Also, the wiki isn't wikipedia.

nmader
21/11/2011, 05:37 AM
format(str, sizeof(str), "%s ((%s))", cmdtext, str);

Remove the '[4]', that's to get the number of characters in to a string and onwards.

Also, the wiki isn't wikipedia.

I will try it now

Whatever, same thing to me... edited it anyways :D

Camacorn
21/11/2011, 05:38 AM
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, 25);
format(str, sizeof(str), "%s ((%s))", cmdtext, str);
SendClientMessageToAll(0xC2A2DAAA, str);
return 1;
}

Try this.

- Camacorn

nmader
21/11/2011, 05:43 AM
Thank you both, you have progressed it, yet it still shows /do in front of what I want.

I.E. /do Eats ((Nathan_Mader)) it adds the /do to what I type.

Jack_Leslie
21/11/2011, 05:45 AM
EDIT:

It's saying /do because "/do" is apart of cmdtext.

Replace cmdtext with result.

Add this above all your coding:

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, "{CC1100}USAGE: {FFFFFF} /do [local chat]");
return 1;
}