Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Var
- conName:string;
- tutorialhtml:string;
- codeWord:string;
- correctAnswer:String;
- parsedText:string;
- lastParse:string;
- Answers:TStringList;
- options:Tstringlist;
- links:Tstringlist;
- optionsCount:integer;
- parsedCount:integer;
- timerAnswer:TTimer;
- Items:TStringList;
- Names:TStringList;
- imgoptions:TStringList;
- procedure Init;
- begin
- timerAnswer:=TTimer.Create(nil);
- timerAnswer.OnTimer:=@SendAnswer;
- timerAnswer.Enabled:=False;
- timerAnswer.Interval:=5000;
- Answers:=TStringList.Create;
- options:=TStringList.Create;
- Items:=TStringList.Create;
- Names:=TStringList.Create;
- links:=TStringList.Create;
- imgoptions:=TStringList.Create;
- Items.LoadFromFile('items.txt');
- Names.LoadFromFile('names.txt');
- optionsCount:=0;
- parsedcount:=0;
- end;
- procedure Free;
- begin
- timerAnswer.Free;
- Answers.Clear;
- options.clear;
- imgoptions.clear;
- links.clear;
- end;
- function ViewHex(hstr:string):string;
- var
- idx:integer = 1;
- begin
- result:='';
- while (idx<=length(hstr)) do begin
- result:=result+format('%.2x ',[ord(hstr[idx])]);
- inc(idx);
- end;
- end;
- procedure getoptions;
- var
- text:string=tutorialHTML;
- i,j,k:integer;
- begin
- i:=pos('button value=',text);
- j:=1;
- while i<>0 do
- begin
- text:=copy(text,i+14,length(text));
- k:=pos('"',text);
- options.add(copy(text,0,k-1));
- j:=j+1;
- i:=pos('button value=',text);
- end;
- optionsCount:=j-1;
- end;
- procedure getimgoptions;
- var
- i:integer;
- begin
- for i:=0 to optionsCount-1 do begin
- imgoptions.add(items[names.indexof(options[i])]);
- end;
- end;
- function getImganswer():string;
- var
- i:integer;
- text:string=tutorialHTML;
- begin
- text:=copy(tutorialHTML,pos('Antibot',text),length(text));
- for i:=0 to optionsCount-1 do begin
- if pos(imgoptions[i],text)<>0 then
- result:=links[i];
- end;
- end;
- function gettxtanswer():string;
- var
- i:integer;
- begin
- for i:=0 to optionsCount-1 do begin
- if options[i]=lastParse then
- result:=links[i];
- end;
- end;
- procedure getlinks;
- var
- text:string=tutorialHTML;
- i,j,k:integer;
- begin
- i:=pos('="link ',text);
- j:=1;
- while i<>0 do
- begin
- text:=copy(text,i+7,length(text));
- k:=pos('"',text);
- links.add(copy(text,0,k-1));
- j:=j+1;
- i:=pos('="link ',text);
- end;
- end;
- function parse(text:string):string;
- var
- parsedText:string;
- temp:string=text;
- i,j:integer;
- interbracket:string;
- begin
- i:=pos('>',temp);
- while i<>0 do
- begin
- if (copy(temp,i+1,1)<>'<') and (i+1<length(temp)) then
- begin
- j:=pos('<',copy(temp,i+1,length(temp)));
- interbracket:=copy(temp,i+1,j-1);
- parsedText:=parsedText+'//'+interbracket;
- lastParse:=interbracket;
- parsedcount:=parsedcount+1;
- end;
- temp:=copy(temp,i+1,length(temp));
- i:=pos('>',temp);
- end;
- result:=parsedText;
- end;
- procedure SendAnswer;
- var
- answer:string;
- begin
- buf:=Answers[1];
- Sendmsg(Answers[0]+' : '+ViewHex(buf));
- SendToServerEx(Answers[0]);
- Answers.Delete(0);
- Answers.Delete(0);
- options.clear;
- imgoptions.clear;
- links.clear;
- If Answers.Count=0 then timerAnswer.Enabled:=False;
- end;
- //main
- begin
- if fromserver then begin
- Case pck[1] of
- #$A0:begin
- conName:=ConnectName;
- tutorialHtml:=ReadS(2);
- if pos('Antibot',tutorialHtml)<>0 then
- begin
- //tutorialhtml:='<html><body><center><img src=l2warland.fb_box_new height=110 width=120><br1><table><tr><td><img src=icon.weapon_imperial_staff_i00 height=32 width=32></td><td><img src=icon.weapon_heavens_divider_i00 height=32 width=32></td><td><img src=icon.weapon_demon_splinter_i00 height=32 width=32></td><td><img src=icon.weapon_basalt_battlehammer_i00 height=32 width=32></td><td><img src=icon.weapon_angel_slayer_i00 height=32 width=32></td></tr></table><font color="LEVEL">Antibot Protection</font><br>Check Code:<font color="LEVEL"><td><img src=icon.armor_t90_g_i00 width=32 height=32></td></font><br><button value="Blessed Scroll: Enchant Armor (Grade C)" action="link 100001" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"><button value="Blessed Scroll: Enchant Armor (Grade S)" action="link 100002" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"><button value="Blue Wolf Leather Armor" action="link 100003" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"><button value="Blue Wolf Tunic" action="link 100004" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"><button value="Major Arcana Gloves" action="link 100005" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"></center></body></html>';
- //tutorialhtml:='<html><body><center><img src=l2warland.fb_box_new height=110 width=120><br1><table><tr><td><img src=icon.weapon_imperial_staff_i00 height=32 width=32></td><td><img src=icon.weapon_heavens_divider_i00 height=32 width=32></td><td><img src=icon.weapon_demon_splinter_i00 height=32 width=32></td><td><img src=icon.weapon_basalt_battlehammer_i00 height=32 width=32></td><td><img src=icon.weapon_angel_slayer_i00 height=32 width=32></td></tr></table><font color="LEVEL">Antibot Protection</font><br>Check Code:<font color="LEVEL"><td>Adonis</td></font><br><button value="soonni" action="link 100001" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"><button value="ossdoo" action="link 100002" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"><button value="isondA" action="link 100003" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"><button value="noiAid" action="link 100004" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"><button value="Adonis" action="link 100005" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"></center></body></html>';
- parsedText:= parse(tutorialHtml);
- sendmsg(parsedText);
- sendmsg(lastParse);
- getoptions;
- getlinks;
- sendmsg(options[0]+ ' '+options[1]+' '+options[2]+' '+options[3]+' '+options[4]);
- sendmsg(links[0]+ ' '+links[1]+' '+links[2]+' '+links[3]+' '+links[4]);
- if parsedcount=3 then
- begin //word
- sendmsg('it is a baby WORD');
- correctAnswer:=gettxtanswer();
- end
- else
- begin //image
- sendmsg('it is a baby IMG');
- getimgoptions;
- sendmsg(imgoptions[0]+ ' '+imgoptions[1]+' '+imgoptions[2]+' '+imgoptions[3]+' '+imgoptions[4]);
- correctAnswer:=getimganswer();
- end;
- sendMsg(correctAnswer);
- sendMsg(conName);
- buf:=hstr('7B');
- WriteS(correctAnswer);
- Answers.Add(conName);
- Answers.Add(buf);
- If Not(timerAnswer.enabled) then timerAnswer.enabled:=true;
- end;
- end;
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement