Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- J.A.R.V.I.S BOT
- Creditos a Luís Gustavo Mike por explicar o uso do sscanf, e a Daniel Santos por desenvolver.
- */
- #include <a_samp>
- #include <sscanf2>
- new
- Timer[3],
- bool:admin[MAX_PLAYERS] = {true, ...},
- bool:JarvisResponse = false
- ;
- new strCallJarvis[3][26] = {
- "Jarvis, está ai?",
- "Jarvis.",
- "Jarvis, faça-me um favor."
- };
- new strJarvisCommands[3][24]= {
- "Numero:",
- "Desconecte o id:",
- "Reinicie o servidor."
- };
- public OnPlayerText(playerid, text[]) {
- if((admin[playerid] == true) && ((text[0] == 'j') || (text[0] == 'J'))) {
- new
- slot
- ;
- while(slot < 3) {
- if(!strcmp(text, strCallJarvis[slot], true)) {
- KillTimer(Timer[0]);
- Timer[0] = SetTimerEx("OnJarvisResponse", 2000, false, "i", slot);
- break;
- }
- slot++;
- }
- }
- if((admin[playerid] == true) && (JarvisResponse == true)) {
- if(!strfind(text, strJarvisCommands[0], true)) { // Vazio, faz a mesma funcao abaixo(pegar um numero)
- new valor;
- if(!sscanf(text, "p<:>{s[144]}d", valor)) {
- }
- }
- if(!strfind(text, strJarvisCommands[1], true)) { // Desconectar jogador.
- new valor;
- if(!sscanf(text, "p<:>{s[144]}d", valor)) {
- KillTimer(Timer[0]);
- Timer[0] = SetTimerEx("OnJarvisResponse", 2000, false, "i", 4);
- KillTimer(Timer[1]);
- Timer[1] = SetTimerEx("OnJarvisExecuteCommand", 5000, false, "ii", 1, valor);
- }
- }
- if(!strfind(text, strJarvisCommands[2], true)) {
- KillTimer(Timer[0]);
- Timer[0] = SetTimerEx("OnJarvisResponse", 2000, false, "i", 5);
- }
- }
- return 1;
- }
- JarvisInactive(); public JarvisInactive() { JarvisResponse = false; return 1; }
- OnJarvisResponse(responseid); public OnJarvisResponse(responseid) {
- if(responseid == 0) {
- SendClientMessageToAll(-1, "{4682B4}Jarvis: {FFFFFF}Para o senhor, sempre.");
- JarvisResponse = true;
- KillTimer(Timer[2]);
- Timer[2] = SetTimer("JarvisInactive", 20*1000, false);
- }
- else if(responseid == 1) {
- SendClientMessageToAll(-1, "{4682B4}Jarvis: {FFFFFF}Diga senhor.");
- JarvisResponse = true;
- KillTimer(Timer[2]);
- Timer[2] = SetTimer("JarvisInactive", 20*1000, false);
- }
- else if(responseid == 2) {
- SendClientMessageToAll(-1, "{4682B4}Jarvis: {FFFFFF}Claro, é só dizer.");
- JarvisResponse = true;
- KillTimer(Timer[2]);
- Timer[2] = SetTimer("JarvisInactive", 20*1000, false);
- }
- else if(responseid == 3) {
- SendClientMessageToAll(-1, "{4682B4}Jarvis: {FFFFFF}Irei alterar o minigame senhor.");
- KillTimer(Timer[1]);
- Timer[1] = SetTimerEx("OnJarvisExecuteCommand", 3000, false, "i", 0);
- }
- else if(responseid == 4) {// kick jogador.
- SendClientMessageToAll(-1, "{4682B4}Jarvis: {FFFFFF}Um momento.");
- }
- else if(responseid == 5) {
- SendClientMessageToAll(-1, "{4682B4}Jarvis: {FFFFFF}Certo, irei reiniciar o minigame.");
- KillTimer(Timer[1]);
- Timer[1] = SetTimerEx("OnJarvisExecuteCommand", 3000, false, "i", 2);
- }
- return 1;
- }
- OnJarvisExecuteCommand(commandid, parameterid); public OnJarvisExecuteCommand(commandid, parameterid) {
- if(commandid == 0) { // comando 1 (sem ação).
- }
- else if(commandid == 1) {
- if(!IsPlayerConnected(parameterid)) return SendClientMessageToAll(-1, "{4682B4}Jarvis: {FFFFFF}Senhor, não há um(a) jogador(a) conectado(a) no momento com este id.");
- new msg[129];
- format(msg, sizeof(msg), "{FF7F00}* {4682B4}Jarvis {FF0000}desconectou {FFFFFF}o(a) jogador(a) {BEBEBE}%s.", GetName(parameterid));
- SendClientMessageToAll(-1, msg);
- KickDelay(parameterid, "{FF0000}Desconectado por {4682B4}Jarvis.");
- return 1;
- }
- if(commandid == 2) {
- SendRconCommand("gmx");
- }
- return 1;
- }
- stock KickDelay(playerid, msg[]) {
- SendClientMessage(playerid, -1, msg);
- SetTimerEx("DesconectPlayer", 250, false, "i", playerid);
- return 1;
- }
- stock GetName(playerid) {
- new a[25];
- GetPlayerName(playerid, a, sizeof(a));
- return a;
- }
- DesconectPlayer(playerid); public DesconectPlayer(playerid) {
- Kick(playerid);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment