Connect bot checker(random numbers)
#1

Hi.
I want to make a script,but I have a problem with making.
So I want that when the player connects it shows a dialog(dialog input text)and there will be random 4 numbers and letters.He must write that random numbers and letters in the box(not obligatory,but i want with a timer with 5 minutes,if he dont write the numbers and letters in the box in 5 minutes he will be kicked by the server)If he does correct it will be nothing,but if he does wrong it will be kicked.

Like this:


P.S:Sorry for my bad english
Reply
#2

I just happened to come across this Admin Filterscript that uses this method. You might wanna look into it.

https://sampforum.blast.hk/showthread.php?tid=485410
Reply
#3

pawn Код:
stock randomString(strDest[], strLen = 10)
{
    while(strLen--)
        strDest[strLen] = random(2) ? (random(26) + (random(2) ? 'a' : 'A')) : (random(10) + '0');
}
Credits to Ryder~.

And for the timer:
pawn Код:
public OnPlayerConnect(playerid)
{
      PlayerKickTimer[playerid] = SetTimerEx("KickEx", 300*60, false, "i", playerid);
      RandomString(PlayerString[playerid], 10);
      new string[64];
      format(string, sizeof string, "Type the following string: %s", PlayerString[playerid]);
      ShowPlayerDialog(playerid, DIALOG_VERIFY, DIALOG_STYLE_INPUTTEXT, "String", string, "ok", "ok");

      return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
      if(dialogid == DIALOG_VERIFY && response)
      {
           if(strcmp(inputtext, PlayerString[playerid], true) != -1)
           {
                // correct
           }
           else KickEx(playerid);
      }
      return 1;
}
Reply
#4

Quote:
Originally Posted by Puppy
Посмотреть сообщение
pawn Код:
stock randomString(strDest[], strLen = 10)
{
    while(strLen--)
        strDest[strLen] = random(2) ? (random(26) + (random(2) ? 'a' : 'A')) : (random(10) + '0');
}
Credits to Ryder~.

And for the timer:
pawn Код:
public OnPlayerConnect(playerid)
{
      PlayerKickTimer[playerid] = SetTimerEx("KickEx", 300*60, false, "i", playerid);
      RandomString(PlayerString[playerid], 10);
      new string[64];
      format(string, sizeof string, "Type the following string: %s", PlayerString[playerid]);
      ShowPlayerDialog(playerid, DIALOG_VERIFY, DIALOG_STYLE_INPUTTEXT, "String", string, "ok", "ok");

      return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
      if(dialogid == DIALOG_VERIFY && response)
      {
           if(strcmp(inputtext, PlayerString[playerid], true) != -1)
           {
                // correct
           }
           else KickEx(playerid);
      }
      return 1;
}
This is good Ideaa
Must help you
Reply
#5

Can someone make me Puppys's code to a complete filterscript?
Reply
#6

Quote:
Originally Posted by tristan137
Посмотреть сообщение
Can someone make me Puppys's code to a complete filterscript?
Exactly how lazy are you?
Reply
#7

Код:
#include a_samp
new PlayerKickTimer[MAX_PLAYERS];
new PlayerString[MAX_PLAYERS];


public OnPlayerConnect(playerid)
{
      PlayerKickTimer[playerid] = SetTimerEx("KickEx", 300*60, false, "i", playerid);
      randomString(PlayerString[playerid], 10);
      new string[64];
      format(string, sizeof string, "Type the following string: %s", PlayerString[playerid]);
      ShowPlayerDialog(playerid, 6973, DIALOG_STYLE_INPUT, "String", string, "ok", "ok");

      return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
      if(dialogid == 6973 && response)
      {
           if(strcmp(inputtext, PlayerString[playerid], true) != -1)
           {
                // correct
           }
           else Kick(playerid);
      }
      return 1;
}

stock randomString(strDest[], strLen = 10)
{
	while(strLen--)
		strDest[strLen] = random(2) ? (random(26) + (random(2) ? 'a' : 'A')) : (random(10) + '0');
}
So this is good,it will work?
Reply
#8

Test it.
Reply
#9

So I tested with printf.
It printed all,if i write wrong it will be nothing.
Код:
#include a_samp
new PlayerKickTimer[MAX_PLAYERS];
new PlayerString[MAX_PLAYERS];


public OnPlayerConnect(playerid)
{
      PlayerKickTimer[playerid] = SetTimerEx("KickEx", 300*60, false, "i", playerid);
      randomString(PlayerString[playerid], 10);
      new string[64];
      format(string, sizeof string, "Type the following string: %s", PlayerString[playerid]);
      ShowPlayerDialog(playerid, 6973, DIALOG_STYLE_INPUT, "String", string, "ok", "ok");

      return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
      if(dialogid == 6973 && response)
      {
           printf("asd0");
           if(strcmp(inputtext, PlayerString[playerid], true) != -1)
           {
                // correct
                printf("asd1");
           }
           else Kick(playerid);
           printf("asd2");
      }
      printf("asd3");
      return 1;
}

stock randomString(strDest[], strLen = 10)
{
	while(strLen--)
		strDest[strLen] = random(2) ? (random(26) + (random(2) ? 'a' : 'A')) : (random(10) + '0');
}
Print(i wrote wrong that random code):
Код:
[20:51:32] asd0
[20:51:32] asd1
[20:51:32] asd2
[20:51:32] asd3
What's wrong?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)