/o help? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /o help? (
/showthread.php?tid=181853)
/o help? -
Luis- - 07.10.2010
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/o", cmdtext, true, 10) == 0)
{
if(!strlen(cmdtext)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /o [chat]");
new str[256];
GetPlayerName(playerid, str, sizeof(str));
format(str, sizeof(str), "%s: %s", str, cmdtext);
SendClientMessageToAll(COLOR_WHITE, str);
return 1;
}
return 0;
I have set up gTeam and I was wandering how to make it so when the player is on PD duty and he types, E.g Hello in /o his name would be
Luis_Foxx: Hello
Thanks
Re: /o help? -
miokie - 07.10.2010
You cannot use two seperate colours in 'SendClientMessageToAll'. Use 'SendPlayerMessageToAll'.
Re: /o help? -
Scenario - 07.10.2010
If you want somebody's chat color to be a particular color, then you need to use "
SetPlayerColor". So for you set their color to blue when they go on PD duty.
Re: /o help? -
Luis- - 07.10.2010
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp("/o", cmdtext, true, 2))
{
new str[128];
GetPlayerName(playerid, str, sizeof(str));
format(str, sizeof(str), "%s", cmdtext[2]);
SendPlayerMessageToAll(playerid, str);
return 1;
}
return 0;
}
Okay it works now but I want it to say this, "Usage: /o [Message]" if the Player only types /o?
Re: /o help? -
Mike_Peterson - 07.10.2010
use sscanf or strlen.. i'm not sure i mostly work with zcmd and dcmd
Re: /o help? -
Scenario - 07.10.2010
If I were you, I would consider using SSCANF(2) and ZCMD. This is the command using SSCANF(2), but not ZCMD.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp("/o", cmdtext, true, 2))
{
new message, string[128], sendername[24];
if(sscanf(params, "s[105]", message)) return SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /o [message]");
GetPlayerName(playerid, sendername, sizeof(sendername));
format(str, sizeof(str), "OOC %s: %s", sendername, message);
SendPlayerMessageToAll(playerid, str);
return 1;
}
return 0;
}
It should work for you.
EDIT: I am so used to working with ZCMD that the command I provided for you will not work with STRCMP. I'll see what I can do, as I don't use STRCMP. I would recommend that you use ZCMD and convert your STRCMP commands to ZCMD as "OnPlayerCommandText" will cause a compatibility issue.