collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Php text out in a recruitment file  (Read 3341 times)

0 Members and 1 Guest are viewing this topic.

Offline jonnyrocker

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Php text out in a recruitment file
« on: August 19, 2010, 10:09:20 am »
Hey there i have setup bebot for my guild and we like it very much so kudos to you guys have programmed it.
But since  i am a noob on php programming i need some help i have used snyders guild recruitment file which he modified from another guy i dont remember what he is called.

So how snyder set it up he uses an external file with the recruitment text in it which i have also setup and got to work. The problem is the output it does not look very nice.
It would be nice if i could make look abit more normal. In the text file it looks ok but the out put doesnt.

Code: [Select]
##GI_red##Who is the Old Guard?##end##
##GI_normal##The Old Guard belong to a gaming community known as The Older Gamers, with over 40,000 members across many genres of game
we have come back to Age of Conan to seek those over the age of 25 to join our ranks.
We are a community for people that still enjoy playing computer games, but are in a bit of an older age bracket than the 'stereotypical' gamer.
TOG is for gamers who (regretfully) can't go out boozing every weekend, because we have partners, or are busy workers and also for people who have retired and who need to de-stress from their busy lives by indulging in some online gaming.##end##
##end##
##end##
##GI_red##What kind of guild are you ?##end##
##GI_normal##The Old Guard has mostly casual players. We like to group together for instances, crafting or generally have a social chat.
We understand that being over 25, life can be busy so we would never implement a hardcore raiding schedule on anyone.
All we ask is for you to have fun, be social and be active as possible.##end##
##end##
##end##
##GI_red##Is there a guild city##end##
##GI_normal##We are beginning the Tier 3 phase, and our city can be located in Lacheish Plains.##end##
##end##
##end##
##GI_red##Do you use voice comms?##end##
##GI_normal##Voice comms are not compulsory however are preferred especially in instance or raids. We use Teamspeak 3 details can be found once a member.##end##
##end##
##end##
##GI_red##Do you have a web site##end##
##GI_normal##www.theoldergamers.com##end##
##end##
##end##
##GI_red##Are there any classes or restrictions?##end##
##GI_normal##No, all classes are welcome and levels. The only restriction is that you must be aged 25 and over.
Players must be active as possible unless they have informed an officer, players inactive for 30 days are demoted in rank, after 60 days, players will be removed from the guild.##end##
##end##
##end##
##GI_red##How do i apply?##end##
##GI_normal##Please go to www.theoldergamers.com have a look around and when you are ready, head to the barracks read the application process and create your application there.
For any more information please contact an officer in game.##end##
##end##
##end##
##GI_red##We are mainly looking for:##end##

That is how the code looks like  hope someone can help me with this.
JR

Offline Yite

  • BeBot Apprentice
  • ***
  • Posts: 152
  • Karma: +0/-0
    • Niflheim - Crom
Re: Php text out in a recruitment file
« Reply #1 on: August 19, 2010, 10:51:02 am »
What does the output look like?
-Yite [Crom]

Offline jonnyrocker

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Php text out in a recruitment file
« Reply #2 on: August 19, 2010, 11:37:58 am »
Heres how it looks like now.

Offline Yite

  • BeBot Apprentice
  • ***
  • Posts: 152
  • Karma: +0/-0
    • Niflheim - Crom
Re: Php text out in a recruitment file
« Reply #3 on: August 19, 2010, 02:47:21 pm »
I think you should be able to just put in \n where needed, so something like:
Code: [Select]
##GI_red##Who is the Old Guard?##end##\n
##GI_normal##The Old Guard belong to a gaming community known as The Older Gamers, with over 40,000 members across many genres of game
we have come back to Age of Conan to seek those over the age of 25 to join our ranks.
We are a community for people that still enjoy playing computer games, but are in a bit of an older age bracket than the 'stereotypical' gamer.
TOG is for gamers who (regretfully) can't go out boozing every weekend, because we have partners, or are busy workers and also for people who have retired and who need to de-stress from their busy lives by indulging in some online gaming.##end##\n
##end##
##end##
##GI_red##What kind of guild are you ?##end##\n
##GI_normal##The Old Guard has mostly casual players. We like to group together for instances, crafting or generally have a social chat.
We understand that being over 25, life can be busy so we would never implement a hardcore raiding schedule on anyone.
All we ask is for you to have fun, be social and be active as possible.##end##
##end##
##end##
-Yite [Crom]

Offline jonnyrocker

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Php text out in a recruitment file
« Reply #4 on: August 19, 2010, 03:02:22 pm »
Thx Yite for the tips but that did not work unfortunally he just shows the \n in the message.

