mIRC Homepage

I guess I need some socket info

Posted By: danzigrules

I guess I need some socket info - 05/02/07 05:31 PM

I was wondering how hard it would be to grab info from a website that list game news as a .txt file, but the info in the text file changes names at random times.

I would also like to be able to do a trigger like !who #### to display the info in mirc.

example of the txt file:

106 Toast (#106) 100 4717 Clan M 0

## Name ### land Networth Clan Government 0=N 1=Y

The government would change letters and there would be 8 in total, each one has a different letter representing them. The clan would also be different.

Would it also be possible to save the file, then the next time it polls the .txt file be able to compare any differences in them. Like say the land changed, could I trigger with !cpwho ####?
Then show what had changed and by what amount?


Thank you for your time.

Posted By: Riamus2

Re: I guess I need some socket info - 05/02/07 09:08 PM

All of that is possible, but you will need to give a link to the site/page for someone to help you with it.
Posted By: danzigrules

Re: I guess I need some socket info - 05/02/07 09:29 PM

http://a.swirve.com/data/ranks.txt

I knew I was forgetting something, as I always do laugh
Posted By: Riamus2

Re: I guess I need some socket info - 05/02/07 09:37 PM

Ok, looking at that... If you did !who #### ... what are you going to put as the #### if you were looking at the first line?

!who 76

or

!who Cirrus Minor

And I assume !cpwho #### would use the same number or name as !who does.

As for having historical data for your !cpwho command, when do you want it to update? Once and hour, once a day, once a week... ?

Finally, how much of that information do you want to store? Everything, or only parts? And do you need both numbers (76 and (#76) )?
Posted By: danzigrules

Re: I guess I need some socket info - 05/02/07 09:58 PM

!who 76 so it looks up by the number not the name, I guess it would be nice if it could do it either way laugh

same for the !cpwho, I would like to be able to compare everything, but if that is to much, I guess Networth and land are the important ones.
I guess every hour, but I suppose I would be able to change it if needed?

No I don't need both numbers, That is just the way the game does country names, it adds the number after the name.
Posted By: Riamus2

Re: I guess I need some socket info - 06/02/07 12:21 AM

Ok, here you go:

Code:
on *:start: {
  if (!$hget(NewGameData)) {
    hmake NewGameData 100
    if ($isfile($+(",$scriptdir\NewGameData.hsh"))) { hload NewGameData $+(",$scriptdir\NewGameData.hsh") }
  }
  if (!$hget(OldGameData)) {
    hmake OldGameData 100
    if ($isfile($+(",$scriptdir\OldGameData.hsh"))) { hload OldGameData $+(",$scriptdir\OldGameData.hsh") }
  }
  .timerGameData 0 3600 GameData
}

; Socket Stuff
alias GameData {
  if ($hget(OldGameData)) { hfree OldGameData }
  if ($isfile($+(",$scriptdir\OldGameData.hsh"))) { .remove $+(",$scriptdir\OldGameData.hsh") }
  if ($hget(NewGameData)) {
    hsave NewGameData $+(",$scriptdir\NewGameData.hsh")
    hfree NewGameData
  }
  hmake NewGameData 100
  hmake OldGameData 100
  if ($isfile($+(",$scriptdir\NewGameData.hsh"))) {
    hload OldGameData $+(",$scriptdir\NewGameData.hsh")
    hsave OldGameData $+(",$scriptdir\OldGameData.hsh")
  }
  sockopen GameData a.swirve.com 80
}

on *:sockopen:GameData: {
  sockwrite -n $sockname GET /data/ranks.txt HTTP/1.0
  sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)
  sockwrite -n $sockname Host: a.swirve.com
  sockwrite -n $sockname Accept-Language: en-us
  sockwrite -n $sockname Accept-Encoding: gzip, deflate
  sockwrite -n $sockname Accept: */* $+ $crlf $+ $crlf
}

on *:sockread:GameData: {
  if ($sockerr) {
    echo -a Error.
    halt
  }
  else {
    var %temptext
    sockread %temptext
    if (!%temptext) { hsave NewGameData $+(",$scriptdir\NewGameData.hsh") | halt }
    tokenize 32 $gettok(%temptext,2-,41)
    hadd NewGameData $gettok(%temptext,1,32) $gettok($gettok(%temptext,2-,32),1,40) 03 $1 03 $2 03 $iif($5,$3 03 $4 03 $5,03 $3 03 $4)
  }
}

; Trigger Stuff
on *:text:!who &:#yourchannel: {
  if ($hget(NewGameData,$2)) {
    msg $chan $2 $+ : $v1
  }
  else msg $chan No data on $2 $+ .
}

on *:text:!cpwho &:#yourchannel: {
  if ($hget(OldGameData,$2) || $hget(NewGameData,$2)) {
    if ($hget(OldGameData,$2) && $hget(NewGameData,$2)) {
      msg $chan New Data for $2 $+ : $hget(NewGameData,$2)
      msg $chan Old Data for $2 $+ : $hget(OldGameData,$2)
    }
    elseif ($hget(NewGameData,$2)) {
      msg $chan New Data for $2 $+ : $hget(NewGameData,$2)
      msg $chan Old Data for $2 $+ : N/A
    }
    else {
      msg $chan New Data for $2 $+ : N/A
      msg $chan Old Data for $2 $+ : $hget(OldGameData,$2)
    }
  }
  else msg $chan No data on $2 $+ . 
}

on *:input:#yourchannel: {
  if ($1 == !who && $2) {
    if ($hget(NewGameData,$2)) {
      msg $chan $2 $+ : $v1
    }
    else msg $chan No data on $2 $+ .
  }
  elseif ($1 == !cpwho && $2) {
    if ($hget(OldGameData,$2) || $hget(NewGameData,$2)) {
      if ($hget(OldGameData,$2) && $hget(NewGameData,$2)) {
        msg $chan New Data for $2 $+ : $hget(NewGameData,$2)
        msg $chan Old Data for $2 $+ : $hget(OldGameData,$2)
      }
      elseif ($hget(NewGameData,$2)) {
        msg $chan New Data for $2 $+ : $hget(NewGameData,$2)
        msg $chan Old Data for $2 $+ : N/A
      }
      else {
        msg $chan New Data for $2 $+ : N/A
        msg $chan Old Data for $2 $+ : $hget(OldGameData,$2)
      }
    }
    else msg $chan No data on $2 $+ . 
  }
}


You'll need to change 3 #yourchannel things to your channel name or to # for all channels.

Also, you may want to change the formatting of how the text is output to the channel. To change how the pieces of data are output to the channel, look for the line that starts with "hadd". You can adjust the 03 parts to change the character/color between each piece of data. Right now, only that character is colored, but you can also color the other text if you want to. I'd recommend having it a different color than the dividing character so you can easily see what is what. To change the beginning text on the line, just look for the lines that start with "msg $chan".

At the top, you'll find a timer. Change the 3600 to the number of seconds you want between getting new data. 3600 == 1 hour. I didn't bother making some setup screen for just that one thing.

It is also set up to handle !who and !cpwho from other users and also from the bot (only in the specified channel(s) ). I didn't put a way to look it up by the name instead of the number. If you really think that would be used, let me know and I can throw in that part for you using $hfind.

Any questions, just ask. You'll want to restart mIRC after loading the script to get the timer started.

If you don't want to restart, you can just type the timer line (with a / in front of it) into your edit box and hit enter and then type /gamedata and hit enter to load in the data. (That /gamedata part is not needed if you restart mIRC).
Posted By: danzigrules

Re: I guess I need some socket info - 06/02/07 12:40 AM

Thank you so much,

So far it works great, waiting for the timer to countdown to get the new data.

If it isn't much more to do it by name too, that would be great.


Again thank you very much
Posted By: Riamus2

Re: I guess I need some socket info - 06/02/07 01:37 AM

Try this one for allowing searches with names instead of just numbers. I could have shortened it by putting things into aliases, but this way it can easily be adjusted.

Code:
on *:start: {
  if (!$hget(NewGameData)) {
    hmake NewGameData 100
    if ($isfile($+(",$scriptdir\NewGameData.hsh"))) { hload NewGameData $+(",$scriptdir\NewGameData.hsh") }
  }
  if (!$hget(OldGameData)) {
    hmake OldGameData 100
    if ($isfile($+(",$scriptdir\OldGameData.hsh"))) { hload OldGameData $+(",$scriptdir\OldGameData.hsh") }
  }
  .timerGameData 0 3600 GameData
  GameData
}

; Socket Stuff
alias GameData {
  if ($hget(OldGameData)) { hfree OldGameData }
  if ($isfile($+(",$scriptdir\OldGameData.hsh"))) { .remove $+(",$scriptdir\OldGameData.hsh") }
  if ($hget(NewGameData)) {
    hsave NewGameData $+(",$scriptdir\NewGameData.hsh")
    hfree NewGameData
  }
  hmake NewGameData 100
  hmake OldGameData 100
  if ($isfile($+(",$scriptdir\NewGameData.hsh"))) {
    hload OldGameData $+(",$scriptdir\NewGameData.hsh")
    hsave OldGameData $+(",$scriptdir\OldGameData.hsh")
  }
  sockopen GameData a.swirve.com 80
}

on *:sockopen:GameData: {
  sockwrite -n $sockname GET /data/ranks.txt HTTP/1.0
  sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)
  sockwrite -n $sockname Host: a.swirve.com
  sockwrite -n $sockname Accept-Language: en-us
  sockwrite -n $sockname Accept-Encoding: gzip, deflate
  sockwrite -n $sockname Accept: */* $+ $crlf $+ $crlf
}

on *:sockread:GameData: {
  if ($sockerr) {
    echo -a Error.
    halt
  }
  else {
    var %temptext
    sockread %temptext
    if (!%temptext) { hsave NewGameData $+(",$scriptdir\NewGameData.hsh") | halt }
    tokenize 32 $gettok(%temptext,2-,41)
    hadd NewGameData $gettok(%temptext,1,32) $gettok($gettok(%temptext,2-,32),1,40) 03 $1 03 $2 03 $iif($5,$3 03 $4 03 $5,03 $3 03 $4)
  }
}

; Trigger Stuff
on *:text:!who *:#yourchannel: {
  if ($2 isnum && !$3) {
    if ($hget(NewGameData,$2)) {
      msg $chan $2 $+ : $v1
    }
    else msg $chan No data on $2 $+ .
  }
  else {
    if ($hfind(NewGameData,$2- $+ *,0,w).data > 0) {
      if ($hfind(NewGameData,$2- $+ *,0,w).data > 1) {
        msg $chan Too many results for $2- $+ .  Be more specific, or use the number instead of the name.
      }
      else {
        var %data = $hfind(NewGameData,$2- $+ *,1,w).data
        msg $chan %data $+ : $hget(NewGameData,%data)
      }
    }
    else msg $chan No data for $2- $+ .
  }
}

on *:text:!cpwho *:#yourchannel: {
  if ($2 isnum && !$3) {
    if ($hget(OldGameData,$2) || $hget(NewGameData,$2)) {
      if ($hget(OldGameData,$2) && $hget(NewGameData,$2)) {
        msg $chan New Data for $2 $+ : $hget(NewGameData,$2)
        msg $chan Old Data for $2 $+ : $hget(OldGameData,$2)
      }
      elseif ($hget(NewGameData,$2)) {
        msg $chan New Data for $2 $+ : $hget(NewGameData,$2)
        msg $chan Old Data for $2 $+ : N/A
      }
      else {
        msg $chan New Data for $2 $+ : N/A
        msg $chan Old Data for $2 $+ : $hget(OldGameData,$2)
      }
    }
    else msg $chan No data on $2 $+ . 
  }
  else {
    if ($hfind(NewGameData,$2- $+ *,0,w).data > 0) {
      if ($hfind(NewGameData,$2- $+ *,0,w).data > 1) {
        msg $chan Too many results for $2- $+ .  Be more specific, or use the number instead of the name.
      }
      else {
        var %data = $hfind(NewGameData,$2- $+ *,1,w).data
        if ($hget(OldGameData,%data) || $hget(NewGameData,%data)) {
          if ($hget(OldGameData,%data) && $hget(NewGameData,%data)) {
            msg $chan New Data for %data $+ : $hget(NewGameData,%data)
            msg $chan Old Data for %data $+ : $hget(OldGameData,%data)
          }
          elseif ($hget(NewGameData,%data)) {
            msg $chan New Data for %data $+ : $hget(NewGameData,%data)
            msg $chan Old Data for %data $+ : N/A
          }
          else {
            msg $chan New Data for %data $+ : N/A
            msg $chan Old Data for %data $+ : $hget(OldGameData,%data)
          }
        }
      }
    }
    else msg $chan No data for $2- $+ .
  }
  else msg $chan No data on $2 $+ . 
}

on *:input:#yourchannel: {
  if ($1 == !who && $2) {
    if ($2 isnum && !$3) {
      if ($hget(NewGameData,$2)) {
        msg $chan $2 $+ : $v1
      }
      else msg $chan No data on $2 $+ .
    }
    else {
      if ($hfind(NewGameData,$2- $+ *,0,w).data > 0) {
        if ($hfind(NewGameData,$2- $+ *,0,w).data > 1) {
          msg $chan Too many results for $2- $+ .  Be more specific, or use the number instead of the name.
        }
        else {
          var %data = $hfind(NewGameData,$2- $+ *,1,w).data
          msg $chan %data $+ : $hget(NewGameData,%data)
        }
      }
      else msg $chan No data for $2- $+ .
    }
  }
  elseif ($1 == !cpwho && $2) {
    if ($2 isnum && !$3) {
      if ($hget(OldGameData,$2) || $hget(NewGameData,$2)) {
        if ($hget(OldGameData,$2) && $hget(NewGameData,$2)) {
          msg $chan New Data for $2 $+ : $hget(NewGameData,$2)
          msg $chan Old Data for $2 $+ : $hget(OldGameData,$2)
        }
        elseif ($hget(NewGameData,$2)) {
          msg $chan New Data for $2 $+ : $hget(NewGameData,$2)
          msg $chan Old Data for $2 $+ : N/A
        }
        else {
          msg $chan New Data for $2 $+ : N/A
          msg $chan Old Data for $2 $+ : $hget(OldGameData,$2)
        }
      }
      else msg $chan No data on $2 $+ . 
    }
    else {
      if ($hfind(NewGameData,$2- $+ *,0,w).data > 0) {
        if ($hfind(NewGameData,$2- $+ *,0,w).data > 1) {
          msg $chan Too many results for $2- $+ .  Be more specific, or use the number instead of the name.
        }
        else {
          var %data = $hfind(NewGameData,$2- $+ *,1,w).data
          if ($hget(OldGameData,%data) || $hget(NewGameData,%data)) {
            if ($hget(OldGameData,%data) && $hget(NewGameData,%data)) {
              msg $chan New Data for %data $+ : $hget(NewGameData,%data)
              msg $chan Old Data for %data $+ : $hget(OldGameData,%data)
            }
            elseif ($hget(NewGameData,%data)) {
              msg $chan New Data for %data $+ : $hget(NewGameData,%data)
              msg $chan Old Data for %data $+ : N/A
            }
            else {
              msg $chan New Data for %data $+ : N/A
              msg $chan Old Data for %data $+ : $hget(OldGameData,%data)
            }
          }
        }
      }
      else msg $chan No data for $2- $+ .
    }
    else msg $chan No data on $2 $+ . 
  }
}


