mIRC Home    About    Download    Register    News    Help

Print Thread
on *:TEXT: - Help Me! #232878 28/06/11 05:17 PM
Joined: Jun 2011
Posts: 10
Z
ZGoldsmith92 Offline OP
Pikka bird
OP Offline
Pikka bird
Z
Joined: Jun 2011
Posts: 10
Hi guys.

I may confuse some people here. Just cause I really don't know what I am talking about..

I am trying to get the $id attached to the end of the on *:TEXT: command so it pulls the data from the website.

Any help would be awesome!

The code is below:

Code:
// Generate names, percentages, points

on *:TEXT:@wall*:#:{

  $url = "http://www.erepublik.com/en/military/battle-log/".$id."";
  	$ch = curl_init($url);
  	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  	curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  	$getinfo = curl_exec($ch);
  	curl_close($ch);
  	
  	$orders = explode(':[', $getinfo);
  	$orders = $orders[0];
  	$orders = explode(',', $orders);
  	$winpercent = str_replace('{"domination":', '', $orders[0]);
  	$lospercent = 100 - $winpercent;
  	$curwin = str_replace('"', '', $orders[1]);
  	
  	$points = explode('"attacker_points":"', $getinfo);
  	$points = explode('"},"', $points[1]);
  	$points = explode('","', $points[0]);
  	$attpoints = $points[0];
  	$defpoints = str_replace('defender_points":"', '', $points[1]);

  	$urla = "http://api.erepublik.com/v2/feeds/battles/".$id."";
  	$ch = curl_init($urla);
  	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  	$getinfo2 = curl_exec($ch);
  	curl_close($ch);
  	$xml = simplexml_load_file($urla);
  	
  	$att = $xml->attacker->name;
  	$def = $xml->defender->name;
  	
  	$winner = $att;
  	$loser = $def;
  	
  	if ($curwin == 'defenders') {
    		$winner = $def;
  		$loser = $att; }
  		
  	$wall['att'] = $winner;
  	$wall['def'] = $loser;
  	$wall['attper'] = round($lospercent,2);
  	$wall['defper'] = round($winpercent,2);
  	$wall['attpoints'] = $attpoints;
  	$wall['defpoints'] = $defpoints;

  // Create the "bar"

  $bar = '0,12';
  $i = 0;
  while ($i < $defper) {
    	$bar .= ' ';
    	$i++;
  }

  $bar .= '0,4';
  $j = 0;
  while ($j < $attper) {
    	$bar .= ' ';
    $j++;
  }

  // Display information (change colour/bold codes for your bot)

  $send = '10Battle ID:5 '.$id.' || 10'.$wall['def'].' (D) -5 '.$wall['defper'].'% 6('.$wall['defpoints'].' points) || 10'.$wall['att'].' (A) -5 '.$wall['attper'].'% 6('.$wall['attpoints'].' points)';
}

// THEN JUST SEND THAT TO THE IRC!

Last edited by ZGoldsmith92; 28/06/11 06:16 PM.
Re: on *:TEXT: - Help Me! [Re: ZGoldsmith92] #232879 28/06/11 06:43 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
That is not mIRC script.


Invision Support
#Invision on irc.irchighway.net
Re: on *:TEXT: - Help Me! [Re: Riamus2] #232880 28/06/11 06:45 PM
Joined: Jun 2011
Posts: 10
Z
ZGoldsmith92 Offline OP
Pikka bird
OP Offline
Pikka bird
Z
Joined: Jun 2011
Posts: 10
Its a script used in IRC.

It works, Seen others use it - actually got this from someone that is using it and it is working.

If its not a IRC script, I'd like to know how he is getting it to work.

Re: on *:TEXT: - Help Me! [Re: ZGoldsmith92] #232881 28/06/11 07:08 PM
Joined: Jun 2011
Posts: 10
Z
ZGoldsmith92 Offline OP
Pikka bird
OP Offline
Pikka bird
Z
Joined: Jun 2011
Posts: 10
And, If you can't answer that question.. Answer the one below....


How do I get the ".$id." placed at the end of the @wall command?

Ex: id would be 1234

I type @wall 1234

Statistics then supposed to show in IRC channel.

Looks like this :

Code:
<+Ultramarine>  Battle ID: 7893 || Spain (D) - 51.08% (450 points) || USA (A) - 48.92% (50 points)                                                                                                 


If you can't answer that question, I don't think you belong on the mIRC forums answering peoples questions.

Re: on *:TEXT: - Help Me! [Re: ZGoldsmith92] #232883 28/06/11 08:08 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
I think before you start fighting you should consider that maybe I know what I'm talking about? That script is NOT a mIRC script. It *may* be a script for ZIRC or some other client. I don't use those, so have never looked to see which ones support scripting or what their scripting looks like. Check to see what client the people using the script are using. You'll need that client to use this script unless someone will convert it for you.

In mIRC scripting, your words for events are $1 through $N. If you typed @wall 1234, 1234 would be the second word and would therefor be $2. Whether or not that is the same with whatever language that is, I do not know.

A couple obvious ways to tell this isn't a mIRC script...
* mIRC scripts don't have semicolons at the end of each line
* []'s are not used for identifiers.. ()'s are.
* Single quotes (') are not used around strings. If anything is used, it's a normal quote ("), but in most cases, no quotes are needed.

Those are just some of the various reasons this is clearly not a mIRC script.

Scripts for one client are not compatible with any other clients.


Invision Support
#Invision on irc.irchighway.net
Re: on *:TEXT: - Help Me! [Re: ZGoldsmith92] #232884 28/06/11 08:14 PM
Joined: Feb 2011
Posts: 315
K
KindOne Offline
Fjord artisan
Offline
Fjord artisan
K
Joined: Feb 2011
Posts: 315
First off, only one line of code is mIRC, I'm guessing you added that in, and its

Code:
on *:TEXT:@wall*:#:{


Everything else is PHP. You can Google random lines of code curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if you want, and you will find PHP references.

If you have seen others run it, that's because they are running it on a PHP server/machine or whatever they are called. NOT mIRC.




irc.swiftirc.net #msl (mIRC Scripting Language)
Re: on *:TEXT: - Help Me! [Re: ZGoldsmith92] #232887 28/06/11 10:38 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
You probably shouldn't come onto a help forum with 3 posts and tell a user with 7000+ posts that they don't belong on the mIRC forums.

I mean, maybe he got really lucky in getting away with not knowing a lick about mIRC for the last 5 years, but I think it's way more likely that he's right and you're wrong. You should consider that possibility first...

Especially since you started this thread with "I don't know what I'm talking about". And that's been quite thoroughly proven.

To weigh in with the others: that code is PHP. It might be an "IRC script", but it's not an mIRC script.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: on *:TEXT: - Help Me! [Re: ZGoldsmith92] #233122 14/07/11 08:13 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
They see me trollin', they hatin'