[Tutorial] Making New Chat
#1

Hi
This is my first tutorial

Make New chat:

This is really easy
First put this at the top of your script:
pawn Код:
#include <a_samp>
then add this above OnGameModeInit()
pawn Код:
new NewChat;
now put this OnGameModeInit()
pawn Код:
public OnGameModeInit()
{

    NewChat = 1; // this will active new chat

    return 1;
}
now go to OnPlayerText and add this:
pawn Код:
public OnPlayerText(playerid,text[])
{
    if(NewChat == 1) // if chat is actived
    {
        new pName[MAX_PLAYER_NAME],str[128];
        GetPlayerName(playerid,pName,sizeof(pName)); // getting player name
        format(str,sizeof(str),"** %s (%d) :(( %s ))",pName,playerid,text); // i hope you know how to use this 'format'
        SendClientMessageToAll(0xFFFFFFFF,str); // sends message to all players , you can change colors
        return 0;
    }
    return 1;
}
Ok and thats all , new chat is done.

you can make a chat versions like this :
pawn Код:
format(str,sizeof(str),"%s says : %s ",pName,text); // in this format chat will be like this example '' Patomaxx says : Whats up''
pawn Код:
format(str,sizeof(str),"%s (( %s )) ",text,pName); //  example ''Whats up (( Patomaxx ))''
pawn Код:
format(str,sizeof(str),"** (%d) Says: %s ",playerid,text); //  example ''(16) Says: Whats up''
Also you can edit colors to make it better:
pawn Код:
format(str,sizeof(str),"{ffffff} %s Says : {ff0000}%s",pName,text); //  Player name will be white color and his text will be red color
This {ff0000} are hex colors which you can find here
Reply
#2

How do you make it so that you need a character to make it? so its like !Talk here

Other than that its a great tut dude
Reply
#3

try use your own stock to get player name. its better that creating new 2 lines btw tut is nice
Reply
#4

How do you make it so that you have to be set to the chat to see the chat ?
Reply
#5

Quote:
Originally Posted by ylleron
Посмотреть сообщение
try use your own stock to get player name. its better that creating new 2 lines btw tut is nice
No it's not, only thing that is better is less typing, which is lazy in my opinion.
Reply
#6

Quote:
Originally Posted by Jack-
Посмотреть сообщение
How do you make it so that you have to be set to the chat to see the chat ?
what do you mean ??
Reply
#7

Quote:
Originally Posted by Mean
Посмотреть сообщение
No it's not, only thing that is better is less typing, which is lazy in my opinion.
Yes, it is. How does a stock which returns the player his name is not better than writing it each time when you have this stock using one variable of MAX_PLAYER_NAME. Better and faster, it has nothing to do with lazy... it's just better.

By the way, this tutorial is nice but you could have explained better since newbies will always get this wrong.
Thank you.
Reply
#8

Quote:
Originally Posted by Toreno
Посмотреть сообщение
Yes, it is. How does a stock which returns the player his name is not better than writing it each time when you have this stock using one variable of MAX_PLAYER_NAME. Better and faster, it has nothing to do with lazy... it's just better.

By the way, this tutorial is nice but you could have explained better since newbies will always get this wrong.
Thank you.
No it's not better as it has no speed difference. It is not faster at all, in fact calling a stock each time might be slower, but I've never tried it.

It's just shorter, storing player name into a variable on connect is the best and the most efficient.
Reply
#9

Quote:
Originally Posted by Mean
Посмотреть сообщение
No it's not better as it has no speed difference. It is not faster at all, in fact calling a stock each time might be slower, but I've never tried it.

It's just shorter, storing player name into a variable on connect is the best and the most efficient.
I was bored, so I thought I might test that. Calling the stock is about 1/6th slower than just doing it normal. I did a test with a 10000000 (One million) loop and the results were

Код:
Stock 596, Normal: 441
For the test that I used, check HERE.
Reply
#10

Told ya!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)