Demonho Posted April 10, 2021 Posted April 10, 2021 (edited) Hello, Need help with script, need capture info about olympiad in interlude (/olympiadstat) How can read the system messages? var p1, p2: pointer; matches, wins, loss, points : integer; OlyStat : integer; begin //1673 1 Your current record for this Grand Olympiad is $s1 match(es), $s2 win(s) and $s3 defeat(s). You have earned $s4 Olympiad Point(s). 0 79 9B B0 FF 0 0 0 0 0 none OlyStat:=1673; while (true) do begin //laSysMsg - system message appeared. P1 - message identificator (cardinal), P2 - message data (TMemoryStream). Engine.WaitAction([laSysMsg], p1, p2); if(p1=OlyStat)then begin //need read olympiad stat from p2 matches:=??? wins:=??? loss:=??? points:=??? end; end; end; Edited April 10, 2021 by Demonho
adr.bot Posted April 11, 2021 Posted April 11, 2021 uses SysUtils; var p1, p2: Pointer; Match, Win, Loss, Points: Cardinal; begin while true do begin if Engine.WaitAction([laSysMsg], p1, p2) = laSysMsg then begin if Cardinal(p1) = 1673 then begin Match := PCardinal(Cardinal(p2) + 12)^; Win := PCardinal(Cardinal(p2) + 20)^; Loss := PCardinal(Cardinal(p2) + 28)^; Points := PCardinal(Cardinal(p2) + 36)^; print(format('Match: %d; Win: %d; Loss: %d; Points: %d', [Match, Win, Loss, Points])); end; end; end; end.
Demonho Posted April 13, 2021 Author Posted April 13, 2021 Thanks adr.bot, On 4/11/2021 at 7:53 PM, adr.bot said: Match := PCardinal(Cardinal(p2) + 12)^; Win := PCardinal(Cardinal(p2) + 20)^; Loss := PCardinal(Cardinal(p2) + 28)^; Points := PCardinal(Cardinal(p2) + 36)^; changed to find the correct values: Match := PCardinal(Cardinal(p2))^; Win := PCardinal(Cardinal(p2) + 8)^; Loss := PCardinal(Cardinal(p2) + 16)^; Points := PCardinal(Cardinal(p2) + 24)^;
adr.bot Posted April 13, 2021 Posted April 13, 2021 (edited) 25 minutes ago, Demonho said: Thanks adr.bot, changed to find the correct values: Match := PCardinal(Cardinal(p2))^; Win := PCardinal(Cardinal(p2) + 8)^; Loss := PCardinal(Cardinal(p2) + 16)^; Points := PCardinal(Cardinal(p2) + 24)^; np, but it is really correct values? for example when tested (interlude) PCardinal(Cardinal(p2))^ gave me system message ID. https://prnt.sc/11c67l2 Edited April 13, 2021 by adr.bot 1
Demonho Posted April 14, 2021 Author Posted April 14, 2021 On 4/13/2021 at 11:24 AM, adr.bot said: np, but it is really correct values? for example when tested (interlude) I belive so In all tests the correct value was returned
adr.bot Posted April 14, 2021 Posted April 14, 2021 1 hour ago, Demonho said: I belive so In all tests the correct value was returned thats interesting, anyways as long as it works then good, gl!
Demonho Posted April 14, 2021 Author Posted April 14, 2021 ^^ yeah!!! In another case, for relogin purposes i need check if char is online, my idea is send a invalid command to server. If receive the Command not found, char is online. i made a test with: uses SysUtils; var p1, p2: Pointer; Match, Win, Loss, Points: Cardinal; i: integer; ret: string; begin while true do begin if Engine.WaitAction([laSysMsg], p1, p2) = laSysMsg then begin if Cardinal(p1) = 1987 then begin for i:= 0 to 44 do begin if i mod 2 <> 0 then Continue; ret:=ret+PChar(Cardinal(p2)+i)^; end; end; Print(ret); end; end; end. its correct? give me result i am expecting: SYS: Command not found. There is a better way to read p2 on this case?
adr.bot Posted April 14, 2021 Posted April 14, 2021 (edited) 28 minutes ago, Demonho said: ^^ yeah!!! In another case, for relogin purposes i need check if char is online, my idea is send a invalid command to server. If receive the Command not found, char is online. i made a test with: uses SysUtils; var p1, p2: Pointer; Match, Win, Loss, Points: Cardinal; i: integer; ret: string; begin while true do begin if Engine.WaitAction([laSysMsg], p1, p2) = laSysMsg then begin if Cardinal(p1) = 1987 then begin for i:= 0 to 44 do begin if i mod 2 <> 0 then Continue; ret:=ret+PChar(Cardinal(p2)+i)^; end; end; Print(ret); end; end; end. its correct? give me result i am expecting: SYS: Command not found. There is a better way to read p2 on this case? i would recommend read this https://adrenalinebot.com/en/api/example/packetunit-ready-unit-working-packets-adrenaline-bot because how u read seems not right. p2 should contain (in my case MessageID), Size, Type, and values by Type. thats why i dont have answer for ur question in this case, because ur system message data seems odd to me xd ps. u always can use move and check if u moved. Edited April 14, 2021 by adr.bot
Demonho Posted April 15, 2021 Author Posted April 15, 2021 On 4/14/2021 at 4:36 PM, adr.bot said: ps. u always can use move and check if u moved. see a quite more easy to implement. Tested the unitpacket, this operations os pointers is strange a lot for me, i cant see any logic here kkkkk uses SysUtils, PacketUnit; var p1, p2: Pointer; Match, Win, Loss, Points: Cardinal; i: integer; ret: string; p : TNetworkPacket; begin while true do begin if Engine.WaitAction([laSysMsg], p1, p2) = laSysMsg then begin if Cardinal(p1) = 1987 then begin p:=TNetworkPacket.Create(p2,46); Print(p.ReadS); p:=nil; end; if Cardinal(p1) = 1673 then begin p:=TNetworkPacket.Create(p2,24); Match := p.ReadD; Win := p.ReadD; Loss := p.ReadD; Points := p.ReadD; p:=nil; print(format('Match: %d; Win: %d; Loss: %d; Points: %d', [Match, Win, Loss, Points])); end; end; end; end.
adr.bot Posted April 15, 2021 Posted April 15, 2021 10 minutes ago, Demonho said: see a quite more easy to implement. Tested the unitpacket, this operations os pointers is strange a lot for me, i cant see any logic here kkkkk uses SysUtils, PacketUnit; var p1, p2: Pointer; Match, Win, Loss, Points: Cardinal; i: integer; ret: string; p : TNetworkPacket; begin while true do begin if Engine.WaitAction([laSysMsg], p1, p2) = laSysMsg then begin if Cardinal(p1) = 1987 then begin p:=TNetworkPacket.Create(p2,46); Print(p.ReadS); p:=nil; end; if Cardinal(p1) = 1673 then begin p:=TNetworkPacket.Create(p2,24); Match := p.ReadD; Win := p.ReadD; Loss := p.ReadD; Points := p.ReadD; p:=nil; print(format('Match: %d; Win: %d; Loss: %d; Points: %d', [Match, Win, Loss, Points])); end; end; end; end. well i mean to read to see idea how it getting read, and not actually use it. anyways to read string (probably, should actually test), i cant tell "Position" number because ur server positions seems odd to me. String(PChar(Cardinal(p2) + Position))
Recommended Posts