The online racing simulator
Searching in All forums
(4 results)
Danielp1997
S3 licensed
Your name: Daniel
In case you win, do you want us to contact you by e-mail or LFSForums? Skype
E-mail ( if applicable ): Frozen knows my Skype.
Chosen Number (0-99): 18
Last edited by Danielp1997, .
Danielp1997
S3 licensed
Would anybody have a download link to these please?
Danielp1997
S3 licensed
Quote from the_angry_angel :3 options;

1. Use constraints (license VARCHAR(32) UNIQUE NOT NULL) and suppress the error/exception on insert failure - simple, quick, although arguably a little hacky as it requires you really suppress the right error to avoid bugs

2. Exactly as you described - how you do this depends on what library you're using to connect to MySQL. Read the documentation?

3. If you want to update something if the user exists (such as last time they were seen, or number of times they've connected) you can do this in one SQL statement by using insert on duplicate update (WARNING: This is MySQL specific)

Since 1 is easy, 2 requires additional information, I'll only describe 3 in more detail.

Assuming a simple table like this:
create table racers(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
license VARCHAR(32) UNIQUE NOT NULL,
data VARCHAR(255),
seen TIMESTAMP DEFAULT UTC_TIMESTAMP
);

The following will attempt to do an insert, otherwise will perform an update storing the last seen time (the UNIQUE license constraint is the magic here):
insert into racers (license, data) values ('the_angry_angel', 'pies') on duplicate key update seen = UTC_TIMESTAMP;

Obviously substitute a parameterized query, or at least filter your inputs through whatever library you're using.

I tried all three but they seemed relatively difficult so I did the method below :P Thank you for your input anyway

Quote from Gai-Luron :Hello,

Use "http" GLScript command to call a php web page doing what you want.

The result of the http web page must be nothing or a valid GLscript script.

Ex:
http("http://www.frh-team.net/reglapper/getserver2.php" );

this command reply (try adress via web)

privMsg( "^7Actually, there are ^345^7 LFSLapper powered servers");

this reply is processed by LFSLapper and display a private message. You can have more then one line in reply or nothing

In this way you can call a php script via web doing that you explain in your post.

In onConnect event

http("http://yourwebsite/registerPlayer.php&id=" . $userName );

An exemple of reply of this php web page command is

privMsg( "Player added to database");

Or

privMsg( "Player already exist, not added to database");

that's all



Gai-Luron

I was thinking of doing it this way beforehand, but have tried and works a treat. Thanks alot.
Insim MySQL Connect
Danielp1997
S3 licensed
Hello,

I'm using LFSLapper insim, and what I'm attempting to do it connect to an external MySQL server that's on my website host.

All I need to do, is insert one piece of information to a table; it may sound easy but the way I want to do it physically may sound more difficult.

So, when someone connects, I want it to connect to the database, and check against the users table whether their LFSU name already exists in there. If it does then close the database, and take no further action.

If, on the other hand, their name doesn't already exist in the table, it will then add it.

This would prevent multiple copies of the same username within one table. Basically on the website we want a list of all our users.

Thinking of doing it through PHP would be a simple $_POST through in input form, select it from the database, if mysql_num_rows is >=1 then do nothing further, else insert into table. Wish it was just that easy in C#...

Anyone fancies a go?
Thanks in advanced,
FGED GREDG RDFGDR GSFDG