03.08.2011, 17:27
(
Последний раз редактировалось sleepysnowflake; 04.08.2011 в 19:20.
Причина: Update
)
Chat colour changer
Intro
Ladies and gentleman I present to you the Chat Color Changer!
With this little filterscript you can change the colour of the name and the text in chat!
Commands
The only command there is: /ccol or /chatcolour.
It will bring a dialog in where you will first choose the colour of your name and after that one the colour of your text.
Credits
Carrot a.k.a. Berlovan for making this,
****** for his Y_ini,
SA:MP team for making this great game;
Changelog
Download
(It is a small script. Only 116 lines.) Now 152!
Intro
Ladies and gentleman I present to you the Chat Color Changer!
With this little filterscript you can change the colour of the name and the text in chat!
Commands
The only command there is: /ccol or /chatcolour.
It will bring a dialog in where you will first choose the colour of your name and after that one the colour of your text.
Credits
Carrot a.k.a. Berlovan for making this,
****** for his Y_ini,
SA:MP team for making this great game;
Changelog
pawn Код:
// ============================ [ Changelog ] ============================
//
// ------------------------------ [ v 1.0 ] ------------------------------
// ~ Initial Release.
// ------------------------------ [ v 1.1 ] ------------------------------
// ~ Added file saving with y_ini. The colours save when player disconnects.
(It is a small script. Only 116 lines.) Now 152!
pawn Код:
// Chat Name Colour changer
// ~ by Carrot
#include <a_samp>
#include <YSI\y_ini>
/*
Za Colors.
{33CC00}Green
{FF0000} Red
{FFCC00} Orange
*/
enum Col
{
pChat[9],
pNameCol[9]
}
new Colour[MAX_PLAYERS][Col];
forward LoadCol_data(playerid,name[],value[]);
public LoadCol_data(playerid,name[],value[])
{
INI_Int("Name Colour", Colour[playerid][pNameCol]);
INI_Int("Chat Colour", Colour[playerid][pChat]);
return 1;
}
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Chat colour changer by Carrot loaded.");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
print("\n--------------------------------------");
print(" Chat colour changer by Carrot unloaded.");
print("--------------------------------------\n");
return 1;
}
public OnPlayerConnect(playerid)
{
if(fexist(WhereTo(playerid)))
{
INI_ParseFile(WhereTo(playerid), "LoadCol_%s", .bExtra = true, .extra = playerid);
}
else
{
Colour[playerid][pNameCol] = "{99DDEE}";
Colour[playerid][pChat] = "{FFFFFF}";
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new string[128];
if(dialogid == 1)
{
if(response)
{
if(listitem == 0)
{
Colour[playerid][pNameCol] = "{33CC00}";
}
if(listitem == 1)
{
Colour[playerid][pNameCol] = "{FF0000}";
}
if(listitem == 2)
{
Colour[playerid][pNameCol] = "{FFCC00}";
}
format(string,sizeof(string),"{FFFFFF}Your chat name colour has changed to %sThis{FFFFFF}.\nChoose the color for your text now.",Colour[playerid][pNameCol]);
ShowPlayerDialog(playerid,2,DIALOG_STYLE_MSGBOX,"Congratz",string,"Next","");
}
}
if(dialogid == 2)
{
if(response)
{
ShowPlayerDialog(playerid,3,DIALOG_STYLE_LIST,"{FFCC00}Choose the colour for your text.","{33CC00}Green\r\n{FF0000}Red\r\n{FFCC00}Orange","Okay", "Not okay");
}
}
if(dialogid == 3)
{
if(listitem == 0)
{
Colour[playerid][pChat] = "{33CC00}";
}
if(listitem == 1)
{
Colour[playerid][pChat] = "{FF0000}";
}
if(listitem == 2)
{
Colour[playerid][pChat] = "{FFCC00}";
}
format(string,sizeof(string),"{FFFFFF}Your chat text colour has changed to %sThis.",Colour[playerid][pChat]);
ShowPlayerDialog(playerid,4,DIALOG_STYLE_MSGBOX,"Congratz",string,"Finish","");
}
return 1;
}
public OnPlayerText(playerid, text[])
{
new
pName[24],
string [256]
;
GetPlayerName(playerid,pName,sizeof(pName));
format(string,sizeof(string),"%s%s(%d): %s%s",Colour[playerid][pNameCol],pName,playerid,Colour[playerid][pChat],text[0]);
// print(string); // For debugging.
SendClientMessageToAll(Colour[playerid][pNameCol],string);
return 0;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/chatcolour", cmdtext, true) == 0 || strcmp("/ccol", cmdtext, true) == 0)
{
ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"{FFCC00}Choose the colour for your name.","{33CC00}Green\r\n{FF0000}Red\r\n{FFCC00}Orange","Okay", "Not okay");
return 1;
}
return 0;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:ColFile = INI_Open(WhereTo(playerid));
INI_SetTag(ColFile,"Colours");
INI_WriteString(ColFile, "Name Colour", Colour[playerid][pNameCol]);
INI_WriteString(ColFile, "Chat Colour", Colour[playerid][pChat]);
INI_Close(ColFile);
return 1;
}
stock WhereTo(playerid)
{
new string[128],
pName[24];
GetPlayerName(playerid,pName,sizeof(pName));
format(string,sizeof(string),"/Colours/%s.ini",pName);
return string;
}
}