· 9 years ago · Feb 11, 2017, 12:22 PM
1/**
2 * Copyright (c) 2015-2016 YBot MySQL Mode
3 *
4 * This program is free software: you can Ristribute it and/or modify it under the terms of the
5 * GNU General Public License as published by the Free Software Foundation, either version 3 of the
6 * License, or (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
9 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with this program.
13 * If not, see <http://www.gnu.org/licenses/>.
14 */
15
16
17 /*AUTHOR **********************
18 * @Yassine - SA-MP Scripter *
19 *******************************/
20
21#include <a_samp>
22#include <a_mysql>
23#include <zcmd>
24#include <sscanf2>
25#include <irc>
26#include <mapandreas>
27
28#define MYSQL_HOST "localhost"
29#define MYSQL_DATABASE "testing"
30#define MYSQL_USER "ybot"
31#define MYSQL_PASSWORD ""
32
33#define YBot "YBot"
34
35#define FORUM "xxx.xxx.com"
36
37#define GRI "{C0C0C0}"
38#define R "{F81414}"
39#define W "{FFFFFF}"
40
41#define Major 1
42#define Minor 0
43
44#define IRCBot YBot
45#define IRCServer "pool.irc.tl"
46
47#define IRC_CHANNEL "#xxx.echo"
48
49#if !defined isnull
50 #define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
51#endif
52
53forward YBot_FetchData(playerid);
54forward YBot_Announces();
55forward YBot_OnlineCount(playerid);
56forward YBot_Reply(playerid, text[], replyid);
57forward OnPlayerAirbreak(playerid);
58forward BanPlayer(playerid, reason[]);
59forward KickPlayer(playerid, reason[]);
60forward AirBreak();
61forward SpawnProtection(playerid);
62
63new bool:Spawned[MAX_PLAYERS];
64
65new groupID = 1;
66new
67 bool:SEEN_SYSTEM = true, // that enable saving mode
68 ANNOUNCE_TIME = 30 // in seconds
69;
70
71new ybot_irc;
72
73new joke[][] =
74{
75 "Why is 88 better than 69? Because you get ate twice.",
76 "I dreamt I was forced to eat a giant marshmallow. When I woke up, my pillow was gone",
77 "Two Elephants meet a totally naked guy. After a while one elephant says to the other: “I really don’t get how he can feed himself with that thing!â€",
78 "My dog used to chase people on a bike a lot. It got so bad, finally I had to take his bike away.",
79 "Police officer: Can you identify yourself, sir? Driver pulls out his mirror and says: Yes, it's me.",
80 "My wife’s cooking is so bad we usually pray after our food.",
81 "What do you get when you cross-breed a cow and a shark? I don’t know, but I wouldn't enjoy milking it.",
82 "I'd like to buy a new boomerang please. Also, can you tell me how to throw the old one away?",
83 "Crowded elevators have a different smell to children and midgets.",
84 "How can you tell you have a really bad case of acne? It’s when the blind try to read your face.",
85 "It is so cold outside I saw a politician with his hands in his own pockets.",
86 "I wanted to grow my own food but I couldn’t get bacon seeds anywhere.",
87 "Why do women live on average two years longer? Because the time they spend parking doesn’t count.",
88 "I can’t believe I forgot to go to the gym today. That’s 7 years in a row now.",
89 "Woke up with a dead leg this morning. I will not take out a loan with the mafia ever again.",
90 "A naked women robbed a bank. Nobody could remember her face.",
91 "How do you tell that a crab is drunk? It walks forwards.",
92 "I’m selling my talking parrot. Why? Because yesterday, the bastard tried to sell me.",
93 "A wife is like a hand grenade. Take off the ring and say good bye to your house.",
94 "I heard women love a man in uniform. Can’t wait to start working at McDonalds.",
95 "You’ll never believe who I bumped into on my way to the eye doctor! Everybody!",
96 "Which bees produce milk? The boo-bees!"
97};
98
99new RandomMessages[][] =
100{
101 "Not having friends is just as bad for your health as smoking a pack of cigarettes a day.",
102 "People who are distracted easily tend to be more creative & actually accomplish more during their lifetime.",
103 "There are currently over 7 billion people on earth today.",
104 "Scientists say, humans have a 95 percent chance of extinction over the next 9000 years.",
105 "Smarter people are more likely to suffer from anxiety and depression.",
106 "If a Google employee passes away, their spouse gets half of their pay for 10 years.",
107 "More than 12 men have stood on the moon, but only three have been to the deepest known spot in the ocean.",
108 "There are more stars in the sky than grains of sand on the earth.",
109 "Once you fall in love, you're more likely to lose two to three close friends.",
110 "There's an 82 percent chance that if you're 16 , older, you've already met the person you'll marry.",
111 "If you're one in a millionÅ There are 6,973 people just like you.",
112 "90 percent of the time, the first cigarette, beer and marijuana of every single person's life was not bought by their own money.",
113 "The average amount of time a woman can keep a secret is just 47 hours and 23 minutes.",
114 "No matter how hard you try, you can never remember how your dream started.",
115 "Bill Gates makes $290 per second.",
116 "If you had 1 billion dollars and spent $1,000 a day, it would take you 2,749 years to spend it all.",
117 "It takes the brain approximately 90 seconds to decide whether or not you like someone.",
118 "The only cells that survive from the time you are born until death are in your eye.",
119 "Apple makes about $436 million every day -- That's $18 million an hour, $300,000 a minute, $5,000 a second.",
120 "All the 13 minerals required to sustain human life can be found in beer.",
121 "Laughter is the best medicine, and marijuana makes you laugh. Therefore marijuana is the best medicine.",
122 "Being ignored can actually drive you slightly crazy.",
123 "About 160,000 people will die on the same day as you.",
124 "5 Minutes of exercise per day can add 3 years to your life.",
125 "The longest recorded marriage lasted 91 years and 12 days.",
126 "400,000 iPhones are sold daily. 350,000 people are born daily.",
127 "By the time you're a Senior in High School... You would've spent 17,000 hours of your life in school.",
128 "Relationships that start off as friendships are more likely to last longer."
129};
130
131new r8ball[][] =
132{
133 "Yes!",
134 "Well ask later",
135 "Never",
136 "NO!",
137 "i don't think so",
138 "......",
139 "Yep",
140 "i think",
141 "well stop asking me this questions",
142 "fk off",
143 "Nope",
144 "YEAH!"
145};
146
147new insultwords[][] =
148{
149 "Fuck you",
150 "fk you",
151 "fk off",
152 "motherfucker",
153 "idiot",
154 "Nigga",
155 "pussy",
156 "your mom",
157 "fking",
158 "fk youself",
159 "gay",
160 "fuck off",
161 "Idiots",
162 "fucker",
163 "7mar",
164 "kalb",
165 "nik",
166 "nikrabek",
167 "nikimak",
168 "ass",
169 "lick",
170 "dick",
171 "cunt",
172 "stupid",
173 "sucks",
174 "cum",
175 "sperm"
176};
177
178enum PlayerStats
179{
180 Hour,
181 Min,
182 Sec
183};
184
185new YBot_player[MAX_PLAYERS][PlayerStats];
186
187new YBot_Timer[MAX_PLAYERS];
188
189new YBot_ATimer;
190new YBot_XTimer;
191
192new warned[MAX_PLAYERS];
193
194new bool:CoolDown[MAX_PLAYERS];
195
196new
197 MySQL:ybot,
198 bool:Failed
199;
200
201
202stock YBot_GetName(playerid)
203{
204 new szName[MAX_PLAYER_NAME];
205 GetPlayerName(playerid, szName, sizeof(szName));
206 return szName;
207}
208
209public OnFilterScriptInit()
210{
211
212 new count = GetTickCount();
213 print(" [YBot]: Loading System...");
214 printf(" [YBot]: YBot System Version %d.%d", Major, Minor);
215 print(" [YBot]: Loading Configurations..");
216
217 if(SEEN_SYSTEM == true)
218 {
219
220 print(" [YBot]: MySQL Mode Loaded.");
221 print(" --------------------------");
222 print(" [YBot]: Connecting to MySQL Database....");
223
224 ybot = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE);
225
226 if(mysql_errno() != 0)
227 {
228 print("[ YBot]: there an error while loading YBot.");
229 print(" [YBot Erros]: 0x04521 -> Failed to connect using following info:");
230 printf(" [YBot Info]: Host: %s | User: %s | Database: %s | Password: ******* ", MYSQL_HOST, MYSQL_USER, MYSQL_DATABASE);
231 print(" --------------------------");
232 Failed = true;
233 }
234 else
235 {
236 print(" [YBot]: Connected.");
237 print(" [YBot]: Creating Databases....");
238
239 mysql_query(ybot, "CREATE TABLE IF NOT EXISTS `YBot` (Name VARCHAR(24), YEAR INT(4), MONTH INT(2), DAY INT(2), HOUR INT(2), MIN INT(2), SEC INT(2))");
240
241 print(" [YBot]: Created. Starting the YBot.");
242 print(" [YBot]: YBot has been connected to main chat");
243
244 Failed = false;
245 }
246 }
247 if(!Failed)
248 {
249 print(" [YBot]: Starting the announces repeater...");
250 YBot_ATimer = SetTimer("YBot_Announces", ANNOUNCE_TIME * 1000, true);
251 print(" [YBot]: Success.");
252 print(" [YBot]: Enabling the anti airbreak...");
253 YBot_XTimer = SetTimer("AirBreak", 1000, true);
254 print(" [YBot]: Success.");
255 print(" --------------------------");
256 printf(" [YBot]: Time taken to start and setup the bot is %d seconds", (GetTickCount() - count)/1000);
257 print(" [YBot]: The bot connected and ready to use");
258
259 ybot_irc = IRC_Connect(IRCServer, 6667, IRCBot, "YBOT", "YBOT");
260 IRC_SetIntData(ybot_irc, E_IRC_CONNECT_DELAY, 2);
261
262 groupID = IRC_CreateGroup();
263
264 }
265 else
266 {
267 print(" [YBot]: Failed to load YBot due to some errors while loading");
268 }
269 return 1;
270}
271
272public OnFilterScriptExit()
273{
274 if(SEEN_SYSTEM == true)
275 {
276 mysql_close(ybot);
277 }
278 KillTimer(YBot_ATimer);
279 KillTimer(YBot_XTimer);
280 for(new i = 0; i < MAX_PLAYERS; i++)
281 {
282 KillTimer(YBot_Timer[i]);
283 }
284 print("->> YBot has been unloaded.");
285 return 1;
286}
287
288public OnPlayerConnect(playerid)
289{
290 Spawned[playerid] = false;
291 if(SEEN_SYSTEM == true)
292 {
293 new query[80];
294 mysql_format(ybot, query, sizeof(query), "SELECT * FROM `YBot` WHERE Name = '%e'", YBot_GetName(playerid));
295 mysql_tquery(ybot, query, "YBot_FetchData", "i", playerid);
296 }
297 return 1;
298}
299
300public OnPlayerDisconnect(playerid, reason)
301{
302 if(SEEN_SYSTEM == true)
303 {
304 new year, month, day, hour, minu, sec, query[150];
305 getdate(year, month, day);
306 gettime(hour, minu, sec);
307
308 mysql_format(ybot, query, sizeof(query), "UPDATE `YBot` SET (YEAR = %d, MONTH = %d, DAY = %d, HOUR = %d, MIN = %d, SEC = %d) WHERE Name = '%s'", year, month, day, hour, minu, sec, YBot_GetName(playerid));
309 mysql_query(ybot, query);
310 KillTimer(YBot_Timer[playerid]);
311 }
312 return 1;
313}
314
315public OnPlayerSpawn(playerid)
316{
317 SetTimerEx("SpawnProtection", 2000, false, "i", playerid);
318 return 1;
319}
320
321public SpawnProtection(playerid)
322{
323 Spawned[playerid] = true;
324 return 1;
325}
326
327public OnPlayerText(playerid, text[])
328{
329 if(!Failed)
330 {
331 if(!strcmp(text, ".joke")) return YBot_Says(playerid, text, 10);
332 if(!strcmp(text, ".cmds")) return YBot_Says(playerid, text, 9);
333 if(!strcmp(text, ".register")) return YBot_Says(playerid, text, 8);
334 if(!strcmp(text, ".forum")) return YBot_Says(playerid, text, 7);
335 if(strfind(text, "How", true) != -1 && !CoolDown[playerid]) return YBot_Says(playerid, text, 6);
336 if(strfind(text, "Hello", true) != -1) return YBot_Says(playerid, text, 5);
337 if(strfind(text, "How are", true) != -1 || strfind(text, "sup", true) != -1) return YBot_Says(playerid, text, 4);
338 if(strfind(text, "Hacker", true) != -1 || strfind(text, "Hack", true) != -1 || strfind(text, "Hax", true) != -1 || strfind(text, "Hak", true) != -1) return YBot_Says(playerid, text, 3);
339 if(strfind(text, "Help", true) != -1) return YBot_Says(playerid, text, 2);
340
341 if(strfind(text, "fuck you admin", true) != -1) return YBot_Says(playerid, text, 0);
342 if(strfind(text, "admins sucks", true) != -1) return YBot_Says(playerid, text, 0);
343 if(strfind(text, "fu admin", true) != -1) return YBot_Says(playerid, text, 0);
344 if(strfind(text, "admin gay", true) != -1) return YBot_Says(playerid, text, 0);
345
346 for(new i = 0; i < sizeof(insultwords); i++)
347 {
348 if(strfind(text, insultwords[i], true) != -1) return YBot_Says(playerid, text, 1);
349 }
350 }
351 return 1;
352}
353
354public IRC_OnConnect(botid, ip[], port)
355{
356 printf("*** IRC_OnConnect: YBot connecting to irc %s at port %d", ip, port);
357 IRC_JoinChannel(botid, IRC_CHANNEL);
358 IRC_AddToGroup(groupID, botid);
359 return 1;
360}
361
362public IRC_OnJoinChannel(botid, channel[])
363{
364 printf("*** IRC_OnJoinChannel: YBot has joined channel %s", channel);
365 IRC_Say(ybot_irc, channel, "**4YBot Initialize....");
366 return 1;
367}
368
369public IRC_OnUserSay(botid, recipient[], user[], host[], message[])
370{
371 if(!Failed)
372 {
373 if(strfind(message, "How are you ?", true) != -1 || strfind(message, "sup", true) != -1) return IRC_Say(ybot_irc, IRC_CHANNEL, "fine and you ?");
374 if(strfind(message, "How", true) != -1) return IRC_Say(ybot_irc, IRC_CHANNEL, "Need any help? don't spam here pm an admin !");
375 if(strfind(message, "Help", true) != -1) return IRC_Say(ybot_irc, IRC_CHANNEL, "Need any help? don't spam here pm an admin !");
376 if(strfind(message, "Hello", true) != -1) return IRC_Say(ybot_irc, IRC_CHANNEL, "Hi");
377 if(strfind(message, "fuck you admin", true) != -1) return IRC_KickUser(ybot_irc, recipient, user, "Disrespecting admins not allowed");
378 if(strfind(message, "admins sucks", true) != -1) return IRC_KickUser(ybot_irc, recipient, user, "Disrespecting admins not allowed");
379 if(strfind(message, "fu admin", true) != -1) return IRC_KickUser(ybot_irc, recipient, user, "Disrespecting admins not allowed");
380 if(strfind(message, "admin gay", true) != -1) return IRC_KickUser(ybot_irc, recipient, user, "Disrespecting admins not allowed");
381 if(strfind(message, "unban me pls", true) != -1) return IRC_KickUser(ybot_irc, recipient, user, "Don't beg for unban here");
382 if(strfind(message, "unban me admin", true) != -1) return IRC_KickUser(ybot_irc, recipient, user, "Don't beg for unban here");
383 if(strfind(message, "unban me", true) != -1) return IRC_KickUser(ybot_irc, recipient, user, "Don't beg for unban here");
384 if(strfind(message, "unban", true) != -1) return IRC_KickUser(ybot_irc, recipient, user, "Don't beg for unban here");
385
386 for(new i = 0; i < sizeof(insultwords); i++)
387 {
388 if(strfind(message, insultwords[i], true) != -1) return IRC_KickUser(ybot_irc, recipient, user, "Insulting/swearing not allowed");
389 }
390 }
391 return 1;
392}
393
394public OnPlayerAirbreak(playerid)
395{
396 new str[50];
397 SendClientMessageToAll(-1, ""R""YBot"(0): "W"those hackers pff, airbreak not allowed see you");
398 format(str, sizeof(str), "YBot/Warned/%s.ybot", YBot_GetName(playerid));
399 if(fexist(str))
400 {
401 format(str, sizeof(str), "YBot/Banned/%s.ybot", YBot_GetName(playerid));
402 new File:file;
403 file = fopen(str, io_write);
404 fclose(file);
405 BanPlayer(playerid, "Airbreak");
406 }
407 else
408 {
409 format(str, sizeof(str), "YBot/Warned/%s.ybot", YBot_GetName(playerid));
410 new File:file;
411 file = fopen(str, io_write);
412 fclose(file);
413 KickPlayer(playerid, "Airbreak");
414 }
415}
416
417CMD:botsay(playerid, params[])
418{
419 new str[100];
420 if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, ""R""YBot"(0): "W"Hello. Thank you for joining our server but you can't use this command atm, you need help ? use /ashley");
421 if(isnull(params)) return SendClientMessage(playerid, -1, ""R""YBot"(0): "W"Hi Admin, it's /botsay [text]");
422 format(str, sizeof(str), ""R""YBot"(0): "W"%s", params);
423 SendClientMessageToAll(-1, str);
424 return 1;
425}
426
427CMD:seen(playerid, params[])
428{
429 new name[24], str[100], bool:exists;
430 if(SEEN_SYSTEM == true)
431 {
432 format(name, sizeof(name), ".seen %s", params);
433 SendPlayerMessageToAll(playerid, name);
434 if(sscanf(params, "s[24]", name)) return SendClientMessageToAll(-1, ""R""YBot"(0): "W"Hello there a Synatax Error: .seen [Name]");
435 for(new i = 0; i < MAX_PLAYERS; i++)
436 {
437 if(IsPlayerConnected(i))
438 {
439 if(!strcmp(name, YBot_GetName(i)))
440 {
441 exists = true;
442 }
443 else
444 {
445 exists = false;
446 }
447 }
448 }
449 if(exists == true)
450 {
451 format(str, sizeof(str), ""R""YBot"(0): "W"Player %s is already online for %d hours, %d minutes and %d seconds", name, YBot_player[YBot_GetPlayerId(name)][Hour], YBot_player[YBot_GetPlayerId(name)][Min], YBot_player[YBot_GetPlayerId(name)][Sec]);
452 SendClientMessageToAll(-1, str);
453 }
454 else
455 {
456 new year, month, day, hour, minute, second;
457 if(YBot_GetLastOnline(name, year, month, day, hour, minute, second))
458 {
459 format(str, sizeof(str), ""R""YBot"(0): "W"Player %s was last online in %dth %s %d, %d:%d:%d", name, day, YBot_Month(month), year, hour, minute, second);
460 SendClientMessageToAll(-1, str);
461 }
462 else
463 {
464 SendClientMessageToAll(-1, ""R""YBot"(0): "W"Error: This nickname not exists in database");
465 }
466 }
467 }
468 return 1;
469}
470
471
472CMD:8ball(playerid, params[])
473{
474 new ex[24], str[50];
475 format(ex, sizeof(ex), ".8ball %s", params);
476 SendPlayerMessageToAll(playerid, ex);
477
478 if(sscanf(params, "s[24]", ex)) return SendClientMessageToAll(-1, ""R""YBot"(0): "W"Well i don't know what you means");
479 format(str, sizeof(str), ""R""YBot"(0): "W"%s", r8ball[random(sizeof(r8ball))]);
480 SendClientMessageToAll(-1, str);
481 return 1;
482}
483
484IRCCMD:8ball(botid, channel[], user[], host[], params[])
485{
486 new ex[24];
487 new str[100];
488 if(sscanf(params, "s[24]", ex)) return SendClientMessageToAll(-1, "1Well i don't know what you means");
489 format(str, sizeof(str), "1%s", r8ball[random(sizeof(r8ball))]);
490 IRC_Say(ybot_irc, IRC_CHANNEL, str);
491 return 0;
492}
493
494IRCCMD:seen(botid, channel[], user[], host[], params[])
495{
496 new name[24], str[100], bool:exists;
497 if(SEEN_SYSTEM == true)
498 {
499 if(sscanf(params, "s[24]", name)) return IRC_Say(ybot_irc, IRC_CHANNEL, "1Hello there a Synatax Error: .seen [Name]");
500 for(new i = 0; i < MAX_PLAYERS; i++)
501 {
502 if(IsPlayerConnected(i))
503 {
504 if(!strcmp(name, YBot_GetName(i)))
505 {
506 exists = true;
507 }
508 else
509 {
510 exists = false;
511 }
512 }
513 }
514 if(exists == true)
515 {
516 format(str, sizeof(str), "1Player %s is already online for %d hours, %d minutes and %d seconds", name, YBot_player[YBot_GetPlayerId(name)][Hour], YBot_player[YBot_GetPlayerId(name)][Min], YBot_player[YBot_GetPlayerId(name)][Sec]);
517 IRC_Say(ybot_irc, IRC_CHANNEL, str);
518 }
519 else
520 {
521 new year, month, day, hour, minute, second;
522 if(YBot_GetLastOnline(name, year, month, day, hour, minute, second))
523 {
524 format(str, sizeof(str), "1Player %s was last online in %dth %s %d, %d:%d:%d", name, day, YBot_Month(month), year, hour, minute, second);
525 IRC_Say(ybot_irc, IRC_CHANNEL, str);
526 }
527 else
528 {
529 IRC_Say(ybot_irc, IRC_CHANNEL, "1Error: This nickname not exists in database");
530 }
531 }
532 }
533 return 1;
534}
535
536IRCCMD:cmds(botid, channel[], user[], host[], params[])
537{
538 return IRC_Say(ybot_irc, IRC_CHANNEL, "1Heya! you can highlight me using those words: !8ball !seen !cmds !forum !register !joke");
539}
540
541IRCCMD:forum(botid, channel[], user[], host[], params[])
542{
543 return IRC_Say(ybot_irc, IRC_CHANNEL, "1Hello man. you are new here ? you can join us at the forum "FORUM"");
544}
545
546IRCCMD:register(botid, channel[], user[], host[], params[])
547{
548 return IRC_Say(ybot_irc, IRC_CHANNEL, "1Hello there. you are new here ? you can register using /register to make you stats saved");
549}
550
551IRCCMD:joke(botid, channel[], user[], host[], params[])
552{
553 new str[100];
554 format(str, sizeof(str), "1%s", joke[random(sizeof(joke))]);
555 IRC_Say(ybot_irc, IRC_CHANNEL, str);
556}
557
558public YBot_Reply(playerid, text[], replyid)
559{
560 new str[150];
561 switch(replyid)
562 {
563 case 0:
564 {
565 SendClientMessageToAll(-1, ""R""YBot"(0): "W"Hello. Disrespecting admin not allowed. now STFU and cya");
566 format(str, sizeof(str), "YBot/Warned/%s.ybot", YBot_GetName(playerid));
567 if(fexist(str))
568 {
569 format(str, sizeof(str), "YBot/Banned/%s.ybot", YBot_GetName(playerid));
570 new File:file;
571 file = fopen(str, io_write);
572 fclose(file);
573 BanPlayer(playerid, "Disrespecting Admins");
574 }
575 else
576 {
577 format(str, sizeof(str), "YBot/Warned/%s.ybot", YBot_GetName(playerid));
578 new File:file;
579 file = fopen(str, io_write);
580 fclose(file);
581 KickPlayer(playerid, "Disrespecting Admins");
582 }
583 }
584 case 1:
585 {
586 if(warned[playerid] == 2) return KickPlayer(playerid, "Insulting");
587 SendClientMessageToAll(-1, ""R""YBot"(0): "W"well insulting is bad next time you will got kicked");
588 warned[playerid]++;
589 }
590 case 2: SendClientMessageToAll(-1, ""R""YBot"(0): "W"Hello. do you need help? you can use /help or /commands");
591 case 3: SendClientMessageToAll(-1, ""R""YBot"(0): "W"Oh COMON? Stop saying it in main chat just use /report or @ ids :/");
592 case 4:
593 {
594 if(CoolDown[playerid])
595 {
596 SendClientMessageToAll(-1, ""R""YBot"(0): "W"fine and you ?");
597 CoolDown[playerid] = false;
598 }
599 }
600 case 5:
601 {
602 SendClientMessageToAll(-1, ""R""YBot"(0): "W"Hello.");
603 CoolDown[playerid] = true;
604 }
605 case 6: SendClientMessageToAll(-1, ""R""YBot"(0): "W"Hello. do you need help? you can use /help or /commands");
606 case 7: SendClientMessageToAll(-1, ""R""YBot"(0): "W"Hello man. you are new here ? you can join us at the forum "FORUM"");
607 case 8: SendClientMessageToAll(-1, ""R""YBot"(0): "W"Hello there. you are new here ? you can register using /register to make you stats saved");
608 case 9: SendClientMessageToAll(-1, ""R""YBot"(0): "W"Heya! you can highlight me using those words: .8ball .seen .cmds .forum .register .joke");
609 case 10:
610 {
611 format(str, sizeof(str), ""R""YBot"(0): "W"%s", joke[random(sizeof(joke))]);
612 SendClientMessageToAll(-1, str);
613 }
614 }
615 return 1;
616}
617
618public YBot_FetchData(playerid)
619{
620 new rows, query[150];
621
622 cache_get_row_count(rows);
623 if(rows)
624 {
625 SetTimerEx("YBot_OnlineCount", 1000, true, "i", playerid);
626 }
627 else
628 {
629 new year, month, day, hour, minu, sec;
630 getdate(year, month, day);
631 gettime(hour, minu, sec);
632
633 mysql_format(ybot, query, sizeof(query), "INSERT INTO `YBot` (Name, YEAR, MONTH, DAY, HOUR, MIN, SEC) VALUES ('%s', %d, %d, %d, %d, %d, %d)", YBot_GetName(playerid), year, month, day, hour, minu, sec);
634 mysql_query(ybot, query);
635
636 YBot_Timer[playerid] = SetTimerEx("YBot_OnlineCount", 1000, true, "i", playerid);
637 }
638 return 1;
639}
640
641public YBot_OnlineCount(playerid)
642{
643 YBot_player[playerid][Sec]++;
644 if(YBot_player[playerid][Sec] == 60)
645 {
646 YBot_player[playerid][Sec] = 0;
647 YBot_player[playerid][Min]++;
648 }
649 if(YBot_player[playerid][Min] == 60)
650 {
651 YBot_player[playerid][Min] = 0;
652 YBot_player[playerid][Hour]++;
653 }
654 return 1;
655}
656
657public YBot_Announces()
658{
659 new str[200];
660 format(str, sizeof(str), ""R""YBot"(0): "W"%s", RandomMessages[random(sizeof(RandomMessages))]);
661 SendClientMessageToAll(-1, str);
662 format(str, sizeof(str), "4"YBot"(0): 1%s", RandomMessages[random(sizeof(RandomMessages))]);
663 IRC_Say(ybot_irc, IRC_CHANNEL, str);
664 return 1;
665}
666
667stock YBot_Says(playerid, text[], replyid)
668{
669 return SetTimerEx("YBot_Reply", 2000, false, "isi", playerid, text, replyid);
670}
671
672stock YBot_GetPlayerId(playername[])
673{
674 for(new i = 0; i <= MAX_PLAYERS; i++)
675 {
676 if(IsPlayerConnected(i))
677 {
678 new playername2[MAX_PLAYER_NAME];
679 GetPlayerName(i, playername2, sizeof(playername2));
680 if(strcmp(playername2, playername, true, strlen(playername)) == 0)
681 {
682 return i;
683 }
684 }
685 }
686 return INVALID_PLAYER_ID;
687}
688
689stock YBot_Month(monthnumber)
690{
691 new str[10];
692
693 switch(monthnumber)
694 {
695 case 1: str = "January";
696 case 2: str = "February";
697 case 3: str = "March";
698 case 4: str = "April";
699 case 5: str = "May";
700 case 6: str = "June";
701 case 7: str = "July";
702 case 8: str = "August";
703 case 9: str = "September";
704 case 10: str = "October";
705 case 11: str = "November";
706 case 12: str = "December";
707 }
708 return str;
709}
710
711public BanPlayer(playerid, reason[])
712{
713 new str[50];
714 format(str, sizeof(str), ""R"*"GRI"%s (Id: %d) "R"has been banned by "GRI""YBot" "R"for "GRI"%s", YBot_GetName(playerid), playerid, reason);
715 SendClientMessageToAll(-1, str);
716 BanEx(playerid, reason);
717 return 1;
718}
719
720stock YBot_GetLastOnline(name[], &y, &mx, &d, &h, &m, &s)
721{
722 new Cache:GetCache, bool:exists;
723 new query[70];
724 if(SEEN_SYSTEM == true)
725 {
726 mysql_format(ybot, query, sizeof(query), "SELECT * FROM `YBot` WHERE Name = '%e'", name);
727 GetCache = mysql_query(ybot, query);
728 new rows;
729 cache_get_row_count(rows);
730
731 if(rows)
732 {
733 cache_get_value_name_int(0, "YEAR", y);
734 cache_get_value_name_int(0, "MONTH", mx);
735 cache_get_value_name_int(0, "DAY", d);
736 cache_get_value_name_int(0, "HOUR", h);
737 cache_get_value_name_int(0, "MIN", m);
738 cache_get_value_name_int(0, "SEC", s);
739 cache_delete(GetCache);
740
741 exists = true;
742 }
743 else
744 {
745 cache_delete(GetCache);
746 exists = false;
747 }
748 }
749 if(exists) return true;
750 else
751 return false;
752}
753
754public KickPlayer(playerid, reason[])
755{
756 new str[50];
757 format(str, sizeof(str), ""R"*"GRI"%s (Id: %d) "R"has been kicked by "GRI""YBot" "R"for "GRI"%s", YBot_GetName(playerid), playerid, reason);
758 SendClientMessageToAll(-1, str);
759 Kick(playerid);
760 return 1;
761}
762
763// Airbreak Detector ===============================================================================
764
765IsVehicleAir(playerid, vehicleid)
766{
767 vehicleid = GetPlayerVehicleID(playerid);
768 switch(GetVehicleModel(vehicleid))
769 {
770 case 592, 577, 511, 512, 593, 520, 553, 476, 519, 460, 513, 548, 425, 417, 487, 488, 498, 563, 447, 469: return true;
771 }
772 return false;
773}
774
775public AirBreak()
776{
777 for(new i = 0; i < MAX_PLAYERS; i++)
778 {
779 if(!Spawned[i]) return 1;
780 new Float:X, Float:Y, Float:Z, Float:ZM, Float:difference;
781 GetPlayerPos(i,X,Y,Z); //Get the players position
782 MapAndreas_FindZ_For2DCoord(X,Y,ZM); //Gets the max Z cord
783 difference = Z-ZM;
784
785 if(!IsVehicleAir(i, GetPlayerVehicleID(i)))
786 {
787 if (difference > 100 && GetPlayerState(i) == PLAYER_STATE_PASSENGER || GetPlayerState(i) == PLAYER_STATE_DRIVER)
788 {
789 SetTimerEx("OnPlayerAirbreak", 1000, false, "i", i);
790 }
791 //If players Z cord is more than 100 meters above the ground
792 if(difference > 10 && GetPlayerState(i) == PLAYER_STATE_ONFOOT)
793 {
794 SetTimerEx("OnPlayerAirbreak", 1000, false, "i", i);
795 }
796 }
797 }
798 return 1;
799}