JR

Offline Yite

  • BeBot Apprentice
  • ***
  • Posts: 152
  • Karma: +0/-0
    • Niflheim - Crom
Re: Php text out in a recruitment file
« Reply #5 on: August 19, 2010, 03:12:32 pm »
Hmmm I know I don't have the problem with my script, might be related in how you are displaying the text file. Can you post the php code that calls the script (ie your complete Ginfo.php)?
-Yite [Crom]

Offline BoA-Gert

  • BeBot User
  • **
  • Posts: 45
  • Karma: +0/-0
Re: Php text out in a recruitment file
« Reply #6 on: August 19, 2010, 03:17:44 pm »
\n works for me in the ginfo module:

Code: [Select]
$txt.= "##GI_red##Brothers of Arms##end## -- ##GI_blue##http://brothersofarms.eu##end##\n \n";
but this in the actual module and doesn't use Snyder's method...looking at the help page for file_get_contents there is this comment:

Quote
if $filename has a relative path file_get_contents returns the uninterpreted sourcecode of the php-file with all comments etc.

which sounds like your problem - how do you have $recruitment_file set?

Offline jonnyrocker

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Php text out in a recruitment file
« Reply #7 on: August 19, 2010, 03:30:20 pm »
This is how the code looks like as you can see its a direct copy of the code snyder has modified and i have just modified the file path on my hand and changed officer names other wise it isnt changed.
Thank you Yite and Gert that you help me out here.

JR


Code: [Select]
<?php
/*
* GuildInfo, by Kaeus
* This module helps people with guild recruitment.
*
* modifyed by Snyder for CRO guild on Crom server
*/
$GuildInfo = new GuildInfo($bot);

class 
GuildInfo extends BaseActiveModule {
private $recruitment_file 'C:/bebot/txt/recruitment.php';
private $who_clicked = array();
private $spam_time 15;// minutes that spam protection is active
/*
constructor
*/
function __construct(&$bot) {
parent::__construct(&$botget_class($this));

$this->register_command('all''ginfo'"ANONYMOUS");

$this->bot->core("colors")->define_scheme("GI""highlight""yellow");
$this->bot->core("colors")->define_scheme("GI""normal""white");
$this->bot->core("colors")->define_scheme("GI""info""lightgreen");
$this->bot->core("colors")->define_scheme("GI""red""red");
$this->bot->core("colors")->define_scheme("GI""blue""blue");
/*
define classes and colors for recruitment
*/
$this->classes = array(
'sin' => 'Assasin',
'barb' => 'Barbarian',
'bs' => 'Bear Shaman',
'conq' => 'Conqueror',
'dt' => 'Dark Templar',
'demo' => 'Demonologist',
'guard' => 'Guardian',
'hox' => 'Herald of Xotli',
'necro' => 'Necromancer',
'pom' => 'Priest of Mitra',
'rang' => 'Ranger',
'tos' => 'Tempest of Set',
);
/*
you can pute more/less levels of recruitment
*/
$this->colors = array(
'none' => '#FFCC00',
'low' => '#FF0000',
'medium' => '#FF6600',
'high' => '#009900',
'ultrahigh' => '#005900',
);
// settings
$i 1;
$opt "";
// make options for settings
foreach ($this->colors as $k => $v) {$opt .= $k.";";unset($k$v);}
$opt eregi_replace(";$"""$opt);// remove last ; from options
// make settings loop
foreach ($this->classes as $short => $long) {
$this->bot->core("settings")->create("GuildInfo"$short"none"$long." requirement"$optfalse$i);
$i++;
}
unset($opt$i);
// help
$this->help['description'] = 'Helps with guild recruitment.';
$this->help['command']['ginfo'] = 'Displays guild\'s info tab.';
// officers
$this->officers = array(
// first is guild leader
'Galatea',
'Hoxidon',
// rest are officers
'Khiy',
'Kallena',
'Inophi',
);

}
/*

*/
function command_handler($name$msg$origin) {
// there is only one command
if (preg_match('/^ginfo/i'$msg$info)) {
// spam protection
if ($this->is_not_spam($name)) {
return $this->info($name);
}
}
else {
$this->bot->send_help($name);
}
}
   
/*
guild info stuff
*/
function info($name) {
// guild name
$txt "<font face='hyboriansmall' color='#FFFFFF'>The Old Guard</font>\n<font color=#000000>.<br></font>";
$txt .= "<font face='hyboriansmall' color='#FFFFFF'>http://www.theoldergamers.com</font>\n<font color=#000000>.<br></font>";
// staff
$i 0;
foreach ($this->officers as $v) {
$online $this->find_officer($v);
$n $online[1];
$online $online[0];
// first one is guildleader
if (!$i) {$txt .= "##normal##Guild leader##end##\n";}
// rest are officers
else if ($i == 1) {$txt .= "##normal##Officers##end##\n";}
$txt .= "##GI_highlight##".$online['content']." :: <a href='chatcmd:///tell ".$n." Hey ".$n.", i would like some more info'>".$n."</a> ( ".$v." )##end##";
if ($v == $name) {$txt .= " - <font color='yellow'>posted recruitment info</font>";}
$txt .= "\n";
unset($v$online$n);
$i++;
}
// recruitment text from local file
// you can get one from your website if you really want...
$data file_exists($this->recruitment_file) ? file_get_contents($this->recruitment_file) : '';
$txt .= $data;
// loop to create requirement
foreach ($this->classes as $short => $long) {
$r $this->bot->core("settings")->get("GuildInfo"$short);// requirement for class
$txt .= "##normal##".$long.":##end## <font color='".$this->colors$r ]."'>[".$r."]</font>\n";
unset($short$long$r);
}
unset($data);
return $this->bot->core("tools")->make_blob("TOG Guild info"$txt);
}
/*
find officer
*/
public function find_officer($name) {
// query for officer, if hes not on any alts his main char will be shown ($name)
$query $this->bot->db->select("select o.nickname from #___online as o, #___alts as a where o.status_gc = '1' and ( (o.nickname = a.alt and a.main = '".$name."') or (o.nickname = a.main and a.alt = '".$name."') ) LIMIT 1");
if (!empty($query)) {
// just in case go with foreach loop, but there should be only one item in array
foreach ($query as $user) {
$name $user[0];
unset($user);
}
}
unset($query);
// online status on character $name
$online $this->bot->core("online")->get_online_state($name);
// return data array (online/offline, character name)
return array($online$name);
}
/*
spam protection agains wankers that click dozen times on link
*/
public function is_not_spam($name) {
// if name is in array, check if he clicked in last $this->spam_time minutes
if (isset($this->who_clicked$name ])) {
// name is in array, check if time char last time clicked is greater than time() - $this->spam_time
if ( $this->who_clicked$name ] > ( time() - $this->spam_time 60 ) ) {
return false;
}
}
$this->who_clicked$name ] = time();
return true;
}
}
?>

