SA-MP Forums Archive
Need help with coding - 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: Need help with coding (/showthread.php?tid=82932)



Need help with coding - Elorreli - 21.06.2009

Allright, so i'm editing my /o cmd. ( Mainchat in RP.)

I'm using this code

Код:
format(string, sizeof(string), "[MC] %s: %s " , sendername, result);
OOCOff(FBI_COLOR,string);
printf("%s", string);
Is it possible to make the [MC] Player_Name: In one color, and the printf in another color?
Thanks,

//HeHu


Re: Need help with coding - MadeMan - 21.06.2009

printf will show a message in server console not in game


Re: Need help with coding - Elorreli - 21.06.2009

Quote:
Originally Posted by MadeMan
printf will show a message in server console not in game
Well, that /o CMD is working anyway, the thing i asked for if it was possible to make two seperate colors, one for the text that is printed and one for the [MC] name:


Re: Need help with coding - Correlli - 21.06.2009

Text printed in console is always white. But there is a plugin for other colors -> http://forum.sa-mp.com/index.php?topic=84654.0


Re: Need help with coding - Elorreli - 21.06.2009

Allright, theres the whole code, i'm having one color on the Mainchat.

[MC] Player_Name: It can look this way

[MC] Player_Name: But i want it this way

Код:
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: (/o)oc [ooc chat]");
				return 1;
			}
			if(PlayerInfo[playerid][pMember] == 1||PlayerInfo[playerid][pLeader] == 1)
      {
			format(string, sizeof(string), "[MC] %s: %s " , sendername, result);
      OOCOff(LSPD_MAINCHAT,string);
			printf("%s", string);
			}



Re: Need help with coding - [nl]daplayer - 21.06.2009

use SendPlayerMessageToAll

You mean that?

Wiki reference: https://sampwiki.blast.hk/wiki/SendPlayerMessageToAll


Re: Need help with coding - Elorreli - 21.06.2009

Nono! I want the [MC] Player_Name: in one color

And the the text "/o text" In another color, is that possible?


Re: Need help with coding - Joe Staff - 21.06.2009

Link in my signature, Better ID with Text, just change the format string to what you want.


Re: Need help with coding - Elorreli - 21.06.2009

I saw your example, i can't find the color for orange, as the "Player_Name"

Код:
public OnPlayerText(playerid,text[])
{
	new string[2][MAX_PLAYER_NAME];
	GetPlayerName(playerid,string[0],sizeof(string[]));
	GetPlayerName(playerid,string[1],sizeof(string[]));
	format(string[0],sizeof(string[]),"[%d]%s",playerid,string[0]);
	SetPlayerName(playerid,string[0]);
	SendPlayerMessageToAll(playerid,text);
	SetPlayerName(playerid,string[1]);
	return 0;
}



Re: Need help with coding - [nl]daplayer - 21.06.2009

Quote:
Originally Posted by hehu
I saw your example, i can't find the color for orange, as the "Player_Name"

Код:
public OnPlayerText(playerid,text[])
{
	new string[2][MAX_PLAYER_NAME];
	GetPlayerName(playerid,string[0],sizeof(string[]));
	GetPlayerName(playerid,string[1],sizeof(string[]));
	format(string[0],sizeof(string[]),"[%d]%s",playerid,string[0]);
	SetPlayerName(playerid,string[0]);
	SendPlayerMessageToAll(playerid,text);
	SetPlayerName(playerid,string[1]);
	return 0;
}
Text color is white and player name color is color of SetPlayerColor