SA-MP Forums Archive
[Please Help][Serious Help]Reaction Test won't Work - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Please Help][Serious Help]Reaction Test won't Work (/showthread.php?tid=104631)



[Please Help][Serious Help]Reaction Test won't Work - Tigerbeast11 - 25.10.2009

Hi! I got this reaction test script from the internet. However,just like other internet releases, it doesnt work! Here is the code...

At the top:
pawn Код:
new reactionstr[9]; //randomly generated string
new reactioninprog; //what status the reactiontest is at
new reactionwinnerid; //id of the current reactiontest winner
new reactiongap; //timer to restart ReactionTest()
pawn Код:
forward ReactionTest();
forward ReactionWin(playerid);
pawn Код:
#define time1 60000 //this is the 1 minute minimum gap time
#define time2 60000
OnGameModeInIt
pawn Код:
SetTimer("ReactionTest",time1+random(time2),1);
pawn Код:
public OnPlayerText(playerid, text[])
{
    DisableWord("faggot",text);
    DisableWord("fuck",text);
    DisableWord("dick",text);
    DisableWord("cunt",text);
    DisableWord("penis",text);
    if(!strcmp(text, reactionstr, false))
  {
  if(reactioninprog == 2) ReactionWin(playerid);
  if(reactioninprog == 1)
  {
  if(reactionwinnerid == playerid)
  {
  SendClientMessage(playerid,0x247C1BFF,"You've already won!");
  }
  else
  {
  SendClientMessage(playerid,0x247C1BFF,"You are too slow!");
  }
  }
  return 1;
  }


    return 1;
    }
pawn Код:
if (strcmp("/test", cmdtext, true) == 0)
  {
  if(IsPlayerAdmin(playerid))
  {
  ReactionTest();
  }

  return 1;
  }
pawn Код:
public ReactionTest()
{
    reactionstr = "";
    KillTimer(reactiongap);
    new str[256];
    new random_set[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; // the set of characters used for the generation of the string
    for (new i = 0; i < 8; i++)
        {
  reactionstr[i] = random_set[random(sizeof(random_set))];
        }
    reactioninprog = 2;
    format(str,sizeof(str),"** First one to type %s wins $20000",reactionstr); // announcement
    print(str);
    SendClientMessageToAll(0xFFFF00FF,str);
}

public ReactionWin(playerid)
{
    GivePlayerMoney(playerid, 20000);
    SetTimer("SetBack",30,0); // required delay, for some reason.
    new reactionwinner[256];
    reactionwinnerid = playerid;
    new tempstring[256];
    GetPlayerName(playerid,reactionwinner,sizeof(reactionwinner));
    format(tempstring,sizeof(tempstring),"%s has won $20000 on the Reaction Test",reactionwinner);
    SendClientMessageToAll(0xFFFF00FF,tempstring);
    reactiongap = SetTimer("ReactionTest",time1+random(time2),0); // sets the timer to restart ReactionTest()
 }
Why wont this work? I get no errors, but, when i enter the word, it doesnt work! If you can help me fix this or right an alternative to this, i'd be really thnkful!

Thnk you!

Here is the pastebin link...
http://pastebin.com/m5d81107a

P.S Peter, i put your name at the top because your the guy I know that can splve this... But if anyone lse wants a go, there is nothing stopping you :P


Re: [Peter Cornelie][Serious Help]Reaction Test won't Work - Tigerbeast11 - 25.10.2009

Sorry for bump =P


Re: [Peter Cornelie][Serious Help]Reaction Test won't Work - Peter_Corneile - 25.10.2009

pawn Код:
if (strcmp("/test", cmdtext, true) == 0)
  {
  if(IsPlayerAdmin(playerid))
  {
  SetTimer("ReactionTest",100,false);
  }

  return 1;
  }
You should put a timer rather than just the name .. Try this it might work


Re: [Peter Cornelie][Serious Help]Reaction Test won't Work - Tigerbeast11 - 25.10.2009

Nice thinking, but no, this isnt what i want...


The problem is, when i type in the [random numbers] it sends the numbers in mainchat but i dont get the 20000!

If you need more info, plz post here


Re: [Please Help][Serious Help]Reaction Test won't Work - Peter_Corneile - 26.10.2009

Try something like this
pawn Код:
if(strcmp("1",text,true,1)==0)
if(strcmp("2",text,true,1)==0)
Under OnPlayerText


Re: [Please Help][Serious Help]Reaction Test won't Work - Tigerbeast11 - 26.10.2009

Sorry, I don't understand...

Plz can u edit and rewrite the script and give me the pastebin link. The original script pastebin link is on the first post.