Offline Yite

  • BeBot Apprentice
  • ***
  • Posts: 152
  • Karma: +0/-0
    • Niflheim - Crom
Re: Php text out in a recruitment file
« Reply #8 on: August 20, 2010, 09:17:35 am »
I checked this last night and it doesn't look very different from the script I'm using.

Only differences are:
* I'm using a relative path
* My text file doesn't have a php extension
* I'm running on Unix

I don't think any of the above is part of the problem though unless it somehow parses based on extension but I don't believe that.
-Yite [Crom]

Offline jonnyrocker

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Php text out in a recruitment file
« Reply #9 on: August 20, 2010, 02:38:45 pm »
Tried to change my recruitment.php to .txt but with the same result.

So im at a stand still now :) out of ideas.

Jr

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Php text out in a recruitment file
« Reply #10 on: August 21, 2010, 12:01:19 am »
Only thing I can think off offhand without having run the code or tested it myself would be that you might be running into issues with line endings.

If you are editing the file on Windows, and running the bot on Linux/*nix, try editing the file using Notepad++ or similar and set EOL conversion to Unix before saving and reuploading the file.
BeBot Founder and Fixer Kingpin

Offline jonnyrocker

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Php text out in a recruitment file
« Reply #11 on: August 21, 2010, 05:56:01 pm »
Thx for your answer Khalem i am running the bot on a windows server and editing with notepad ++ since i think that editor is the best.

JR

Offline BoA-Gert

  • BeBot User
  • **
  • Posts: 45
  • Karma: +0/-0
Re: Php text out in a recruitment file
« Reply #12 on: August 22, 2010, 02:09:12 pm »
Had a little play around with it - was getting the line breaks ok but the only thing I had changed was using \ instead of / in your path...

Offline jonnyrocker

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Php text out in a recruitment file
« Reply #13 on: August 23, 2010, 12:49:14 pm »
Thx for your answer Gert ive tried that as well now and still the recruitment file looks like well not good :) .
Gonna try to make a totally new file too see if that changes something.

JR

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 200
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal