mi código es el siguiente:
Código PHP:
<?php
$char_id = 1;
$item_id = 15;
$item_ammount = 10;
$item_enchant = 0;
$admin = "Sk0rPi0n";
printf($char_id, $admin, KickCharacterPacket($char_id, $admin) == "x1" ? "KICKEADO" : "KICK_ERROR"); // kickea el Personaje ingame
printf($char_id, $item_id, $item_ammount, $item_enchant, $admin, AddItem2Packet($char_id, $item_id, $item_ammount, $item_enchant, $admin) == "x1" ? "GIVE_OK" : "ERROR_GIVE"); //Envia un packete que entrega X item
function tounicode($string) {
$rs = ""; for($i = 0; $i < strlen($string); $i++) $rs .= $string[$i].chr(0);
return($rs.chr(0).chr(0));
}
function KickCharacterPacket($char_id, $admin) {
$fp = fsockopen("127.0.0.1", "2012", $errno, $errstr, 5); $rs = "x";
if (!$fp) die("<script>alert('Error connecting to cached: $errstr
[server down??]')</script>");
$buf = pack("c", 5); // 4 = ChangeCharacterNamePacket();
$buf .= pack("i", $char_id); //char_id
$buf .= tounicode($admin); //new char name
fwrite($fp, pack("s", (strlen($buf)+2)).$buf);
$len = unpack("v", fread($fp, 2)); $rid = unpack("c", fread($fp, 1));
for ($i = 0; $i < (($len[1]-4) / 4); $i++) { $read = unpack("i", fread($fp, 4)); $rs .= $read[1]; }
fclose($fp); return($rs);
}
function AddItem2Packet($char_id, $item_id, $item_ammount, $item_enchant, $admin) {
$fp = fsockopen("127.0.0.1", "2012", $errno, $errstr, 5); $rs = "x";
if (!$fp) die("<script>alert('Error connecting to cached: $errstr
[server down??]')</script>");
$buf=pack("cVVVVVVVVVV",55,$char_id,0,$item_id,$item_ammount,$item_enchant,0,0,0,0,1).tounicode("$admin");
fwrite($fp, pack("s", (strlen($buf)+2)).$buf);
$len = unpack("v", fread($fp, 2)); $rid = unpack("c", fread($fp, 1));
for ($i = 0; $i < (($len[1]-4) / 4); $i++) { $read = unpack("i", fread($fp, 4)); $rs .= $read[1]; }
fclose($fp); return($rs);
}
?>
Funcionan ambas tal cual estan... pero solo funciona 1 a la vez... osea si el Personaje esta logeado... lo kickea... si esta offline... le da el item... :/
Tambien puedo chequear primero si esta o no online...
Código PHP:
printf("The character %s is %s\n", $char_id, CheckCharacterPacket($char_id) == "x1" ? "online" : "offline");
function CheckCharacterPacket($p0) {
$fp = fsockopen("127.0.0.1", "2012", $errno, $errstr, 5); $rs = "x";
if (!$fp) die("<script>alert('Error connecting to cached: $errstr
[server down??]')</script>");
$buf = pack("c", 1); // 1 = CheckCharacterPacket();
$buf .= pack("i", $p0); //char_id
fwrite($fp, pack("s", (strlen($buf)+2)).$buf);
$len = unpack("v", fread($fp, 2)); $rid = unpack("c", fread($fp, 1));
for ($i = 0; $i < (($len[1]-4) / 4); $i++) { $read = unpack("i", fread($fp, 4)); $rs .= $read[1]; }
fclose($fp); return($rs);
}
Alguna idea :/?