again help !! :D - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: again help !! :D (
/showthread.php?tid=180557)
again help !! :D -
[Lsrcr]Rafa - 01.10.2010
guys is there some way to make the server connect with the web site
exsample:
When u will connect in the server automatic to kick u and tells to you "you must need to register on our site
www.blahblah.com"
Thanks for the help...
Re: again help !! :D -
Mauzen - 01.10.2010
This sounds like a job for MySQL and PHP (PHP writes user registration infos from the website into MySQL, SA-MP accesses MySQL database and reads the infos)
It would take way too much to explain it here, and moreover i only have a basic knowledge about PHP.
Re: again help !! :D -
[Lsrcr]Rafa - 01.10.2010
ok can u send me some link or pawn code of ur basic knowledge
Thanks
Re: again help !! :D -
Mauzen - 02.10.2010
Sorry, but it would take too much time and work, and i am just too tired and too stoned now, to write some random php stuff down. Wouldnt help you anyways
Re: again help !! :D -
SAW-RL - 02.10.2010
Just ****** for tutorials
Re: again help !! :D -
mrmuffins - 02.10.2010
As Mauzen said:
Check if their name exists in the Database, if not kick them. Their name = Registered on the web site.
There are other things besides PHP, so I don't know why you singled that one out but I will use that.
For a very basic registration on the web site side:
PHP код:
<?php
mysql_connect("localhost", "root", "", "db");
mysql_select_db("db");
?>
<html>
<head>
<title>Registration for Server</title>
</head>
<body>
<?php
if (isset($_POST['submit'])) {
if (!$_POST['Name'] || !$_POST['Pass']) {
echo "<h1><center><font color='red'>You need to fill in both fields!</font></center></h1>";
} else {
$name = mysql_escape_string($_POST['Name']);
$pass = mysql_escape_string($_POST['Pass']);
$Query = mysql_query("SELECT username FROM users WHERE username = '".$name."'");
if(mysql_num_rows($Query) == 0) { //Their account is not already made, so insert it into the DB
echo "<h1><center><font color='green'>Account Created Successfully!</font></center></h1>";
$Query = mysql_query("INSERT INTO users (id, username, password) VALUES ('', '".$name."', '".$pass."')")
} else { //Account already exists
echo "<h1><center><font color='red'>This account exists already!</font></center></h1>";
}
}
}
?>
Enter below the required information:<br />
<form action="" method="post">
In-Game Name: <input type="text" name="Name" size="30" /><br />
In-Game Pass: <input type="password" name="Pass" size="30" /><br />
Submit Info: <input type="submit" name="submit" value="Submit" /><br />
<b>Names must be 20 Characters long!</b>
</form>
</body>
</html>
Now this is just an example, don't go using this cause its only there to show you. Obviously this would be your site as not many people would be excited to use a white blank registration page.
Now back on PAWN side:
You need to check the account name in the database and if there's a match then they can login.
pawn Код:
public OnGameModeInit
() { mysql_connect
("localhost",
"root",
"",
"db",
1);
return 1;
}public OnPlayerConnect
(playerid
) { //Registration and Loggin In new Query
[80];
format(Query,
80,
"SELECT username FROM users WHERE username = '%s'", Name
(playerid
));
mysql_query
(Query
);
mysql_store_result
();
if (mysql_num_rows
() == 1) { //They are already registered, so they can login SendClientMessage
(playerid, COLOR_WHITE,
"Your account exists. Please enter your password to proceed.");
} else { //They are not, so kick them. SendClientMessage
(playerid, COLOR_WHITE,
"You need to register your account on our website first: http://yoursite.domain");
Kick
(playerid
);
} return 1;
}
Once again, this is an example only and to show you how to do it.
Learn upon this and make yours work.
Re: again help !! :D -
[Lsrcr]Rafa - 02.10.2010
uhhhhh thanks muffin i apprecitate this you realy help me alot
THANKS !
Re: again help !! :D -
[MKD]Max - 02.10.2010
rafa this is nice thing to make the game be with webiste