Aviso
Antes de realizar el tutorial, recomiendo crear un backup del GM por posibles fallos
Antes de realizar el tutorial, recomiendo crear un backup del GM por posibles fallos
Bueno, veo que en la comunidad no hay ningun post de dialog, así que yo haré los honores.
Lo primero, tenemos que borrar el anterior sistema de registro (Si había)
Vale, vamos a OnPlayerRegister y buscamos un texto así o parecido:
- Spoiler:
- new sendername[MAX_PLAYER_NAME];
new string[256];
GetPlayerName(playerid, sendername,sizeof(sendername));
format(string, sizeof(string), "SAGC/Accounts/%s.ini", sendername);
Vale, pues ese texto teneis que borrarlo, también deberéis borrar el comando /register y /login, o como sean en vuestro servidor.
Lo primero, le agregamos:
- Spoiler:
#include <Dini>
Debe quedar algo así:
- Spoiler:
#include <a_samp>
#include <Dini>
//El resto de includes
Ahora vamos a "new" y agregamos estos 2:
- Spoiler:
new gPlayerLogTries[MAX_PLAYERS];
new ObjetoConectado[MAX_PLAYERS];
Ahora vamos a OnPlayerConnect y agregamos esto:
- Spoiler:
new sendername[MAX_PLAYER_NAME];
new string[256];
GetPlayerName(playerid, sendername,sizeof(sendername));
format(string, sizeof(string), "SAGC/Accounts/%s.ini", sendername);
ObjetoConectado[playerid] = CreatePlayerObject(playerid,18750,1413.6752,-1040.2668,148.6437,90.0,60.0,180.0);
if(fexist(string))
{
new loginstring[256];
SetPlayerCameraPos(playerid,1334.000,-995.000,149.000);
SetPlayerCameraLookAt(playerid,1339.000,-998.000,149.000);
SetPlayerPos(playerid,1334.000,-995.000,109.000);
format(loginstring,sizeof(loginstring),"{4FC7C9}Bienvenido a nuestro servidor.\n\n\n{4FC7C9}Este Nombre ya se encuentra registrado.\n\n{4FC7C9}Coloca tu contraseña para acceder a tu cuenta.\n\n\n{4FC7C9}Recuerda no usar Cheats.");
ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"{E50000}Callejeros RP{BB9000}RP - {D8711B}Login",loginstring,"Login","Salir");
return 1;
}
else
{
new regstring[256];
SetPlayerCameraPos(playerid,1334.000,-995.000,149.000);
SetPlayerCameraLookAt(playerid,1339.000,-998.000,149.000);
SetPlayerPos(playerid,1334.000,-995.000,109.000);
format(regstring,sizeof(regstring),"{4FC7C9}Bienvenido a nuestro servidor.\n\n{4FC7C9}Esta cuenta no se encuentra registrada.\n{4FC7C9}Coloca tu contraseña abajo para crear un cuenta y poder entrar.");
ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"{E50000}Callejeros RP {BB9000}RP - {D8711B}Registro",regstring,"Registrar","Salir");
}
LimpiarPantalla(playerid);
return 1;
}
stock LimpiarPantalla(playerid)
{
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
SendClientMessage(playerid, COLOR_YELLOW, "");
}
Ahora en OnDialogResponse ponemos esto:
- Spoiler:
if(dialogid == 1) //Esta es la id del dialog, si hay algun otro dialog en tu servidor te recomiendo que las revises
{
if(response)
{
if(strlen(inputtext))
{
new tmppass[64];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
//Encrypt(tmppass);
OnPlayerLogin(playerid,tmppass);
}
else
{
new loginstring[256];
format(loginstring,sizeof(loginstring)," {E60720}Contraseña incorrecta\n\n{4FC7C9}Coloca tu contraseña para acceder a tu cuenta.");
ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"{E50000}Callejeros RP {BB9000}RP - {D8711B}Error",loginstring,"Login","Salir");
gPlayerLogTries[playerid] += 1;
if(gPlayerLogTries[playerid] == 3) { Kick(playerid); }
}
}
else
{
Kick(playerid);
}
return 1;
}
if(dialogid == 2)
{
if(response)
{
if(strlen(inputtext))
{
new string[128];
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "SAGC/Accounts/%s.ini", sendername);
new File: hFile = fopen(string, io_read);
if (hFile)
{
SendClientMessage(playerid, 0xFFFF00AA, "Por favor, Elija otro nombre.");
fclose(hFile);
Kick(playerid);
return 1;
}
new tmppass[64];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
//Encrypt(tmppass);
OnPlayerRegister(playerid,tmppass);
}
else
{
new regstring[128];
format(regstring,sizeof(regstring),"{4FC7C9}Bienvenido a nuestro servidor.\n\n{4FC7C9}Esta cuenta no se encuentra registrada.\n{4FC7C9}Coloca tu contraseña abajo para crear un cuenta y poder entrar.");
ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"{E50000}Callejeros RP {BB9000}RP - {D8711B}Registro",regstring,"Registrar","Salir");
}
}
else
{
Kick(playerid);
}
}
Sigamos, ahora tenemos que ir a OnPlayerRegister, y poner esto:
- Spoiler:
fclose(hFile);
new loginstring[256];
format(loginstring,sizeof(loginstring),"{4FC7C9}Bienvenido a nuestro servidor.\n\n\n{4FC7C9}Este Nombre ya se encuentra registrado.\n\n{4FC7C9}Coloca tu contraseña para acceder a tu cuenta.\n\n\n{4FC7C9}Recuerda no usar Cheats.");
ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"{E50000}Virtual Rol {BB9000}RP - {D8711B}Login",loginstring,"Login","Salir");
}
}
return 1;
}
Y el último paso, creamos una carpeta que se llame Usuarios o Users, y ya está terminado nuestro sistema de logueo por dialog.