[Tutorial] BotChat (Part 2)
#1

BotChat(2/3)




Welcome to the second tutorial of my BotChat...
U are Advised to Read MY first Tutorial on BotChat if u Want to Understand this Tutorial Completely [RECOMENDED for Learners with no knowledge of scripting] Here.
Though This is pretty Self Explanatory(u need basic scripting knowledge)




First I will Tell You the necessary Incudes and Defines for this

Code:
#include <a_samp>

#define COLOR_PINK         0xFF60FFFF
We will be using the include a_samp...
also i would be using a coulor pink with the color code "FF60FFFF" so i am defining it as COLOR_PINK

so We would be Building this Inside THe OnPlayerText Public Function
Code:
public OnPlayerText(playerid, text[])

Now Lets Do something Else....
How About we Make it Perticular and specify which person has said hey and then use his name in the output..




SO how do we do it?

First We need the name of the player who has said hey.......so we use the function GetPlayerName



first we define a new Local Variable "name" inside the if condition

Code:
if(!strfind(text,"Hey",true))
    {
             new name[24];
    }
Now lets use the GetPlayerName function and get the name of the person who has typed Hey




Code:
if(!strfind(text,"Hey",true))
    {
	  new name[24];
	  GetPlayerName(playerid,name,sizeof(name))
    }
Ahh We ot The Players name ....
Now We Shall Create a string of the Bot's response

First we Create a new Variable Named as "response"

Code:
if(!strfind(text,"Hey",true))
    {
	  new name[24];
	  GetPlayerName(playerid,name,sizeof(name))
                new response[120];
    }
Now lets feed a value to our response using the already defined Variable "Name"


Code:
if(!strfind(text,"Hey",true))
    {
	  new name[24];
	  GetPlayerName(playerid,name,sizeof(name))
                new response[120];
                format(response,sizeof(response),"BOT : HELLO %s",name);
    }
Now Lets send a message to all players


Code:
if(!strfind(text,"Hey",true))
    {
	  new name[24];
	  GetPlayerName(playerid,name,sizeof(name))
                new response[120];
                format(response,sizeof(response),"BOT : HELLO %s",name);
                SendClientMessageToAll(COLOR_PINK,response);
    }
Hope I Helped You
A Third Tutorial IS Out TOO in Which YOU Will Learn More On THIS.
Reply
#2

Why three parts you godamn post whore
Reply
#3

You're using "new response[120];" way to high.
"new response[12 + MAX_PLAYER_NAME];" will save you so much more memory.
Reply
#4

Quote:
Originally Posted by StegooPs
View Post
Why three parts you godamn post whore
its his way of making tutorials

On topic: Good job
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)