Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

chat spawn script 1

Status
Not open for further replies.

MAWarGod

Programmer
Feb 15, 2002
352
US
Ok I have come up with a file that looks like this

kajira.cfg

Code:
<center><b><font color=#FFFFFF>ermm:<center><b><font color=#FF0000>fall out of a wagon passing the camp, bond and gagged.. 
<center><b><font color=#FFFFFF>lotus:<center><b><font color=#FF0000>was handed her papper and set free... 
<center><b><font color=#FFFFFF>darla:<center><b><font color=#FF0000>a girl is in search of food and is captured by a out rider..His bola wraps about her legs 
<center><b><font color=#FFFFFF>abbie:<center><b><font color=#FF0000>she is sold to the Ubar of the home 
<center><b><font color=#FFFFFF>barbie:<center><b><font color=#FF0000>she is sold to the second of the home 
<center><b><font color=#FFFFFF>connie:<center><b><font color=#FF0000>six girls are drawn in by the outriders, their necks encircled by leather tethers, running behind the kailla as the tethers were bound together and used as leashes, you are captured 
<center><b><font color=#FFFFFF>esther:<center><b><font color=#FF0000>she was a captive and was sold to the home 
<center><b><font color=#FFFFFF>fawn:<center><b><font color=#FF0000>a slaver brings in his wagon filled with girls, calling out*  buy this one, try this one, you are sold to the home 
<center><b><font color=#FFFFFF>gigit:<center><b><font color=#FF0000>*watches as the girl stumbles in, then accidentally falls into the sleen pen*  ruh roh, sleen chow, try again 
<center><b><font color=#FFFFFF>hump:<center><b><font color=#FF0000>girl rushes out and kneels saying i am home thank the skies, welcome home 
<center><b><font color=#FFFFFF>innie:<center><b><font color=#FF0000>Outrider accidentally runs over a slave hiding in the high grass.  The outrider mutters, "damn speedbumps", try again

Now what I am trying to do is made a random spawned for a chat room..

The names and posts each time would differ

#/usr/bin/perl

use strict;
use warnings;
use CGI qw:)standard);


my $filename = '\path\to\my\kajira.cfg
';

ok in the file I have $name and $msg separated by :

and this is where I am confussed.. I want to enter those values into a format

that allow the to pass into the chat server, thus entering the chat room..

with the values hidden till in room. so it woud be is a button saying enter

Normal entry is like

Code:
<table width="100%">
<form method="post" target="_top" action="[URL unfurl="true"]http://chatsuites.com:8880/chat/kassar"></table>[/URL]
<table border="0" cellspacing="0" cellpadding="0" width="676">
<tbody>
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<tr>
<td align="right"><font size="-1">Screen Name:</font></td>
<td colspan="3"><input style="background: black; color: #d2cec5; border-color: silver" value="&lt;center&gt;a stranger is spotted" size="20" name="USER" /></td></tr>
<tr>
<td align="right"><font size="-1">Enter Msg:</font></td>
<td colspan="3"><font color="#a4a4a4"><input style="background: black; color: #d2cec5; border-color: silver" value="&lt;center&gt;&lt;i&gt;Enters Kassars Territory...&lt;/i&gt;" size="20" name="SAYS" /></font></td></tr></tr>
<tr>
<td></td>
<td colspan="2"><input style="background: black; color: #d2cec5; border-color: silver" value="Enter Kassar!" type="submit" /></td></tr></tbody></table><input value="says to" type="hidden" name="ACTION" /><input value="ALL" type="hidden" name="WHOTO" /></form>
<center></center></td></font></tr></table>&nbsp;</td>
<td align="right" height="17%" width="100%"></td></table>
<div></div></form>
so how would I form a action to impede the values of both $name and $msg to ???

clueless


MA WarGod

I believe if someone can think it, it can be programmed
 
ok I can get name and msg to print out

open (SPAWN, "/pathto/kajira.cfg");
while (<SPAWN>) {
($name,$msg)=split(/:/,$_,2);
print "<table><TR><TD>\n";
print $name;
print "</FONT>\n";
print $msg;
print "</FONT>\n";
print "</TD></TR></table>\n";
}
close(SPAWN);
print "<br></a>\n";

MA WarGod

I believe if someone can think it, it can be programmed
 
Glad you figured it out becuase I have no clue what you are trying to do.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Hello Kevin

Ok I am trying not to just print these to a page like I did..


ok let Me take the html out
kajira.cfg
Code:
ermm:fall out of a wagon passing the camp, bond and gagged.. 
lotus:was handed her papper and set free... 
darla:a girl is in search of food and is captured by a out rider..His bola wraps about her legs 
abbie:Outrider rides in with a slave across the saddle, her ass high in the air, then nonchalantly pushes her off the saddle in front of the Ubar*, she is gifted to the Ubar of the home 
barbie:she is sold to the second of the home 
connie:six girls are drawn in by the outriders, their necks encircled by leather tethers, running behind the kailla as the tethers were bound together and used as leashes, you are captured 
esther:she was a captive and was sold to the home 
fawn:a slaver brings in his wagon filled with girls, calling out*  buy this one, try this one, you are sold to the home 
gigit:*watches as the girl stumbles in, then accidentally falls into the sleen pen*  ruh roh, sleen chow, try again 
hump:girl rushes out and kneels saying i am home thank the skies, welcome home 
innie:Outrider accidentally runs over a slave hiding in the high grass.  The outrider mutters, "damn speedbumps", try again

