mIRC Home    About    Download    Register    News    Help

Topic Options
#232878 - 28/06/11 06:17 PM on *:TEXT: - Help Me!
ZGoldsmith92 Offline
Pikka bird

Registered: 28/06/11
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!


Edited by ZGoldsmith92 (28/06/11 07:16 PM)

Top
#232879 - 28/06/11 07:43 PM Re: on *:TEXT: - Help Me! [Re: ZGoldsmith92]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
That is not mIRC script.
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#232880 - 28/06/11 07:45 PM Re: on *:TEXT: - Help Me! [Re: Riamus2]
ZGoldsmith92 Offline
Pikka bird

Registered: 28/06/11
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.

Top
#232881 - 28/06/11 08:08 PM Re: on *:TEXT: - Help Me! [Re: ZGoldsmith92]
ZGoldsmith92 Offline
Pikka bird

Registered: 28/06/11
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.

Top
#232883 - 28/06/11 09:08 PM Re: on *:TEXT: - Help Me! [Re: ZGoldsmith92]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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

Top
#232884 - 28/06/11 09:14 PM Re: on *:TEXT: - Help Me! [Re: ZGoldsmith92]
KindOne Offline
Fjord artisan

Registered: 23/02/11
Posts: 310
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)

Top
#232887 - 28/06/11 11:38 PM Re: on *:TEXT: - Help Me! [Re: ZGoldsmith92]
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
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"

Top
#233122 - 14/07/11 09:13 PM Re: on *:TEXT: - Help Me! [Re: ZGoldsmith92]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
They see me trollin', they hatin'

Top