SA-MP Forums Archive
Connect bot checker(random numbers) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Connect bot checker(random numbers) (/showthread.php?tid=564491)



Connect bot checker(random numbers) - tristan137 - 21.02.2015

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


Re: Connect bot checker(random numbers) - AndySedeyn - 21.02.2015

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


Re: Connect bot checker(random numbers) - Puppy - 21.02.2015

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;
}



Re: Connect bot checker(random numbers) - arlindi - 21.02.2015

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


Re: Connect bot checker(random numbers) - tristan137 - 21.02.2015

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


Re: Connect bot checker(random numbers) - JaydenJason - 21.02.2015

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


Re: Connect bot checker(random numbers) - tristan137 - 22.02.2015

Код:
#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?


Re: Connect bot checker(random numbers) - AndySedeyn - 22.02.2015

Test it.


Re: Connect bot checker(random numbers) - tristan137 - 22.02.2015

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?