now I want to open that file and split the values, $name and $msg

open (SPAWN, "/pathtp/kajira.cfg");
while (<SPAWN>) {
($name,$msg)=split(/:/,$_,2);

Ok now is where I am losted

Code:
<form
        action="[URL unfurl="true"]http://chatsuites.com:8880/chat/kassar/"[/URL] method="POST"
        target="_top"><input type="hidden" name="HISTORY" value="2"><INPUT NAME="USER" TYPE="HIDDEN" VALUE="$name"><input TYPE="HIDDEN" value="$msg" name="SAYS" /></font></td></tr></tr>
<input type="submit" name="SUBMIT" value="Enter"></u></font></pre>

Now what I want it to do is pick a random name and a random msg and when the user hits button load a name and message
into the chat..

MA WarGod

I believe if someone can think it, it can be programmed
 
Code:
my @rand;
open (SPAWN, "/pathtp/kajira.cfg");
while (<SPAWN>) {
   chomp;
   push @rand, [split /:/,$_, 2];
}
my $rand = $rand[rand @rand];
my $name = $rand->[0];
my $message = $rand->[1];
   chomp;
   push @rand, [split /:/,$_, 2];
}
my $rand = $rand[rand @rand];
my $name = $rand->[0];
my $msg = $rand->[1];

See if that helps get you going.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
even if it did like



ermm:fall out of a wagon passing the camp, bond and gagged..

$name= ermm
$msg= fall out of a wagon passing the camp, bond and gagged..

even line by line would be great

MA WarGod

I believe if someone can think it, it can be programmed
 
ok will do

MA WarGod

I believe if someone can think it, it can be programmed
 
Unless there is another reason to split the entire file this will be more efficient:

Code:
open (SPAWN, "/pathtp/kajira.cfg");
@rand = <SPAWN>;
close SPAWN;
my ($name,$msg) = split(/:/,$rand[rand @rand],2);

Assumes the SPAWN file is not so big it will consume too much memory if read into an array. You can avoid that by using Tie::File but it will be slower than the above code.


------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
#!/usr/bin/perl

my @rand;
open (SPAWN, "kajira.cfg");
while (<SPAWN>) {
chomp;
push @rand, [split /:/,$_, 2];
}
my $rand = $rand[rand @rand];
my $name = $rand->[0];
my $message = $rand->[1];
chomp;
push @rand, [split /:/,$_, 2];
}
my $rand = $rand[rand @rand];
my $name = $rand->[0];
my $msg = $rand->[1];

}
print qq ~Content-type: text/html
<HTML>
<HEAD>
<TITLE> EDIT ACTIONS </TITLE>
<BODY TEXT = '#FFFFFF' LINK = '#FFCC66' VLink = '#99CC66' ALINK = '#FF0000'>
<center><img src = ""></a>
<CENTER>
<form action=' method='POST' target='_top'>
<input type='hidden' name='HISTORY' value='2'><INPUT NAME='USER' TYPE='HIDDEN' VALUE='$name'>
<input TYPE='HIDDEN' value='$msg' name='SAYS' /></font></td></tr></tr><input type='submit' name='SUBMIT' value='Enter'></u></font></pre>
</FORM>
</CENTER>
~;
}

ok I really lost now been up playing with this all night..

MA WarGod

I believe if someone can think it, it can be programmed
 
Code:
#!/usr/bin/perl

my @rand;
open (SPAWN, "kajira.cfg");
while (<SPAWN>) {   
    chomp;   
    push @rand, [split /:/,$_, 2];
}
my $rand = $rand[rand @rand];
my $name = $rand->[0];
my $msg  = $rand->[1];   

print qq ~Content-type: text/html
<HTML>
<HEAD>
<TITLE> EDIT ACTIONS </TITLE>
<BODY  TEXT = '#FFFFFF' LINK = '#FFCC66' VLink = '#99CC66' ALINK = '#FF0000'>
<center><img src = ""></a> 
<CENTER>
<form        action='[URL unfurl="true"]http://chatsuites.com:8880/chat/kassar/'[/URL] method='POST'        target='_top'>
<input type='hidden' name='HISTORY' value='2'><INPUT NAME='USER' TYPE='HIDDEN' VALUE='$name'>
<input TYPE='HIDDEN' value='$msg' name='SAYS' /></font></td></tr></tr><input type='submit' name='SUBMIT' value='Enter'></u></font></pre>
</FORM>
</CENTER>
~;

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
this needs to be changed:

Code:
print qq ~Content-type: text/html
<HTML>

change to:

Code:
print qq ~Content-type: text/html

<HTML>

You need two newlines after the header

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top