[SOLVED]How can I? - 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: [SOLVED]How can I? (
/showthread.php?tid=122338)
[SOLVED]How can I? -
Jeffry - 21.01.2010
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
Re: How can I? -
thiaZ_ - 21.01.2010
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
Re: How can I? -
Jeffry - 21.01.2010
Omg, i dont understand that. Can anyone of you create it for me fast?
Would be nice
Re: How can I? -
thiaZ_ - 21.01.2010
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
Re: How can I? -
Correlli - 21.01.2010
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?
Re: How can I? -
Jeffry - 21.01.2010
Doesnt matter. I will change. BUT: Thank you!! It works!!
I just replaced all what i did with yours, was faster.
![Wink](images/smilies/wink.png)
Gonna edit it for my winning things now.
Thank you!!!!
Re: How can I? -
Correlli - 21.01.2010
Quote:
Originally Posted by Jeffry
Doesnt matter.
|
Yes, it does matter.
http://forum.sa-mp.com/index.php?topic=78026.0
Re: [SOLVED]How can I? -
Jeffry - 21.01.2010
So, iґd use 150 or?
Re: [SOLVED]How can I? -
thiaZ_ - 21.01.2010
oh im sorry, i've changed my all my string sizes to 128, maybe ive forgotten this one :X
Re: [SOLVED]How can I? -
Correlli - 21.01.2010
Quote:
Originally Posted by Jeffry
So, iґd use 150 or?
|
128 is the maximum I/O for chat-box.