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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

generate fake names

Status
Not open for further replies.

math

Programmer
Mar 21, 2001
56
0
0
BE
Hi,

I'm trying to create a online game for which i need fictious (fake) names... Preferably by nationality...
Currently I've made 2 databases (first and second names) (mysql), and I let php randomly choose a name... Problem being that making such a database for a number of nationalities is alot of work... Is there maybe someone who has such a database, or is there maybe an other way of doing this??
How do professional game-makers do it?

Thanx in advance,
math
 
IIRC..when I helped out with a mod for Ghost Recon the names were simply held in big text file.

Each character in the game was configured from series of XML documents. The name was one of these documents.


Thinking back again, the names used for bots in Sturmbot (for generating AI players in a Day Of Defeat) all come from a long list of names stored in 2 text files (Allied names and Axis names).

If you want to generate the names from an SQL database then why not add another field to each christian name/surname that gives a nationality?
Then just pull a name from each table that matches the nationality you want?

Sure its work.. but the data has to get in there somehow!

Just a thought....If you find a ready made list of names then you are at least half way there and could use a text editor with good find/replace facilities to create a big SQL query and dump the names into your tables.
 
First of all make the files that you want and give them the name of the nationality that you want!
Then take this php and but them all into a dir!
(I quess you can run php scripts! :)

<?php
if (isset($filename)) insert($filename);
echo &quot;
<FORM type=post action='insert.php'>
<select name=\&quot;filename\&quot; onchange=\&quot;submit()\&quot;>&quot;;
if ($handle = opendir('Here goes the full path')) {
while (false !== ($file = readdir($handle))) {
echo &quot;<option value='&quot;.$file.&quot;' selected>&quot;.$file.&quot;</option>&quot;;
}
while ($file = readdir($handle)) {
echo &quot;$file\n&quot;;
}
closedir($handle);
}

echo &quot;</select><br>&quot;;

function insert($filename) {
include(&quot;config.inc.php&quot;);
$lines = file ($filename);
$i=0;
foreach ($lines as $line_num => $line) {
$data[$i] = $line;
$i++;
}

$w=$i;
$u=0;
while ($w > 0) {
//Set 1st link
$name = $data[$u];
$u++;
$nationality = $filename;
$query = &quot;INSERT INTO data (name,nationality) VALUES ('$name','$nationality')&quot;;
$result = mysql_query($query,$db) or die(mysql_error());
$w--;
}
echo &quot;DB updated&quot;;
}
?>

hope it helps!
I used this to make a db from some files! this was really fast about 8.+++ entries withing 5min! mAX :)

but you must have list names

Go check for cracking lists there are some real big naming lists :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top