To test, try:

!who Cirrus Minor
!who Cirrus
!who C
!who 76

You can try those with !cpwho as well. All except the third will result in the data being displayed. You don't need to enter the entire name, but you need to enter enough of it so that only one name matches. That's why "C" won't work, but "Cirrus" will. Note that it searches in the form of $2* (not *$2*). So you can't search for "!who Minor". This was done purposely to allow you to search with the fewest letters possible. In this case, you can use "!who Cir" and you'll get your results.
Posted By: danzigrules

Re: I guess I need some socket info - 06/02/07 06:06 AM

everything is working just great. laugh

someone had a thought though, would it be possible to make the triggers, trigger the timer to download the txt file and say something like, Getting current info, then spit out the result.
I guess it would also need a way to keep it from getting the txt file if someone had just searched in say the last 5-10 minutes.

Without having to change a bunch of the script you did?


Thanks
Posted By: Riamus2

Re: I guess I need some socket info - 06/02/07 02:00 PM

To have it display "Getting Data," just add a line below this:
Code:
alias GameData {


After that line, insert:
Code:
msg #yourchannel Getting Data...


If you want it to also say "Done," then edit this line:
Code:
    if (!%temptext) { hsave NewGameData $+(",$scriptdir\NewGameData.hsh") | halt }



Make it like this:
Code:
    if (!%temptext) { hsave NewGameData $+(",$scriptdir\NewGameData.hsh") | msg #yourchannel Done. | halt }



Just replace #yourchannel with the channel name.

As for having it download based on the triggers, that will affect your !cpwho command. If people are using it regularly, then that will make the data be the same for both old and new almost all of the time unless the data is changing every few minutes on the site. Also, you can make it download more often than once and hour if you think that's an issue. Personally, I wouldn't make the triggers cause it to download something. If I were you, I'd find out how often the data on the site changes (if it's a regular interval) or else find out the average amount of time between changes (if it's not a regular interval). Then I would have it download data a little bit after that change.

For example, if the site updated every 30 minutes (every time the minute hand is on the 6 and the 12), then I'd have your script update every 30 minutes (every time the minute hand is on the 7 and 1). That would keep it updated regularly with the site for you. To do that would mean starting the timer at the right time and setting it to the right interval, of course.
Posted By: danzigrules

Re: I guess I need some socket info - 08/02/07 08:21 AM

sorry for the delay in responding, waterlines freezing is not any fun frown

Got the Getting data to work, which is nice. I see your point about the trigger pulling the info. This is working wonderfully.

Few more things to ask of you. Is there a way to add commas to the Networth output? So it doesn't all run together.

888: country name 03 Land: 17220 03 NetWorth: 46996633 03 removed 03 H 03 1

Can I just move the parts of this line:

hadd NewGameData $gettok(%temptext,1,32) $gettok($gettok(%temptext,2-,32),1,40) 03 Land: $1 03 NetWorth: $2 03 $iif($5,$3 03 $4 03 $5,03 $3 03 $4)
}
To make the output more like:

0Oh My Gosh (#212) Communism Rank: 21 Networth: 637,594 Land: 3191 Tag: GDI: 0

Can the Rank be added to the script you wrote? The Rank is what ever line that country is on. 1 top - whatever at the bottom.

Thank you
Posted By: Riamus2

Re: I guess I need some socket info - 08/02/07 02:24 PM

For now, here's the change to the SOCKREAD event:

Code:
on *:sockread:GameData: {
  if ($sockerr) {
    echo -a Error.
    halt
  }
  else {
    var %temptext
    sockread %temptext
    if (!%temptext) { hsave NewGameData $+(",$scriptdir\NewGameData.hsh") | unset %rank.cnt | halt }
    inc %rank.cnt
    tokenize 32 $gettok(%temptext,2-,41)
    hadd NewGameData $gettok(%temptext,1,32) 0 $+ $gettok($gettok(%temptext,2-,32),1,40) (# $+ $gettok(%temptext,1,32) $+ $chr(41) 03 Land: $bytes($1,b) 03 NetWorth: $bytes($2,b) 03 $iif($5,$3 03 $4 03 $5,03 $3 03 $4) 03 Rank: %rank.cnt
  }
}


I did't reorder it because I'm not sure what goes where. wink

Can you display the output as it is right now for one of them and then display how you want it to look for the same one? That way I know what numbers are going where.
Posted By: danzigrules

Re: I guess I need some socket info - 08/02/07 03:45 PM

how it is now:

212: 0Test (#212) 03 Land: 16,661 03 NetWorth: 4,466,503 03 03 Clan 03 R 03 Rank: 908


how I would like it:

Test (#212) 03 Rank: 908 03 Networth: 4,466,503 03 Land: 16,661 03 Clan 03 Republic 03 GDI: 0

would it be possible to make it turn the R into repulic like is the second example? The letter break down is:

M=Monarchy D=Democracy R=Republic H=Theocracy C=Communism I=Dictatorship T=Tyranny F=Fascism



Thank You
Posted By: Riamus2

Re: I guess I need some socket info - 08/02/07 07:19 PM

Ok, here's the new SOCKREAD:

Code:
on *:sockread:GameData: {
  if ($sockerr) {
    echo -a Error.
    halt
  }
  else {
    var %temptext
    sockread %temptext
    if (!%temptext) { hsave NewGameData $+(",$scriptdir\NewGameData.hsh") | unset %rank.cnt | halt }
    inc %rank.cnt
    tokenize 32 $gettok(%temptext,2-,41)
    var %Government = $replace($iif($5,$5,$4),M,Monarchy,D,Democracy,R,Republic,H,Theocracy,C,Communism,I,Dictatorship,T,Tyranny,F,Fascism)
    hadd NewGameData $gettok(%temptext,1,32) 0 $+ $gettok($gettok(%temptext,2-,32),1,40) (# $+ $gettok(%temptext,1,32) $+ $chr(41) 03 Rank: %rank.cnt 03 NetWorth: $bytes($2,b) 03 Land: $bytes($1,b) 03 $iif($5,$3 03 $4,03 $3)  03 %Government
  }
}


I'm not sure what the GDI is. See what you think.
Posted By: danzigrules

Re: I guess I need some socket info - 08/02/07 07:57 PM

Originally Posted By: Riamus2
Ok, here's the new SOCKREAD:

Code:
on *:sockread:GameData: {
  if ($sockerr) {
    echo -a Error.
    halt
  }
  else {
    var %temptext
    sockread %temptext
    if (!%temptext) { hsave NewGameData $+(",$scriptdir\NewGameData.hsh") | unset %rank.cnt | halt }
    inc %rank.cnt
    tokenize 32 $gettok(%temptext,2-,41)
    var %Government = $replace($iif($5,$5,$4),M,Monarchy,D,Democracy,R,Republic,H,Theocracy,C,Communism,I,Dictatorship,T,Tyranny,F,Fascism)
    hadd NewGameData $gettok(%temptext,1,32) 0 $+ $gettok($gettok(%temptext,2-,32),1,40) (# $+ $gettok(%temptext,1,32) $+ $chr(41) 03 Rank: %rank.cnt 03 NetWorth: $bytes($2,b) 03 Land: $bytes($1,b) 03 $iif($5,$3 03 $4,03 $3)  03 %Government
  }
}


I'm not sure what the GDI is. See what you think.


Close laugh

212: 0Test(#212) 03 Rank: 911 03 NetWorth: 4,445,201 03 Land: 16,661 03 03 Clan 03 RepublDicTyrannyaTyrannyorshipCommunDicTyrannyaTyrannyorshipsm

and yes I am changing the Clan part laugh

GDI is just a Y or N , 1 = Y , 0 = N
Posted By: Riamus2

Re: I guess I need some socket info - 08/02/07 10:28 PM

Ok, this may be it. (can't test right now)

Code:
on *:sockread:GameData: {
  if ($sockerr) {
    echo -a Error.
    halt
  }
  else {
    var %temptext
    sockread %temptext
    if (!%temptext) { hsave NewGameData $+(",$scriptdir\NewGameData.hsh") | unset %rank.cnt | halt }
    inc %rank.cnt
    tokenize 32 $gettok(%temptext,2-,41)
    var %Government = $replacex($iif($5,$4,$3),M,Monarchy,D,Democracy,R,Republic,H,Theocracy,C,Communism,I,Dictatorship,T,Tyranny,F,Fascism)
    hadd NewGameData $gettok(%temptext,1,32) 0 $+ $gettok($gettok(%temptext,2-,32),1,40) (# $+ $gettok(%temptext,1,32) $+ $chr(41) 03 Rank: %rank.cnt 03 NetWorth: $bytes($2,b) 03 Land: $bytes($1,b) 03 $iif($5,$3 03,03) 03 %Government 03 GDI: $iif($5,$5,$4)
  }
}
Posted By: danzigrules

Re: I guess I need some socket info - 08/02/07 10:47 PM

212: 0I Hate This Game (#212) 03 Rank: 909 03 NetWorth: 4,445,201 03 Land: 16,661 03 03 03 RepublicDictatorshipval 03 GDI: R


frown

Thanks for working on this so much smile
Posted By: Riamus2

Re: I guess I need some socket info - 08/02/07 11:56 PM

Code:
on *:sockread:GameData: {
  if ($sockerr) {
    echo -a Error.
    halt
  }
  else {
    var %temptext
    sockread %temptext
    if (!%temptext) { hsave NewGameData $+(",$scriptdir\NewGameData.hsh") | unset %rank.cnt | halt }
    inc %rank.cnt
    tokenize 32 $gettok(%temptext,2-,41)
    var %Government = $replacex($iif($5 != $null,$4,$3),M,Monarchy,D,Democracy,R,Republic,H,Theocracy,C,Communism,I,Dictatorship,T,Tyranny,F,Fascism)
    hadd NewGameData $gettok(%temptext,1,32) 0 $+ $gettok($gettok(%temptext,2-,32),1,40) (# $+ $gettok(%temptext,1,32) $+ $chr(41) 03 Rank: %rank.cnt 03 NetWorth: $bytes($2,b) 03 Land: $bytes($1,b) 03 $iif($5 != $null,$3 03,03) %Government 03 GDI: $iif($5 != $null,$5,$4)
  }
}


Firgured it out. It was because the check for $5 failed to work properly if the last item (GDI) was 0. It should be fine now. (I hope) wink
Posted By: danzigrules

Re: I guess I need some socket info - 09/02/07 02:19 AM

Thanks,
That works now, but search by name doesn't work anymore.

Did the changes in the code affect that?


Posted By: Riamus2

Re: I guess I need some socket info - 09/02/07 03:00 AM

That was because of the "0" that you wanted at the beginning of the line. If you don't need that, then just remove "0 $+" from the hadd line.

If you do want it, then we'll need to make some changes. Just let me know if you want it or not.
Posted By: danzigrules

Re: I guess I need some socket info - 09/02/07 05:44 PM

ok that fixed it and is working great.

how does it find the specific # though?

I am just wondering, because I am just trying to do a simple script to trigger a specific line of a .txt file, that is on my machine. It is a list of phone #'s that I want to msg the user that requests the info for a specific person.

I feel bad for asking, and want to learn. frown
Posted By: Riamus2

Re: I guess I need some socket info - 09/02/07 10:18 PM

It uses hash tables and the item name is the number, so I just grab the data by using the $hget command on that item name (number).

If you want to use a text file, then use $read with the "s" or "w" parameters to search for what you're looking for.
© 2019 mIRC Discussion Forums