[SOLVED]How can I?
#1

Hello guys. I made a little reaction test, but when i type the right solution it just happens nothing.

pawn Код:
if(text[0] == nra+nrb+nrc) {
      new string[128]; new stringy[128]; GetPlayerName(playerid,stringy,sizeof(stringy));
        format(string,sizeof(string),"%s has won the Reaction Test. Solution: %d",stringy,text[0]); SendClientMessageToAll(yellow, string);
      return 0;
    }
nra = first number
nrb = 2nd number
nrc = 3rd number

How can I make that?
Would be nice if iґd get some help.

Greetz
Jeffry
Reply
#2

Quote:

if(text[0] == nra+nrb+nrc) {

use strfind to find parts of a text.

// https://sampwiki.blast.hk/wiki/Strfind
//І or strval https://sampwiki.blast.hk/wiki/Strval
Reply
#3

Omg, i dont understand that. Can anyone of you create it for me fast?

Would be nice
Reply
#4

pawn Код:
//on top of your script:
forward Result();
new result12[128];
new calculated;

//ongamemodeinit:
SetTimer("Result",180000, 1); //timer is set to 3mins, change it

//end of your script:
public Result()
{
    new random1,random2,random3,str[128];
    random1 = random(999);
    random2 = random(999);
    random3 = random(999);
    format(str,sizeof(str),"[Calculation] calculate: %d + %d - %d and win 5000$",random1,random2,random3);
    SendClientMessageToAll(0xFFFFFF,str);
    printf("%d+%d-%d",random1,random2,random3);
    format(result12,sizeof(result12),"%d",random1+random2-random3);
    calculated = 1;
    return 1;
}

//onplayertext:

for(new i=0; i<256; i++)
{
        if(strfind(text[i],result12) != -1 && calculated == 1)
        {
           
            SendClientMessageToAll(THIAZ_YELLOW,"the calculation has been finished!"); //do this for yourself!
            GivePlayerMoney(playerid,5000);
            calculated = 0; //set this to 0, so that noone else can write the result after now.
        }
    }
that should be work, its my code
Reply
#5

Quote:
Originally Posted by thiaZ_
pawn Код:
//onplayertext:
for(new i=0; i<256; i++)
{
        if(strfind(text[i],result12) != -1 && calculated == 1)
        {
           
            SendClientMessageToAll(THIAZ_YELLOW,"the calculation has been finished!"); //do this for yourself!
            GivePlayerMoney(playerid,5000);
            calculated = 0; //set this to 0, so that noone else can write the result after now.
        }
    }
SA:MP chat-box MAX_IO is 128, so i don't really know why're you using 256?
Reply
#6

Doesnt matter. I will change. BUT: Thank you!! It works!!

I just replaced all what i did with yours, was faster.
Gonna edit it for my winning things now.

Thank you!!!!
Reply
#7

Quote:
Originally Posted by Jeffry
Doesnt matter.
Yes, it does matter.

http://forum.sa-mp.com/index.php?topic=78026.0
Reply
#8

So, iґd use 150 or?
Reply
#9

oh im sorry, i've changed my all my string sizes to 128, maybe ive forgotten this one :X
Reply
#10

Quote:
Originally Posted by Jeffry
So, iґd use 150 or?
128 is the maximum I/O for chat-box.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)