Hola Amigos De Forum Samp, Bueno Yo Hice El Sietema De Logueo y Registro Desde 0, Pero Tengo Un Problema En El Registro, El Problema Es Cuando Pongo La Contraseсa y Le Doy Registrar Me Dice Que La Contraseсa Es Incorrecta y me Cierra El Servidor, Instale el Plugin crashdetect y Me Dice Que El Problema Es En El Public OnDialogResponse, y Ya Revise El Public y Todo Esta Bien Pero Nose Que Sea y Me Pueden Ayudar..
PHP код:
if(dialogid == DIALOGO_INGRESO)
{
new Query[50], DBResult: Resultado;
if(response)
{
format(Query, sizeof(Query)," SELECT * FROM `USUARIOS` WHERE `NOMBRE` = '%s' AND `PASSWORD` = '%s' COLLATE NOCASE",DB_Escape(Nombre(playerid)),DB_Escape(inputtext));
Resultado = db_query(SPFDB, Query);
if(db_num_rows(Resultado))
{
new Field[45];
db_get_field_assoc(Resultado, "SCORE", Field, 45);
Usuario[playerid][ScoreFreeRoam]=strval(Field);
SetPlayerScore(playerid,Usuario[playerid][ScoreFreeRoam]);
db_get_field_assoc(Resultado, "DINERO", Field, 45);
Dinero[playerid] = 0;
ResetPlayerMoney(playerid);
GivePlayerMoneyEx(playerid, strval(Field));
db_get_field_assoc(Resultado, "KILLS", Field, 45);
Usuario[playerid][Kills]=strval(Field);
db_get_field_assoc(Resultado, "DEATHS", Field, 45);
Usuario[playerid][Deaths]=strval(Field);
db_get_field_assoc(Resultado, "ADMINLEVEL", Field, 45);
Usuario[playerid][AdminLevel]=strval(Field);
db_get_field_assoc(Resultado, "VIPLEVEL", Field, 45);
Usuario[playerid][VipLevel]=strval(Field);
db_get_field_assoc(Resultado, "NIVEL", Field, 45);
Usuario[playerid][NivelFreeRoam]=strval(Field);
db_get_field_assoc(Resultado, "EXPERIENCIA", Field, 45);
Usuario[playerid][Experiencia]=strval(Field);
Usuario[playerid][Registrado] = 1;
Usuario[playerid][Logueado] = 1;
}
else
{
ShowPlayerDialog(playerid,DIALOGO_INGRESO,DIALOG_STYLE_PASSWORD,"Contraseсa incorrecta!","{FFFFFF}Ingresa tu contraseсa en el siguiente campo para poder ingresar","Aceptar","Salir");
}
db_free_result(Resultado);
}
}
if(dialogid == DIALOGO_REGISTRO)
{
new Query[420];
if(response)
{
if(strlen(inputtext) < 3 && strlen(inputtext) > 32)return ShowPlayerDialog(playerid,DIALOGO_REGISTRO,DIALOG_STYLE_INPUT,"{00F600}REGISTRAR CUENTA","{FFFFFF}Ingresa la contraseсa con la que te deseas registrar\nla contraseсa debe ser de 4 - 32 caracteres.","Registrar","Salir");
format(Query, sizeof(Query), " INSERT INTO `USUARIOS` (`NOMBRE`, `PASSWORD`, `IP`, `SCORE`, `DINERO`, `KILLS`, `DEATHS`, `ADMINLEVEL`, `VIPLEVEL`, `NIVEL`, `EXPERIENCIA`) VALUES ('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%f')",
DB_Escape(Nombre(playerid)),
DB_Escape(inputtext),
PlayerIp(playerid),
Usuario[playerid][ScoreFreeRoam],
Usuario[playerid][Kills],
Usuario[playerid][Deaths],
Usuario[playerid][AdminLevel],
Usuario[playerid][VipLevel],
Usuario[playerid][NivelFreeRoam],
Usuario[playerid][Experiencia]);
db_query(SPFDB,Query);
Usuario[playerid][Registrado] = 1;
Usuario[playerid][Logueado] = 1;
GameTextForPlayer(playerid, "~g~~h~Registrado Correctamente", 4000,3);
}
}
Si Bro Tengo Todo Definido Muy Bien Pero El Problema Es En El Registro, y No Se Porque
Nada Si Igual El Registro, Pero Ahora No Me Sierra El Server pero Le Doy Cancelar y le doy spawn me sale un copode cosas Mira Aqui La Foro:
pawn Код:
//*==========================================================================*//
#include <a_samp>
//*==========================================================================*//
#pragma tabsize 0
//*==========================================================================*//
#define PocketMoney 50000
#define DIALOGO_REGISTRO 4
#define DIALOGO_INGRESO 4
//*==========================================================================*//
forward SetPlayerRandomSpawn(playerid);
forward SetupPlayerForClassSelection(playerid);
//*==========================================================================*//
//* ENUM DE DATOS *//
//*==========================================================================*//
enum PlayerDatos
{
Registrado,
Logueado,
AdminLevel,
VipLevel,
Kills,
Deaths,
ScoreFreeRoam,
NivelFreeRoam,
Float:Experiencia
};
new Usuario[MAX_PLAYERS][PlayerDatos];
//*==========================================================================*//
new iSpawnSet[MAX_PLAYERS];
new Dinero[MAX_PLAYERS];
new DB:SPFDB;
//*==========================================================================*//
new Float:PlayerRandomSpawn[23][3] =
{
{1958.3783,1343.1572,15.3746},
{2199.6531,1393.3678,10.8203},
{2483.5977,1222.0825,10.8203},
{2637.2712,1129.2743,11.1797},
{2000.0106,1521.1111,17.0625},
{2024.8190,1917.9425,12.3386},
{2261.9048,2035.9547,10.8203},
{2262.0986,2398.6572,10.8203},
{2244.2566,2523.7280,10.8203},
{2335.3228,2786.4478,10.8203},
{2150.0186,2734.2297,11.1763},
{2158.0811,2797.5488,10.8203},
{1969.8301,2722.8564,10.8203},
{1652.0555,2709.4072,10.8265},
{1564.0052,2756.9463,10.8203},
{1271.5452,2554.0227,10.8203},
{1441.5894,2567.9099,10.8203},
{1480.6473,2213.5718,11.0234},
{1400.5906,2225.6960,11.0234},
{1598.8419,2221.5676,11.0625},
{1318.7759,1251.3580,10.8203},
{1558.0731,1007.8292,10.8125},
{1705.2347,1025.6808,10.8203}
};
//*==========================================================================*//
main()
{
print("\n||================================||");
print("|| Super Party FreeRoaM ||");
print("|| ToTalMenTe CrEaDa DeSdE 0 ||");
print("|| PoR Su DuEсO ||");
print("|| ]Sr[M]arshmello[._.] ||");
print("||================================||\n");
}
//*==========================================================================*//
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
//*==========================================================================*//
public OnPlayerConnect(playerid)
{
//*==========================================================================*//
Usuario[playerid][Kills] = 0;
Usuario[playerid][Deaths] = 0;
Usuario[playerid][AdminLevel] = 0;
Usuario[playerid][VipLevel] = 0;
Usuario[playerid][ScoreFreeRoam] = 0;
Usuario[playerid][NivelFreeRoam] = 0;
Usuario[playerid][Experiencia] = 0;
Dinero[playerid] = 0;
//*==========================================================================*//
new Query[50], DBResult: Resultado;
format(Query, sizeof(Query), "SELECT * FROM `USUARIOS` WHERE `NOMBRE` = '%s' COLLATE NOCASE",DB_Escape(Nombre(playerid)));
Resultado = db_query(SPFDB, Query);
if(db_num_rows(Resultado))
{
ShowPlayerDialog(playerid,DIALOGO_INGRESO,DIALOG_STYLE_PASSWORD,"{00F600}INICIAR SESION","{FFFFFF}Ingresa tu contraseсa en el siguiente campo para poder ingresar","Aceptar","Salir");
Usuario[playerid][Registrado] = 1;
}
else
{
ShowPlayerDialog(playerid,DIALOGO_REGISTRO,DIALOG_STYLE_INPUT,"{00F600}REGISTRAR CUENTA","{FFFFFF}Ingresa la contraseсa con la que te deseas registrar","Registrar","Salir");
Usuario[playerid][Registrado] = 0;
}
db_free_result(Resultado);
//*==========================================================================*//
GameTextForPlayer(playerid,"~w~SA-MP: ~r~Las Venturas ~g~MoneyGrub",5000,5);
return 1;
}
//*==========================================================================*//
public OnPlayerDisconnect(playerid)
{
return 1;
}
//*==========================================================================*//
public OnPlayerSpawn(playerid)
{
GivePlayerMoney(playerid, PocketMoney);
SetPlayerInterior(playerid,0);
SetPlayerRandomSpawn(playerid);
TogglePlayerClock(playerid,1);
return 1;
}
//*==========================================================================*//
public SetPlayerRandomSpawn(playerid)
{
new rand = random(sizeof(PlayerRandomSpawn));
SetPlayerPos(playerid, PlayerRandomSpawn[rand][0], PlayerRandomSpawn[rand][1], PlayerRandomSpawn[rand][2]);
SetPlayerFacingAngle(playerid, 270.0);
return 1;
}
//*==========================================================================*//
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
//*==========================================================================*//
public OnPlayerRequestClass(playerid, classid)
{
iSpawnSet[playerid] = 0;
SetupPlayerForClassSelection(playerid);
return 1;
}
//*==========================================================================*//
public SetupPlayerForClassSelection(playerid)
{
SetPlayerInterior(playerid,14);
SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
SetPlayerFacingAngle(playerid, 270.0);
SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
return 1;
}
//*==========================================================================*//
public OnGameModeInit()
{
SetGameModeText("Ventura's DM~MG");
ShowPlayerMarkers(1);
ShowNameTags(1);
EnableStuntBonusForAll(0);
SPFDB = db_open("Servidor/SuperParty.db");
db_query(SPFDB, "CREATE TABLE IF NOT EXISTS `USUARIOS` (`NOMBRE`, `PASSWORD`, `IP`, `SCORE`, `DINERO`, `KILLS`, `DEATHS`, `ADMINLEVEL`, `VIPLEVEL`, `NIVEL`, `EXPERIENCIA`)");
return 1;
}
//*==========================================================================*//
public OnGameModeExit()
{
db_close(SPFDB);
return 1;
}
//*==========================================================================*//
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOGO_INGRESO)
{
new Query[50], DBResult: Resultado;
if(response)
{
format(Query, sizeof(Query)," SELECT * FROM `USUARIOS` WHERE `NOMBRE` = '%s' AND `PASSWORD` = '%s' COLLATE NOCASE",DB_Escape(Nombre(playerid)),DB_Escape(inputtext));
Resultado = db_query(SPFDB, Query);
if(db_num_rows(Resultado))
{
new Field[45];
db_get_field_assoc(Resultado, "SCORE", Field, 45);
Usuario[playerid][ScoreFreeRoam]=strval(Field);
SetPlayerScore(playerid,Usuario[playerid][ScoreFreeRoam]);
db_get_field_assoc(Resultado, "DINERO", Field, 45);
Dinero[playerid] = 0;
ResetPlayerMoney(playerid);
GivePlayerMoneyEx(playerid, strval(Field));
db_get_field_assoc(Resultado, "KILLS", Field, 45);
Usuario[playerid][Kills]=strval(Field);
db_get_field_assoc(Resultado, "DEATHS", Field, 45);
Usuario[playerid][Deaths]=strval(Field);
db_get_field_assoc(Resultado, "ADMINLEVEL", Field, 45);
Usuario[playerid][AdminLevel]=strval(Field);
db_get_field_assoc(Resultado, "VIPLEVEL", Field, 45);
Usuario[playerid][VipLevel]=strval(Field);
db_get_field_assoc(Resultado, "NIVEL", Field, 45);
Usuario[playerid][NivelFreeRoam]=strval(Field);
db_get_field_assoc(Resultado, "EXPERIENCIA", Field, 45);
Usuario[playerid][Experiencia]=strval(Field);
Usuario[playerid][Registrado] = 1;
Usuario[playerid][Logueado] = 1;
}
else
{
ShowPlayerDialog(playerid,DIALOGO_INGRESO,DIALOG_STYLE_PASSWORD,"Contraseсa incorrecta!","{FFFFFF}Ingresa tu contraseсa en el siguiente campo para poder ingresar","Aceptar","Salir");
}
db_free_result(Resultado);
}
return 1;
}
if(dialogid == DIALOGO_REGISTRO)
{
new Query[420];
if(response)
{
if(strlen(inputtext) < 3 && strlen(inputtext) > 32)return ShowPlayerDialog(playerid,DIALOGO_REGISTRO,DIALOG_STYLE_INPUT,"{00F600}REGISTRAR CUENTA","{FFFFFF}Ingresa la contraseсa con la que te deseas registrar\nla contraseсa debe ser de 4 - 32 caracteres.","Registrar","Salir");
format(Query, sizeof(Query), " INSERT INTO `USUARIOS` (`NOMBRE`, `PASSWORD`, `IP`, `SCORE`, `DINERO`, `KILLS`, `DEATHS`, `ADMINLEVEL`, `VIPLEVEL`, `NIVEL`, `EXPERIENCIA`) VALUES ('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%f')",
DB_Escape(Nombre(playerid)),
DB_Escape(inputtext),
PlayerIp(playerid),
Usuario[playerid][ScoreFreeRoam],
Usuario[playerid][Kills],
Usuario[playerid][Deaths],
Usuario[playerid][AdminLevel],
Usuario[playerid][VipLevel],
Usuario[playerid][NivelFreeRoam],
Usuario[playerid][Experiencia]);
db_query(SPFDB,Query);
Usuario[playerid][Registrado] = 1;
Usuario[playerid][Logueado] = 1;
GameTextForPlayer(playerid, "~g~~h~Registrado Correctamente", 4000,3);
}
return 1;
}
return 0;
}
//*==========================================================================*//
stock DB_Escape(text[])
{
new ret[80 * 2], ch, i, j;
while((ch = text[i ++]) && j < sizeof(ret))
{
if(ch == '\'')
{
if(j < sizeof(ret) - 2)
{
ret[j ++] = '\'';
ret[j ++] = '\'';
}
}
else if(j < sizeof(ret)) ret[j ++] = ch;
else j ++;
}
ret[sizeof(ret) - 1] = '\0';
return ret;
}
//*==========================================================================*//
stock Nombre(playerid)
{
new name[24];
GetPlayerName(playerid,name,sizeof(name));
return name;
}
//*==========================================================================*//
stock PlayerIp(playerid)
{
new Ip[5];
GetPlayerIp(playerid, Ip, sizeof(Ip));
return Ip;
}
//*==========================================================================*//
stock GuardarCuentas(playerid)
{
new Query[360];
if(Usuario[playerid][Logueado] == 1 && Usuario[playerid][Registrado] == 1)
{
if(Usuario[playerid][ScoreFreeRoam] > 999999999)
Usuario[playerid][ScoreFreeRoam] = 999999999;
if(Dinero[playerid] > 999999999)
Dinero[playerid] = 999999999;
format(Query, sizeof(Query)," UPDATE `USUARIOS` SET `SCORE` = '%d', `DINERO` = '%d', `KILLS` = '%d', `DEATHS` = '%d', `ADMINLEVEL` = '%d', `VIPLEVEL` = '%d', `NIVEL` = '%d', `EXPERIENCIA` = '%f' WHERE `NOMBRE` = '%s' COLLATE NOCASE",
Usuario[playerid][ScoreFreeRoam],
Dinero[playerid],
Usuario[playerid][Kills],
Usuario[playerid][Deaths],
Usuario[playerid][AdminLevel],
Usuario[playerid][VipLevel],
Usuario[playerid][NivelFreeRoam],
Usuario[playerid][Experiencia],
DB_Escape(Nombre(playerid)));
db_query(SPFD,Query)
}
}
//*==========================================================================*//
stock GivePlayerMoneyEx(playerid,money)
{
if((Dinero[playerid]+money)>999999999)
Dinero[playerid]=999999999;
else
Dinero[playerid]=Dinero[playerid]+money;
ResetPlayerMoney(playerid);
return GivePlayerMoney(playerid,Dinero[playerid]);
}
//*==========================================================================*//