25.08.2014, 01:59
pawn Код:
forward CheckPlayer(playerid);
public CheckPlayer(playerid)
{
new pName[24], Query[256];
GetPlayerName(playerid, pName, 24);
format(Query, sizeof(Query), "SELECT * FROM `usuarios` WHERE Nombre='%s' LIMIT 1 ", pName);
mysql_function_query(Conecction, Query, true, "OnQueryFinish", "ii",2, playerid);
return 1;
}
forward OnQueryFinish(resultid, extraid, ConnectionHandle);
public OnQueryFinish(resultid, extraid, ConnectionHandle)
{
new Rows, Field, string[256];
if(resultid != 0)
{
cache_get_data(Rows, Field);
}
switch(resultid)
{
case 1:
{
if(Rows == 1)
{
new content[20];
cache_get_field_content(0, "Contraseсa", PlayerInfo[extraid][pPassword]);
cache_get_field_content(0, "Asesinatos", content); PlayerInfo[extraid][pAsesinatos]= strval(content);
cache_get_field_content(0, "Muertes", content); PlayerInfo[extraid][pMuertes] = strval(content);
cache_get_field_content(0, "Admin", content); PlayerInfo[extraid][pAdmin] = strval(content);
cache_get_field_content(0, "Dinero", content); PlayerInfo[extraid][pDinero] = strval(content);
cache_get_field_content(0, "Baneado", content); PlayerInfo[extraid][pBaneado] = strval(content);
cache_get_field_content(0, "Vip", content); PlayerInfo[extraid][pVip] = strval(content);
}
else if(!Rows)
{
//
}
}
case 2:
{
if(Rows == 1)
{
new pName[24]; GetPlayerName(extraid, pName, 24);
cache_get_field_content(0, "Contraseсa", PlayerInfo[extraid][pPassword]);
format(string, sizeof(string), "El personaje %s estб registrado en la base de datos. Pon los datos para iniciar sesiуn:", pName);
ShowPlayerDialog(extraid, LOGIN, DIALOG_STYLE_PASSWORD,"Login",string,"Enviar","Salir");
}
else if(!Rows)
{
new pName[24]; GetPlayerName(extraid, pName, 24);
format(string, sizeof(string), "El jugador %s no estб registrado en el servidor, pon aquн la contraseсa para registrarlo:", pName);
ShowPlayerDialog(extraid, REGISTRO, DIALOG_STYLE_PASSWORD,"Registro:",string,"Enviar","Salir");
}
}
}
return 1;
}