stock MySQL_Registro(playerid, passwordstring[])
{
new query[300], pname[24], IP[16];
GetPlayerName(playerid, pname, 24);
GetPlayerIp(playerid, IP, 16);
mysql_function_query(1,"INSERT INTO playerdata (Usuario, Contrasena, Nivel, Dinero, IP) VALUES('%s', SHA1('%s'), 0, 0, '%s')", pname, passwordstring, IP);
#define mysql_query(%1,%2,%3,%4) \
mysql_function_query(%4, %1, false, "OnQueryFinish", "siii", %1, %2, %3, %4)
SendClientMessage(playerid, -1, "Usted ha sido registrado en este servidor!");
Logueado[playerid] = 1;
return 1;
}
new ConnectionHandle;
public OnFilterScriptInit()
{
ConnectionHandle = mysql_connect(SQL_HOST, SQL_USER,SQL_DB, SQL_PASS);
}
stock MySQL_Registro(playerid, passwordstring[])
{
new query[300], pname[24], IP[16];
GetPlayerName(playerid, pname, 24);
GetPlayerIp(playerid, IP, 16);
format(query, 300, "INSERT INTO playerdata (Usuario, Contrasena, Nivel, Dinero, IP) VALUES('%s', SHA1('%s'), 0, 0, '%s')", pname, passwordstring, IP);
mysql_function_query(ConnectionHandle,query, true, "OnQueryFinish", "is", ConnectionHandle, query);
SendClientMessage(playerid, -1, "Usted ha sido registrado en este servidor!");
Logueado[playerid] = 1;
return 1;
}
forward OnQueryFinish(connectionhandle, query[]);
public OnQueryFinish(connectionhandle, query[])
{
}
main()
{
ConectarMySQL();
mysql_connect("CREATE TABLE IF NOT EXISTS playerdata(Usuario VARCHAR(24), Contrasena VARCHAR(41), Nivel INT(20), Dinero INT(20), IP VARCHAR(16) )");
print(" |====================================|");
print(" |.i.| Texas - Roleplay - Espaсol |.i.|");
print(" | oOFotherOo |");
print(" |====================================|");
}
C:\Users\oOFotherOo\Desktop\Programas SV\Sever - Copy\gamemodes\Untitled.pwn(74) : warning 202: number of arguments does not match definition
C:\Users\oOFotherOo\Desktop\Programas SV\Sever - Copy\gamemodes\Untitled.pwn(74) : warning 202: number of arguments does not match definition
C:\Users\oOFotherOo\Desktop\Programas SV\Sever - Copy\gamemodes\Untitled.pwn(74) : warning 202: number of arguments does not match definition
main()
{
ConectarMySQL();
new query[] = "CREATE TABLE IF NOT EXISTS playerdata(Usuario VARCHAR(24), Contrasena VARCHAR(41), Nivel INT(20), Dinero INT(20), IP VARCHAR(16) )";
mysql_query_function(ConnectionHandle, query, true, "OnQueryFinish", "is", ConnectionHandle, query);
print(" |====================================|");
print(" |.i.| Texas - Roleplay - Espaсol |.i.|");
print(" | oOFotherOo |");
print(" |====================================|");
}
Muchas gracias por su ayuda pero me podria decir que funcion tiene OnQueryFinish exactamente?
|
#include <a_samp>
#include <a_mysql>
#pragma tabsize 0
main () {}
//===================[MySQL]======================//
#define MySQL_HOST "localhost"
#define MySQL_USER "root"
#define MySQL_DB "datacenter"
#define MySQL_PASSWORD ""
//=================[DIALOGOS]=====================//
#define REGISTRO 001
#define LOGIN 002
//=================[NEWS]=======================//
new IsRegistered[MAX_PLAYERS];//comprobar si el jugador estб inscrito en la base de datos.
//new MoneyGiven[MAX_PLAYERS]; //Esta es la variable del Efectivo $$$$$$$ no bulto.
new Logueado[MAX_PLAYERS]; //La variable para comprobar si el jugador se registra.
new ConnectionHandle;
public OnFilterScriptInit()
{
ConnectionHandle = mysql_connect(MySQL_HOST, MySQL_USER, MySQL_DB, MySQL_PASSWORD);
}
enum pInfo
{
pNivel,
pDinero,
pAdmin
};
new PlayerInfo[MAX_PLAYERS][pInfo];
stock MySQL_Registro(playerid, passwordstring[])
{
new query[300], pname[24], IP[16];
GetPlayerName(playerid, pname, 24);
GetPlayerIp(playerid, IP, 16);
mysql_format(ConnectionHandle, "INSERT INTO playerdata (Usuario, Contrasena, Nivel, Dinero, Administrador, Ban, IP) VALUES('%s', SHA1('%s'), 0, 0, '%s')", pname, passwordstring, IP);
mysql_function_query(ConnectionHandle,query, true, "OnQueryFinished", "is", ConnectionHandle, query);
SendClientMessage(playerid, -1, "Usted ha sido registrado en este servidor!");
Logueado[playerid] = 1;
return 1;
}
stock MySQL_Login(playerid)
{
new query[300], pname[24], savingstring[20];
GetPlayerName(playerid, pname, 24);
mysql_format(ConnectionHandle, "SELECT * FROM playerdata WHERE Usuario = '%s' LIMIT 0,1", "true", "OnPlayerDataLoad", "s", "Andre", pname);
printf("%d is registerd (1 row with %d fields)", pNivel, pDinero);
new temp[12];
cache_get_row(0, 0, temp);// Cache
printf("Usuario ID is %d", strval(temp));
cache_get_row(0, 2, temp);// Cache
printf("Usuario Nivel is %d", strval(temp));
cache_get_row(0, 1, temp);// Cache
PlayerInfo[playerid][pNivel] = strval(temp);
cache_get_row(0, 4, temp);// Cache
printf("Usuario Dinero is %d", strval(temp));
cache_get_row(0, 3, temp);// Cache
PlayerInfo[playerid][pDinero] = strval(temp);
cache_get_row(0, 6, temp);// Cache
printf("Usuario Administrador is %d", strval(temp));
cache_get_row(0, 5, temp);// Cache
PlayerInfo[playerid][pAdmin] = strval(temp);
mysql_free_result(); //Siempre tenemos que liberar a un resultado almacenado.
SendClientMessage(playerid, -1, "Usted ha ingresado!"); //Envia un mensaje al usuario.
Logueado[playerid] = 1;
return 1;
}
public OnGameModeInit()
{
mysql_connect(MySQL_HOST, MySQL_USER, MySQL_DB, MySQL_PASSWORD); // connection ID 1
mysql_connect("CREATE TABLE IF NOT EXISTS playerdata(Usuario VARCHAR(24), Contrasena VARCHAR(41), Nivel INT(20), Dinero INT(20), Administrador INT(20),Ban INT (16), IP VARCHAR(16) )");
mysql_function_query(ConnectionHandle, "SELECT * FROM playerdata", true, "OnQueryFinished", "siii", "Usuario", 1, 2, 3);
mysql_function_query(ConnectionHandle, "SELECT Usuario,Contraseсa,Nivel,Dinero,Administrador, Ban, FROM playerdata WHERE id = 1", true, "OnPlayerDataLoad", "");
return 1;
}
public OnGameModeExit()
{
}
forward OnQueryFinished(Usuario[], Contrasena, Nivel, Dinero);
public OnQueryFinished(Usuario[], Contrasena, Nivel, Dinero)
{
printf("Datos: %s %i %i %i", Usuario , Contrasena, Nivel, Dinero);
// se imprimirб: Usuario 1 2 3 Miren la linea 76 despues de siii,siii significa entero entero entero xDDDDD
}
forward OnPlayerDataLoad(Usuario[]);
public OnPlayerDataLoad(Usuario[])
{
new rows, fields;
cache_get_data(rows, fields); // Cache
if(!rows)
{
print(!"%d esta no cuenta esta registrada en este servidor!");
}
else
{
printf("%d estб registrado", fields);
}
}
forward OnQueryExecute();
public OnQueryExecute()
{
new fieldname[32], fields, rows;
// recuperar la cantidad de filas y los campos (vamos a tomar ventaja de la cuenta de campo).
cache_get_data(rows, fields); // Cache
// bucle a travйs de todos los campos.
for(new i = 0; i != fields; i++)
{
cache_get_field(i, fieldname);// Cache
printf("El nombre del campo %d is '%s'", i, fieldname);
}
return 1;
}
public OnPlayerConnect(playerid)
{
new query[200], pname[24];
GetPlayerName(playerid, pname, 24);
mysql_format(ConnectionHandle, "SELECT IP FROM `playerdata` WHERE Usuario = '%s' LIMIT 1", pname);
mysql_function_query(ConnectionHandle,query, true, "OnQueryFinished", "is", ConnectionHandle, query);
mysql_store_result();
new rows = mysql_num_rows();
if(!rows)
{
ShowPlayerDialog(playerid, REGISTRO, DIALOG_STYLE_INPUT, "Registro","Usted {FF0000}no{FFFFFF} esta registrado! Por favor {0000FF}Registrese{FFFFFF} Ponga una Contraseсa debajo!","Registrar","Cancelar");
}
if(rows == 1)
{
new IP[2][16];
mysql_fetch_field_row(IP[0],"IP");
GetPlayerIp(playerid, IP[1], 16);
if(strlen(IP[0]) != 0 && !strcmp(IP[0], IP[1], true))
{
MySQL_Login(playerid);
}
else if(!strlen(IP[0]) || strcmp(IP[0], IP[1], true))
{
ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Ingreso","Usted esta Registrado! Por favor Ingrese a su Cuenta\n\nPonga su Contraseсa debajo!","Ingresar","Cancelar");
IsRegistered[playerid] = 1;
}
}
mysql_free_result();
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == REGISTRO)
{
if(response)
{
if(!strlen(inputtext) || strlen(inputtext) > 30)
{
SendClientMessage(playerid, 0xFF0000, "Usted debe insertar una contraseсa de entre 1-30 caracteres!");
ShowPlayerDialog(playerid, REGISTRO, DIALOG_STYLE_INPUT, "Registro","Usted no esta Registrado!,Por favor Registrese.\n\nPonga una Contraseсa debajo!{FF0000}ERROR:Por favor inserte una contraseсa entre 1-30 Caracteres!","Registrar","Cancelar");
}
else if(strlen(inputtext) > 0 && strlen(inputtext) < 30)
{
new escpass[30];
mysql_real_escape_string(inputtext, escpass);
MySQL_Registro(playerid, escpass);
}
}
if(!response)
{
SendClientMessage(playerid, 0xFF0000, "Usted debe registrarse antes de poder ingresar al Servidor!");
ShowPlayerDialog(playerid, REGISTRO, DIALOG_STYLE_INPUT, "Registro","Usted no esta Registrado!,Por favor Registrese.\n\nPonga una contraseсa debajo!\n{FF0000}ERROR:Por favor ponga su Contraseсa!","Registrar","Cancelar");
}
}
if(dialogid == LOGIN)
{
if(!response)
{
SendClientMessage(playerid, 0xFF0000, "Usted debe ingresar antes de que Spawne!");
ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Ingreso","Usted esta Registrado! Por favor Ingrese a su Cuenta\n\nPonga su Contraseсa debajo!\n{FF0000}Ingrese a su cuenta antes de Spawnear!","Ingresar","Cancelar");
}
if(response)
{
new query[200], pname[24], escapepass[30];
GetPlayerName(playerid, pname, 24);
mysql_real_escape_string(inputtext, escapepass);
mysql_format(ConnectionHandle, "SELECT `Usuario` FROM playerdata WHERE Usuario = '%s' AND Contrasena = SHA1('%s')", pname, escapepass);
mysql_function_query(ConnectionHandle,query, true, "OnQueryFinished", "is", ConnectionHandle, query);
mysql_store_result();
new numrows = mysql_num_rows();
if(numrows == 1) MySQL_Login(playerid);
if(!numrows)
{
ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Ingreso","Usted esta Registrado por favor! ingrese su Contraseсa para Loguear.\n\nPonga su contraseсa debajo!\n{FF0000}Contraseсa Incorrecta!","Loguear","Cancelar");
SendClientMessage(playerid, 0xFF0000, "Contraseсa Incorrecta!");
}
mysql_free_result();
}
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(Logueado[playerid] == 1)
{
new query[200], pname[24];
GetPlayerName(playerid, pname, 24);
mysql_format(ConnectionHandle, "UPDATE playerdata SET Nivel=%d, Dinero=%d, Administrador=%d, WHERE Usuario='%s'", false, "", "", pname);
mysql_function_query(ConnectionHandle,query, false, "OnQueryFinished", "is", ConnectionHandle, query);
}
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
if(!Logueado[playerid])
{
if(!IsRegistered[playerid])
{
ShowPlayerDialog(playerid, REGISTRO, DIALOG_STYLE_INPUT, "Registro","Este usuario {FF0000}no{FFFFFF} esta Registrado! Por favor {0000FF}Registrese{FFFFFF} Ponga una Contraseсa debajo!\n {FF0000}ERROR:Usted debe registrarse antes de ingresar!","Registrar","Cancelar");
return 0;
}
if(IsRegistered[playerid] == 1)
{
ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Ingreso","Usted esta Registrado! Por favor Ingrese a su Cuenta\n\n Ponga su Contraseсa debajo!\n{FF0000} Usted debe ingresar antes de iniciar!","Ingresar","Cancelar");
return 0;
}
}
return 1;
}
C:\Users\oOFotherOo\Desktop\Programas SV\Sever - Copy\gamemodes\Untitled.pwn(50) : warning 204: symbol is assigned a value that is never used: "savingstring"
C:\Users\oOFotherOo\Desktop\Programas SV\Sever - Copy\gamemodes\Untitled.pwn(50) : warning 204: symbol is assigned a value that is never used: "query"
C:\Users\oOFotherOo\Desktop\Programas SV\Sever - Copy\gamemodes\Untitled.pwn(80) : warning 202: number of arguments does not match definition
C:\Users\oOFotherOo\Desktop\Programas SV\Sever - Copy\gamemodes\Untitled.pwn(80) : warning 202: number of arguments does not match definition
C:\Users\oOFotherOo\Desktop\Programas SV\Sever - Copy\gamemodes\Untitled.pwn(80) : warning 202: number of arguments does not match definition
C:\Users\oOFotherOo\Desktop\Programas SV\Sever - Copy\gamemodes\Untitled.pwn(220) : error 035: argument type mismatch (argument 3)