Tipo: FilterScript
Nome: Sistema de Login/Registro Descriзгo: Um login/registro via MySQL, acessando via site, etc. |
public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ )
{
if(hittype == BULLET_HIT_TYPE_OBJECT) // Detecta tiro ao objeto
{
if( IsValidObject( hitid ) ) // Ver se o objeto й vбlido.
{
SendClientMessage( playerid, -1, "Vocк acertou o objeto e ele vazou!" );
DestroyObject( hitid ); // Destrou o Objeto acertado.
}
}
return 1;
}
// Escudo
SetPlayerAttachedObject(playerid, 0,18637,13,0.35,0.0,0.0,0.0,0.0,180.0);
SetPlayerAttachedObject(playerid, 1,18642,7,0.1,0.0,-0.11,0.0,-90.0,90.0);
// Colete
SetPlayerAttachedObject(playerid, 2,19142,1,0.1,0.05,0.0,0.0,0.0,0.0);
// Capacete
SetPlayerAttachedObject(playerid, 3,19141,2,0.11,0.0,0.0,0.0,0.0,0.0);
Sua propria ideia:
Tipo: FilterScript Nome: Sistema de Login/Registro Descriзгo: Um login/registro via MySQL, acessando via site, etc. Seria interessante. |
#include A_SAMP
#include A_MySQL
#define loginUser (0)
#define registerUser (1)
#define hostName "" // Endereзo
#define userName "" // Usuбrio de Login
#define dataName "" // Data Base
#define passName "" // Senha de Login
new MySQLConnect;
new playerLogado[100];
forward checkRegister(playerid);
forward checkLogin(playerid);
stock getNome(playerid){
new NOME[21];
GetPlayerName(playerid, NOME, 21);
return NOME;
}
public checkRegister(playerid) {
new Rows, Fields, Celulas[80], value[10];
cache_get_data (Rows, Fields, MySQLConnect);
if (Rows) {
cache_get_field_content(0, "logadoWEB", value);
playerLogado[playerid] = strval(value);
if(playerLogado[playerid] == 0) {
format(Celulas, 80, "Vocк estб registrado %s\n\nDigite sua senha!", getNome (playerid));
ShowPlayerDialog (playerid, loginUser, DIALOG_STYLE_PASSWORD, "Login Necessбrio", Celulas, "Logar", "Sair");
} else {
SendClientMessage(playerid, -1, "Vocк jб estб logado no site, entгo nгo й preciso fazer login aqui!");
SpawnPlayer(playerid);
}
}else {
format(Celulas, 80, "Vocк nгo estб registrado %s\n\nDigite uma senha!", getNome (playerid));
ShowPlayerDialog (playerid, registerUser, DIALOG_STYLE_PASSWORD, "Nгo Registrado", Celulas, "Registrar", "Sair");
}
return true ;
}
public checkLogin (playerid) {
new Row, Field, Celulas[80];
cache_get_data(Row, Field, MySQLConnect);
if (Row) {
SendClientMessage (playerid, -1, "LOGADO COM SUCESSO!");
} else {
format(Celulas, 80, "Vocк estб registrado %s\n\nDigite sua senha!", getNome (playerid));
ShowPlayerDialog (playerid, loginUser, DIALOG_STYLE_PASSWORD, "Login Necessбrio", Celulas, "Logar", "Sair");
SendClientMessage (playerid, -1, "SENHA ERRADA!");
}
return true ;
}
public OnGameModeInit() {
MySQLConnect = mysql_connect (hostName, userName, dataName, passName);
if(mysql_ping() >= 1) {
print("# ================================== #");
print("# MYSQL: CONECTADO #");
print("# ================================== #");
} else {
print("# ================================== #");
print("# MYSQL: ERROR #");
print("# ================================== #");
}
return true;
}
public OnPlayerConnect(playerid) {
new queryMySQL[65];
format(queryMySQL, 65, "SELECT * FROM usuarios WHERE Usuario='%s' LIMIT 1", getNome (playerid));
mysql_function_query(MySQLConnect, queryMySQL, true, "checkRegister", "i", playerid);
return true;
}
public OnDialogResponse (playerid, dialogid, response, listitem, inputtext []) {
switch(dialogid) {
case loginUser: {
if(!response)
return Kick(playerid);
new Celulas[90];
format(Celulas, 90, "SELECT * FROM usuarios WHERE Usuario='%s' AND Senha='%s'", getNome(playerid), inputtext);
mysql_function_query(MySQLConnect, Celulas, true, "checkLogin", "i", playerid);
}
case registerUser: {
if (!response)
return Kick (playerid);
new Celulas[90];
format(Celulas, 90, "INSERT INTO usuarios (Nick, Senha) VALUES ('%s', '%s')", getNome(playerid), inputtext);
mysql_function_query(MySQLConnect, Celulas, false, #, #);
}
}
return true;
}
<?php
$mysqli = new mysqli("localhost", "root", "", "dataabase");
if ($mysqli->connect_error) {
printf("Erro na conexгo com o Banco de Dados: %s\n", $mysqli->connect_error);
exit();
}
?>
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title> SA-MP </title>
<style type="text/css">
#Container {
width: 1000px;
height: auto;
margin: 0 auto;
font-size: 15px;
font-family: Arial;
}
#Container #Login {
position: relative;
left: 400px;
top: 100px;
}
#Container #Login form input[type="text"], input[type="password"] {
width: 200px;
height: 30px;
padding-left: 10px;
}
#Container #Login form input[type="submit"] {
width: 100px;
height: 30px;
background: #F5F5F5;
border: 1px solid #000;
margin-left: 50px;
}
#Container #Login form a {
text-decoration: none;
color: #000;
margin-left: 55px;
}
#Container #Login form a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div id="Container">
<div id="Login">
<form action="" method="POST">
<label> Usuбrio </label> <br />
<input name="Usuario" type="text" placeholder="UserName" /> <br /> <br />
<label> Senha </label> <br />
<input name="Senha" type="password" placeholder="*****" /> <br /> <br />
<input name="Botao" type="submit" value="Logar" /> <br /> <br />
<a href="registro.php"> Registrar-se </a>
</form>
</div>
</div>
</body>
</html>
<?php
if(isset($_POST["Botao"])) {
$User = $_POST["Usuario"];
$Pass = $_POST["Senha"];
if($User == "" || $Pass == "") {
echo "<script> alert('Preencha todos os campos'); </script>";
}
$query = $mysqli->query("SELECT * FROM usuarios WHERE Usuario='$User' AND Senha='$Pass'");
if($query) {
$row = $query->num_rows;
if($row > 0) {
$query2 = $mysqli->query("UPDATE usuarios SET logadoWEB='1' WHERE Usuario='$User'");
if($query2) {
echo "<script> alert('Bem vindo ao sistema $User!'); </script>";
} else {
echo $mysqli->error;
}
} else {
echo "<script> alert('Usuбrio ou Senha Incorretos!');</script>";
}
} else {
echo $mysqli->error;
}
}
?>
<?php
$mysqli = new mysqli("localhost", "root", "", "dataabase");
if ($mysqli->connect_error) {
printf("Erro na conexгo com o Banco de Dados: %s\n", $mysqli->connect_error);
exit();
}
?>
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title> SA-MP </title>
<style type="text/css">
#Container {
width: 1000px;
height: auto;
margin: 0 auto;
font-size: 15px;
font-family: Arial;
}
#Container #Registro {
position: relative;
left: 400px;
top: 100px;
}
#Container #Registro form input[type="text"], input[type="password"] {
width: 200px;
height: 30px;
padding-left: 10px;
}
#Container #Registro form input[type="submit"] {
width: 100px;
height: 30px;
background: #F5F5F5;
border: 1px solid #000;
margin-left: 50px;
}
#Container #Registro form a {
text-decoration: none;
color: #000;
margin-left: 55px;
}
#Container #Registro form a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div id="Container">
<div id="Registro">
<form action="" method="POST">
<label> Usuбrio </label> <br />
<input name="Usuario" type="text" placeholder="UserName" /> <br /> <br />
<label> Senha </label> <br />
<input name="Senha" type="password" placeholder="*****" /> <br /> <br />
<label> Repetir Senha </label> <br />
<input name="Senha2" type="password" placeholder="*****" /> <br /> <br />
<input name="Botao" type="submit" value="Registrar" /> <br /> <br />
<a href="login.php"> Logar-se </a>
</form>
</div>
</div>
</body>
</html>
<?php
if(isset($_POST["Botao"])) {
$User = $_POST["Usuario"];
$Pass = $_POST["Senha"];
$Pass2 = $_POST["Senha2"];
if($User == "" || $Pass == "" || $Pass2 == "") {
echo "<script> alert('Preencha todos os campos'); </script>";
return true;
}
if($Pass != $Pass2) {
echo "<script> alert('As senhas nгo conferem'); </script>";
return true;
}
$query = $mysqli->query("SELECT * FROM usuarios WHERE Usuario='$User'");
if($query) {
$row = $query->num_rows;
if($row > 0) {
echo "<script> alert('Jб existe uma conta com o Usuбrio: $User'); </script>";
} else {
$query2 = $mysqli->query("INSERT INTO usuarios (Usuario, Senha) VALUES ('$User', '$Pass')");
if($query2) {
echo "<script> alert('Conta registrada com sucesso!');</script>";
} else {
echo "<script> alert('Erro ao registrar uma nova conta!');</script>";
}
}
} else {
echo $mysqli->error;
}
}
?>
Tipo:FilterScript
Nome:Sistema de x1 Descriзгo: um sistema de x1 de no maximo 2 pessoas e quem ganhar o x1 manda uma menssagem para todo o servidor dizendo que o killerid matou o playerid no x1 |