ok I added some changes, backup what you have just so you can always go back, but give this section of the code a try:
[php]
thanks this works great now. i got both problems fixed (botowner and switch)
the only bug in the script was a ] after $botowner in the if statements but i just deleted them and it works.
ill add them to the rest of the owner commands. i dont want you to do it all for me so i can learn too
thanks for your help and im sure ill be ack here for more questions in the future ;D
actually i have one last problem. sometimes whenever i try to run it on a chat i get an old flash error that i dont know how to fix. It runs in the command prompt and i have no idea how to fix it. It just says an old chat is being used (its not an old chat) and to upgrade flash to fix it but it is updated. not sure if you would know how to fix that. its xat chats by the way if you havent figured that out already
try clearing your browser cache, then close the browser and give it a shot again sometimes it can be a cache issue since flash files get cached like images and mp3’s etc. if everything is up to date then that would most likely be the culprit. I doubt it would be due to old version of flash if it is telling you it is an old chat, but you never know. Yes I noticed it was xat 8) I love that chat. I am glad you got it all straight now!
ive tried the cache before and it never seemed to work. ive had very slim luck wiht turning my proxy on and off and restarting by broswer but if a chats on promotion it almost never works
also, im trying to add another function to member registered users only and im getting an error.
heres what i did
[php] if("$info[rank]"==“guest” && “$automem”==“on”)
$this->member($data[‘id’]);
if("$info[rank]"==“guest” && “$info[‘registeredName’]”!=’’ && “$automem”==“registered”)
$this->member($data[‘id’]);[/php]
the error is on that 3rd line but the other works. i added the registered command already after the on and off ones so it should be fine. some people just only want registered users to be members and i didn’t want to have to have 2 main scripts to be messing around with when i could have one main one.
I dont believe these should be in quotes
“$info[‘registeredName’]”
“$info[rank]”
could be wrong but I think take them out of quotes, also did you add a new section which would register the variable $automem as “regististered” cause when we last left off it was only “on” or"off"?
i tried it without quotes but it didnt work. the error didnt show but the command didnt go. and yes i did add another elseif for registered
do what you have to, to have it echo out
$info[rank]
$info[‘registeredName’]
$automem
I am betting they are empty or not what they need to be to fill the if statement!
yeah i did it before but deleted the script because i was going to put it all on one. i dindt bother to look at that part and remember it or copy it down though. i just made a small command to say that to figure out which one i needed so ill jsut do that again
well i removed the quotes before and it didnt work but now it is ???
i think i might of been editing another one i had at the time so i wasnt editing the one i was testing and when i realized it i never tried that but idk
works:
[php]if("$info[rank]"==“guest” && $info[‘registeredName’]!=’’ && “$automem”==“registered”)[/php]
thanks for all your help so far. im sure ill be back with more questions
im still getting this flash error. i cleared my browsing data, tried the proxy, restarted my browser and nothing. the error points to this part of the script
[php]function read($parse=true) {
$res = rtrim(socket_read($this->soc, 4096));
if($this->debug)echo “<<-\t$res\n”;
if(!$res) {
return “DIED”; //Used to gracefully handle a closed socket
}
if($res{strlen($res)-1}!=’>’) { $res.=$this->read(false);} //Recursive call for messages split over several packets.
if($parse)$this->parse($res);
return $res;
}[/php]
heres a snapshot of the error: http://prntscr.com/2c3n7 (i just made a batch file to run the bots easily instead of going through cmd every time i can just open it and type in the name to run)
if you could help me with this it would be greatly appreciated since it does this very often
its pointing to the second line of that btw
are you sure that you have secure sockets enabled?
not sure what you mean. heres the second half of the script if it helps you tell. the first half issues the connection and all that but this has all the functions and stuff in it
[php] /* ****************************************************** /
/ YOU SHOULD NOT NEED TO EDIT ANYTHING AFTER TH
IS LINE /
/ ****************************************************** /
/*
* Connects to a given ip on the given port
* @param $ip The IP to connect to.
* @param $port The port on the IP to connect to.
*/
function connect($ip, $port) {
if($this->soc!=null) socket_close($this->soc);
$this->soc = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
if(!$this->soc) die(socket_strerror(socket_last_error($this->soc)));
if(!socket_connect($this->soc,$ip,$port)) die(“Could not connect.”);
}
/**
* Writes the given message to the object socket($this->soc)
* @param $message The packet to send.
*/
function send($message) {
if($this->debug)echo "->>\t$message\n";
socket_write($this->soc, $message."\0", strlen($message)+1);
}
/**
* Reads a message from the socket, will read until entire message has been recieved or connection closes.
* @param $parse Used for recursive calls to tell the function not to parse a partial packet
*/
function read($parse=true) {
$res = rtrim(socket_read($this->soc, 4096));
if($this->debug)echo "<<-\t$res\n";
if(!$res) {
return "DIED"; //Used to gracefully handle a closed socket
}
if($res{strlen($res)-1}!='>') { $res.=$this->read(false);} //Recursive call for messages split over several packets.
if($parse)$this->parse($res);
return $res;
}
/**
* Parses the recieved packets into their message and types.
* @param $packet The packet recieved.
*/
function parse($packet) {
if(substr_count($packet,'>')>1) $packet = explode('/>',$packet);//If necessary split the packet into individual messages
foreach((Array)$packet as $p) {
$p = trim($p);
if(strlen($p)<5) return;//garbage data
$type = trim(strtolower(substr($p,1,strpos($p.' ',' '))));//packet type
$p = trim(str_replace("<$type",'',str_replace('/>','',$p)));//remove details so it is just the info to be parsed
parse_str(str_replace('"','',str_replace('" ','&',str_replace('="','=',str_replace('&','__38',$p)))),$this->packet[$type]);
foreach($this->packet[$type] as $k=>$v) {
$this->packet[$type][$k] = str_replace('__38','&',$v); //htmlspecial chars are protected instead of being parsed
}
$this->handle($type,$p);
}
}
/**
* This is the inital handler for the packets, parses them and sends them off to their respective function to be handled further.
* @param $type The character code indicating the type of data within the message.
* @param $message The data the message contains.
*/
function handle($type,$msg) {
switch($type) {
case 'gp':
if(isset($this->packet['gp']['x']))
$this->send('<x i="'.$this->packet['gp']['x'].'" u="'.$this->userID.'" t="j" />'); //Handle groups
break;
case 'q'://XAT notice to change ip/port
$this->connect($this->packet['q']['d'], $this->packet['q']['p']);
$this->join($this->roomID);
break;
case 'o':
$this->packet['o']['u'] = $this->parseU(@$this->packet['u']['u']);
$this->userInfo[$this->packet['o']['u']]['name'] = @$this->packet['o']['n'];
$this->userInfo[$this->packet['o']['u']]['registeredName'] = ((isset($this->packet['o']['N']))?$this->packet['o']['N']:'');
$this->userInfo[$this->packet['o']['u']]['avatar'] = @$this->packet['o']['a'];
$this->userInfo[$this->packet['o']['u']]['homepage'] = @$this->packet['o']['h'];
$this->userInfo[$this->packet['o']['u']]['rank'] = $this->f2rank(@$this->packet['o']['f']);
break;
case 'u':
//Joined
//Default Bot stuff regarding userInformation
$this->packet['u']['u'] = $this->parseU(@$this->packet['u']['u']);
$this->userInfo[$this->packet['u']['u']]['name'] = @$this->packet['u']['n'];
$this->userInfo[$this->packet['u']['u']]['registeredName'] = ((isset($this->packet['u']['N']))?$this->packet['u']['N']:'');
$this->userInfo[$this->packet['u']['u']]['avatar'] = @$this->packet['u']['a'];
$this->userInfo[$this->packet['u']['u']]['homepage'] = @$this->packet['u']['h'];
$this->userInfo[$this->packet['u']['u']]['rank'] = $this->f2rank(@$this->packet['u']['f']);
$event = 'userJoined';
$data['id'] = $this->packet['u']['u'];
$data['old'] = ($type=='o'||(isset($this->packet['u']['s']))?true:false);
$this->handleEvent($event,$data);
break;
case 'l':
//User Left or was kicked, banned
unset($this->userInfo[$this->packet['l']['u']]);
$event = 'userLeft';
$data['id'] = $this->packet['l']['u'];
$this->handleEvent($event,$data);
break;
case 'p':
//Private message/chat recieved
$event = ((isset($this->packet['p']['d']))?'privateChat':'privateMessage');
$data['id'] = $this->parseU(@$this->packet['p']['u']);
$data['message'] = $this->packet['p']['t'];
$this->handleEvent($event,$data);
break;
case 'm':
//message to main chat.
$event = 'message';
$data['id'] = $this->parseU(@$this->packet['m']['u']);
$data['message'] = $this->packet['m']['t'];
$data['old'] = ((isset($this->packet['m']['s']))?true:false);
$this->handleEvent($event,$data);
break;
}
}
/**
* Joins a room.
* @param $roomID the numeric roomID to join.
*/
function join($roomID) {
//Announce we are here:
$this->send('<y m="1" />');//Anounces our arrival to the server and gets some information to send back
$this->read(); //Auto parsed into $this->packet['y']
$this->send('<j2 q="1" y="'.$this->packet['y']['i'].'" k="'.$this->k.'" k3="0" z="12" p="0" c="'.$roomID.'" f="0" u="'.$this->userID.'" d0="0" n="'.$this->name.'" a="'.$this->avatar.'" h="'.$this->homepage.'" v="0" />');
$this->roomID = $roomID;
}
/**
* Parses the u value from a packet to get just the id
* @param $id the id to be parsed.
*/
function parseU($id) {
if(substr_count($id,'_')>=1) $id = substr($id,0,strpos($id,'_'));
return $id;
}
/**
* Converts an f value to a string containing the corresponding rank...this if you don't understand bitwise operations is a little 'magical' deal with it.
* @param $f The f value to be parsed.
*/
function f2rank($f) {
$f = $this->parseU($f);
if($f==-1) return 'guest';
//Okay, 98% of you reading this on NewHax won't know what any of this means; if you do you are more adnvanced than I expected
//Not that this is advnaced stuff, but basiclly it is a bit-wise comparision(notice & instead of && it is checking if certain binary bits are set to 1
//The F value is essientially a bunch of flags where for example 00010000 == banned(the 0s can be 0 or 1, just as long as that one 1 is a one you are banned.
if((16 & $f)) return 'banned';
if((1 & $f)&&(2 & $f)) return 'member';
if((4 & $f)) return 'owner';
if((32 & $f)&&(1 & $f)&&!(2 & $f)) return 'main';
if(!(1 & $f)&&!(2 & $f)) return 'guest';
if((16 & $f)) return 'banned';
if((2 & $f)&&!(1 & $f)) return 'mod';
}
/**
* Returns an assoc array of information regarding the user with the given id
* @param $id The user id you want information on.
*/
function getUserArray($id) {
$id = $this->parseU($id);
if(isset($this->userInfo[$id])) {
return $this->userInfo[$id];
} else return false;
}
/**
* Sends the given message to the main chat
* @param $message
*/
function sendMessage($message) {
if(empty($message))return;
$this->send('<m t="'.$message.'" u="'.$this->userID.'" />');
}
/**
* Sends a PC to the given ID
* @param $message The message to send.
* @param $id The id to send the message to
*/
function sendPrivateChat($message, $id) {
if(empty($message))return;
$this->send('<p u="'.$id.'" t="'.$message.'" s="2" d="'.$this->userID.'" />');
}
/**
* Sends a PM to the given ID
* @param $message The message to send.
* @param $id The id to send the message to
*/
function sendPrivateMessage($message,$id) {
$id = $this->parseU($id);
if(empty($message))return;
$this->send('<p u="'.$id.'" t="'.$message.'" />');
}
/**
* Makes the given $id an owner, assuming the bot is main
* @param $id The id to promote
*/
function owner($id) {
$this->send('<c u="'.$this->parseU($id).'" t="/M" />');
}
/**
* Makes the given $id a mod, assuming the bot is owner
* @param $id The id to promote
*/
function mod($id) {
$this->send('<c u="'.$this->parseU($id).'" t="/m" />');
}
/**
* Makes the given $id a member, assuming the bot is mod
* @param $id The id to member
*/
function member($id) {
$this->send('<c u="'.$this->parseU($id).'" t="/e" />');
}
/**
* Makes the given $id a guest, assuming the bot is mod
* @param $id The id to guest
*/
function guest($id) {
$this->send('<c u="'.$this->parseU($id).'" t="/r" />');
}
/**
* Ki!cks the given ID assuming the bot is a mod and $id is a member or less
* @param $id The id to kick
*/
function kick($message, $id) {
$this->send('<c p="'.$message.'" u="'.$this->parseU($id).'" t="/k" />');
}
/**
* Bans the ID for a given time(0 is forever)
* @param $id The id to ban
*/
function ban($message, $id, $time) {
if(empty($time)) $time = 3600;
$this->send('<c p="'.$message.'" u="'.$this->parseU($id).'" t="/g'.$time.'" />');
}
/**
* Unbans the given ID
* @param $id The id to unban
*/
function unban($id) {
$this->send('<c u="'.$this->parseU($id).'" t="/u" />');
}
/**
* Performs a basic HTTP GET to the given URL
* @param $url The url to retrieve, please include http:// and www if necessary
* @param $includeHeader Tells teh function wether or not to include the server header respond before the main content
*/
function get($url, $includeHeader=false) {
$urlp = parse_url($url);
$fp = fsockopen($urlp['host'],80);
$path = explode('/',$url,4);
$path = ((count($path)>=4)?$path[3]:"");
$req = "GET /$path HTTP/1.1\r\n";
$req .= "Host: $urlp[host]\r\n";
$req .= "Connection: Close\r\n\r\n";
fputs($fp, $req);
$res = "";
while(!feof($fp)) $res .= fgets($fp, 4096);
fclose($fp);
if($includeHeader) return $res;
$res = explode("\r\n\r\n",$res,2);
return $res[1];
}
/**
* A utility function to get all text beween $start and $end
* @param $content The content from which we are grabbing data
* @param $start where to start grabbing from
* @param $end the end of the content to grab
*/
function getBetween($content,$start,$end){
$r = explode($start, $content);
if (isset($r[1])){
$r = explode($end, $r[1]);
return $r[0];
}
return '';
}
function pause($seconds){
sleep($seconds);
}
}
?>[/php]
i talked to 3nvisi0n (the guy who made this script) and he said secure sockets arent needed and just to get the ID and K value from a registered user and login with protection and locking of. i tried but still no luck.