As most of us know, the original chat in vcmp only supports English letters. So, I have created this custom chat system in order to use Turkish letters. It is also possible to bring support for different languages by changing the font file.
SERVER SIDE
[noae][noae][noae][noae][noae][noae][noae]
CLIENT SIDE
[noae][noae]
You need add fonts folder to store.
New Chat Key Is -> "Y"
Preview:
Good luck...
SERVER SIDE
[noae][noae][noae][noae][noae][noae][noae]
Code Select
function onClientScriptData( player ) {
local int=Stream.ReadInt(), str=Stream.ReadString();
local aColour = player.Colour, pcolor = format("[#%02X%02X%02X]", aColour.r, aColour.g, aColour.b);
if(int==2022){for(local i = 0; i<100; i++){SendDataToClient(i, 2022, pcolor.tolower()+player.Name+": [#ffffff]"+str);}}
}
function SendDataToClient(p,i,s){
p=FindPlayer(p);
if(p){
Stream.StartWrite();Stream.WriteInt(i);
}
if(s!=null){
Stream.WriteString(s);
}
Stream.SendStream(p);
}
[/noae][/noae][/noae][/noae][/noae][/noae][/noae]CLIENT SIDE
[noae][noae]
Code Select
// =================== Credits Goes To ysc3839 for Client Timer ==============================
function Script::ScriptProcess(){
Timer.Process();
}
Timer <- {
Timers = {}
function Create(environment, listener, interval, repeat, ...)
{
// Prepare the arguments pack
vargv.insert(0, environment);
// Store timer information into a table
local TimerInfo = {
Environment = environment,
Listener = listener,
Interval = interval,
Repeat = repeat,
Args = vargv,
LastCall = Script.GetTicks(),
CallCount = 0
};
local hash = split(TimerInfo.tostring(), ":")[1].slice(3, -1).tointeger(16);
// Store the timer information
Timers.rawset(hash, TimerInfo);
// Return the hash that identifies this timer
return hash;
}
function Destroy(hash)
{
// See if the specified timer exists
if (Timers.rawin(hash))
{
// Remove the timer information
Timers.rawdelete(hash);
}
}
function Exists(hash)
{
// See if the specified timer exists
return Timers.rawin(hash);
}
function Fetch(hash)
{
// Return the timer information
return Timers.rawget(hash);
}
function Clear()
{
// Clear existing timers
Timers.clear();
}
function Process()
{
local CurrTime = Script.GetTicks();
foreach (hash, tm in Timers)
{
if (tm != null)
{
if (CurrTime - tm.LastCall >= tm.Interval)
{
tm.CallCount++;
tm.LastCall = CurrTime;
tm.Listener.pacall(tm.Args);
if (tm.Repeat != 0 && tm.CallCount >= tm.Repeat)
Timers.rawdelete(hash);
}
}
}
}
};
// ============================================================================================
local sX = GUI.GetScreenSize().X,sY = GUI.GetScreenSize().Y;
chatbox <-{Box = null EditBox = null}
function Script::ScriptLoad(){
createChatBox();
}
function Server::ServerData( stream ){
local readint=stream.ReadInt( ),readstr=stream.ReadString( );
switch(readint.tointeger()){
case 2022: chatProcess(readstr); break;
}
}
function GUI::InputReturn( editbox ){
if (editbox == chatbox.EditBox){
if (chatbox.EditBox.Text == "" || chatbox.EditBox.Text == " " || chatbox.EditBox.Text == " " ){
chatbox.EditBox = null;
}else{
if (chatbox.EditBox.Text.len() < 97){
SendDataToServer(chatbox.EditBox.Text, 2022);
}chatbox.EditBox = null;
}
}
}
chat_key <- KeyBind( 0x59 );
function KeyBind::OnDown(key){
if (key == chat_key){
if(!chatbox.EditBox){
createChatEditBox();
}
}
}
function VScreen(pos_x, pos_y){//Credits goes to Doom_Kill3R for this function
local
screenSize = GUI.GetScreenSize( ),
x = floor( pos_x * screenSize.X / 1920 ),
y = floor( pos_y * screenSize.Y / 1080 );
return VectorScreen( x, y );
}
function SendDataToServer(s, i){local msg=Stream();msg.WriteInt(i.tointeger());msg.WriteString(s);Server.SendData(msg);}
function createChatBox(){
chatbox.Box = GUIMemobox(VScreen( 10 , 25 ), VScreen(1000, 400), Colour(0, 0, 0, 255), GUI_FLAG_MEMOBOX_TOPBOTTOM | GUI_FLAG_VISIBLE | GUI_FLAG_TEXT_TAGS);
chatbox.Box.RemoveFlags( GUI_FLAG_BACKGROUND | GUI_FLAG_BORDER );
chatbox.Box.FontSize = floor( 17 * GUI.GetScreenSize( ).Y / 1080 );
chatbox.Box.FontName = "TR Tahoma Bold"
chatbox.Box.FontFlags = GUI_FFLAG_OUTLINE;
chatbox.Box.LineHeight = 0;
}
function createChatEditBox(){
chatbox.EditBox = GUIEditbox(VScreen( 15, 370 ), VScreen( 900, 30 ), Colour(0, 0, 0, 255), GUI_FLAG_TEXT_TAGS);
chatbox.EditBox.FontSize = floor( 17 * GUI.GetScreenSize( ).Y / 1080 );
chatbox.EditBox.TextColour = Colour(255, 255, 255, 255);
chatbox.EditBox.FontName = "TR Tahoma Bold"
chatbox.EditBox.FontFlags = GUI_FFLAG_OUTLINE;
chatbox.EditBox.RemoveFlags( GUI_FLAG_BACKGROUND | GUI_FLAG_BORDER );
chatbox.EditBox.Text = "";
chatboxTimer <- Timer.Create(this, function(text, int) {
chatbox.EditBox.Text = "";
GUI.SetFocusedElement( chatbox.EditBox );
}, 45, 1, "Timer Text ", 12345);
}
chatTimer <- null;
maxChatLine <- 15;
function chatProcess(readstr){
if (chatbox.Box.LineHeight == 0){chatbox.Box.LineHeight = 1;}
chatbox.Box.AddLine(readstr, Colour(255, 255, 255, 255))
if(chatbox.Box.LineHeight < maxChatLine ){
chatbox.Box.LineHeight += 1;
}
chatTimerProcess();
}
function chatTimerProcess(){
Timer.Destroy( chatTimer );
chatTimer <- Timer.Create(this, function(text, int) {
if (chatbox.Box.LineHeight > 0 ){
chatbox.Box.LineHeight -=1;
}
chatbox.Box.DisplayPos = 0;
}, 10000, 0, "Timer Text ", 12345);
}
[/noae][/noae]You need add fonts folder to store.
New Chat Key Is -> "Y"
Preview:
Good luck...