Yoko

All sides of Injection
It is currently 2025-12-10 20:41:44

All times are UTC+02:00




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
 Post subject: How to count 345+556
PostPosted: 2011-06-04 19:22:34 
Offline

Joined: 2010-12-01 08:01:12
Posts: 19
Hey guys, on my shard we got a kind of jail (like a warning before they put you into real jail)
that you have to answer on a mtch questions for like 15 minutes....

question type:
<nick>: How much is 456 + 34?

and got to answer in 3s...

I dont know how to catch those two numbers into variables, so for now i have all that row from journal saved in variable ROW...

and now i need to separate those two numbers to work with that... could anybody help me please?

PS: each of those two numbers can have 1 (x), 2 (xx) or 3 (xxx) digits so i cant realy just set an exact position to cut part of the variable....


Top
   
 Post subject: Re: How to count 345+556
PostPosted: 2011-06-04 20:38:14 
Offline

Joined: 2005-04-19 18:00:29
Posts: 2259
Location: Московская область
Interesting question if there could be more operators, than '+' (-, *, /).


Top
   
 Post subject: Re: How to count 345+556
PostPosted: 2011-06-05 00:22:17 
Offline
User avatar

Joined: 2006-12-08 10:51:50
Posts: 718
Location: Москва
Парню бы помогли полезности с переведённым описанием)


Top
   
 Post subject: Re: How to count 345+556
PostPosted: 2011-06-05 13:47:15 
Offline

Joined: 2010-12-01 08:01:12
Posts: 19
so i have done some work which works up to half way
Code:
sub karibik()

  var row
  var num1 = 0
  var num2 = 0
  var i = 0
  var multiply = 1

  uo.deletejournal()

  while NOT uo.injournal("How much is")
    wait(200)
  wend

  row = uo.journal(uo.injournal('How much is')-1)

  while NOT row[i] == "?"
    i = i + 1
  wend

  i = i - 1

repeat
#uo.print(row[i])
  num2 = num2 + (row[i] * multiply)
  i = i - 1
  multiply = multiply * 10
until row[i] == " "

end sub


the variable ROW is "<NICK>: How much is 345+556?"

so if i untag the row uo.print(row[i]) then injection will print into yournal this:
6
5
5

which is GOOD!

but this script has an error BAD OPERATION FOR THIS TYPE OF VARIABLE: NUM2 on row:
num2 = num2 + (row[i] * multiply)

if i try to put a INT() or VAL() in front of row[i] then the error is gonem but uo.print(int(row[i])) or uo.print(val(row[i])) does show NOTHING at all....

so please if anybodyu can correct me?


Top
   
 Post subject: Re: How to count 345+556
PostPosted: 2011-06-05 15:38:02 
Offline

Joined: 2005-04-19 18:00:29
Posts: 2259
Location: Московская область
Well done, guy. U wrote nice start of script and i just correct this a little and finish. Now it's good calc ;)
Code:
sub karibik()
  var row
  var result = 0
  var i = 0
  var multiply = 1
  uo.deletejournal()
  while NOT uo.injournal("How much is")
    wait(200)
  wend
  row = uo.journal(uo.injournal('How much is')-1)
  while NOT row[i] == "?"
    i = i + 1
    wait(100)
  wend
  i = i - 1
  repeat
    if row[i] <> '+' then
      result = result + (val(row[i]) * multiply)
      multiply = multiply * 10
    else
      multiply = 1
    endif
    wait(500)
    i = i - 1 
  until row[i] == " "
  uo.Print('Result :' + STR(result))
end sub


Image


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 posts ] 

All times are UTC+02:00


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited