Subject : on*:TEXT: - Help Please.
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!
Any help will be much appreciated.