• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Help with INI
#1
Code:
#include <a_samp>



#include <YSI\y_ini>



#define? ? PATH_CONTAS? ? ? ? ? ? "Contas/%s.ini"



#define? ? DIALOG_REGISTRO? ? ? ? 0

#define? ? DIALOG_LOGIN? ? ? ? ? ? 1



enum pData

{

? ? Pass,

? ? Dinheiro,

? ? Banido,

? ? Skin

}

new PlayerData[MAX_PLAYERS][pData];



forward LoadUser_data(playerid, name[], value[]);



main()

{

print("\n\n\n=====================");

print("Servidor INICIANDO...? ? ? ");

print("=====================\n\n\n");

CarregarLog();

}



stock UserPath(playerid)

{

? ? new string[128];

? ? format(string, sizeof(string), PATH_CONTAS, pName(playerid));

? ? return string;

}



stock udb_hash(const buf[])

{

? ? new length=strlen(buf);

? ? new s1 = 1;

? ? new s2 = 0;

? ? new n;

? ? for (n=0; n<length; n)

? ? {

? ? ? s1 = (s1  buf[n]) % 65521;

? ? ? s2 = (s2  s1)? ? % 65521;

? ? }

? ? return (s2 << 16)  s1;

}



stock pName(playerid)

{

? ? new name[MAX_PLAYER_NAME];

? ? GetPlayerName(playerid, name, sizeof(name));

? ? return name;

}



public LoadUser_data(playerid, name[], value[])

{

? ? INI_Int("Senha", PlayerData[playerid][Pass]);

? ? INI_Int("Dinheiro", PlayerData[playerid][Dinheiro]);

? ? INI_Int("Banido", PlayerData[playerid][Banido]);

? ? INI_Int("Skin", PlayerData[playerid][Skin]);

? ? return 1;

}



public OnPlayerConnect(playerid)

{

? ? if(fexist(UserPath(playerid))

? ? {

? ? ? ? INI_ParseFile(UserPath(playerid), "LoadUser_%s", bExtra = true, extra = playerid);

? ? ? ? format(lib, sizeof(lib), "{FFFFFF}Bem Vindo ao {397BE6}Red {FFFFFF}Country {575656}[RPG/DM/FR]\n\

? ? ? ? {397BE6}Nick: {FFFFFF}%s\n{397BE6}Registrado: {00ff00}Sim\n\

? ? ? ? \n{575656}Insira sua senha para logar", pName(playerid));

? ? ? ? ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", lib, "Logar", "Sair");

? ? }

? ? else

? ? {

? ? ? ? format(lib, sizeof(lib), "{FFFFFF}Bem Vindo ao {397BE6}Red {FFFFFF}Country {575656}[RPG/DM/FR]\n\

? ? ? ? {397BE6}Nick: {FFFFFF}%s\n{397BE6}Registrado: {FF0000}N?o\n\

? ? ? ? \n{575656}Insira sua senha para se registrar", pName(playerid));

? ? ? ? ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Registro", lib, "Registrar", "Sair");

? ? }

? ? return 1;

}



public OnPlayerDisconnect(playerid)

{

? ? new INI:File = INI_Open(UserPath(playerid));

? ? INI_SetTag(File, "data");

? ? INI_WriteInt(File, "Dinheiro", GetPlayerMoney(playerid));

? ? INI_WriteInt("Banido", PlayerData[playerid][Pass]);

? ? INI_WriteInt("Skin", GetPlayerSkin(playerid));

? ? return 1;

}



public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])

{

? ? switch (dialogid)

? ? {

? ? ? ? case DIALOG_REGISTRO:

? ? ? ? {

? ? ? ? ? ? if (!response) return Kick(playerid);? ? ? ?

? ? ? ? ? ? if (!(3 <= strlen(inputtext) <= 20))

? ? ? ? ? ? {

? ? ? ? ? ? ? ? new StrLogin[500];

? ? ? ? ? ? ? ? format(StrLogin, sizeof(StrLogin), "{FFFFFF}Bem Vindo ao {397BE6}Red {FFFFFF}Country {575656}[RPG/DM/FR]\n\

? ? ? ? ? ? ? ? {397BE6}Nick: {FFFFFF}%s\n{397BE6}Registrado: {FF0000}N?o\n\

? ? ? ? ? ? ? ? \n{575656}Insira sua senha para se registrar", pName(playerid));

? ? ? ? ? ? ? ? SendClientMessage(playerid, AMARELO, "ERRO: Insira uma senha de 3-20 caracteres!");

? ? ? ? ? ? ? ? ShowPlayerDialog(playerid, DIALOG_REGISTRO, DIALOG_STYLE_PASSWORD, "Registro", StrLogin, "Registrar", "Sair");

? ? ? ? ? ? ? ? return 1;

? ? ? ? ? ? }

? ? ? ? ? ? new INI:File = INI_Open(UserPath(playerid));

? ? ? ? ? ? INI_SetTag(File, "data");

? ? ? ? ? ? INI_WriteInt(File, "Senha", udb_hash(inputtext));

? ? ? ? ? ? INI_WriteInt(File, "Dinheiro", 2500);

? ? ? ? ? ? INI_WriteInt("Banido", 0);

? ? ? ? ? ? INI_Close(File);

? ? ? ? ? ? TogglePlayerSpectating(playerid, false);

? ? ? ? ? ? GivePlayerMoney(playerid, 2500);

? ? ? ? ? ? SendClientMessage(playerid, AMARELO, "Voc? se registrou com sucesso!");

? ? ? ? ? ? SendClientMessage(playerid, VERDE_DINHEIRO, "Voc? recebeu $2500!");

? ? ? ? }

? ? ? ? case DIALOG_LOGIN:

? ? ? ? {

? ? ? ? ? ? if(!response) return Kick(playerid);? ? ?

? ? ? ? ? ? new buf[129], StrLogin[500];

? ? ? ? ? ? if(udb_hash(inputtext) == PlayerInfo[playerid[Senha])

? ? ? ? ? ? {

? ? ? ? ? ? ? ? INI_ParseFile(UserPath(playerid), "LoadUser_%s", bExtra = true, extra = playerid);

? ? ? ? ? ? ? ? GivePlayerMoney(playerid, PlayerData[playerid][Dinheiro]);

? ? ? ? ? ? ? ? SetPlayerSkin(playerid, PlayerData[playerid][Skin]);

? ? ? ? ? ? ? ? SendClientMessage(playerid, 0x00FF00FF, "Voc? logou em sua conta com sucesso!");

? ? ? ? ? ? ? ? TogglePlayerSpectating(playerid, false);

? ? ? ? ? ? }

? ? ? ? ? ? else

? ? ? ? ? ? {

? ? ? ? ? ? ? ? format(StrLogin, sizeof(StrLogin), "{FFFFFF}Bem Vindo ao {397BE6}Red {FFFFFF}Country {575656}[RPG/DM/FR]\n\

? ? ? ? ? ? ? ? {397BE6}Nick: {FFFFFF}%s\n{397BE6}Registrado: {FF0000}N?o\n\

? ? ? ? ? ? ? ? \n{575656}Insira sua senha para se registrar", pName(playerid));

? ? ? ? ? ? ? ? if(tent[playerid] <= 0) return Kick(playerid);

? ? ? ? ? ? ? ? SendClientMessage(playerid, VERMELHO, "ERRO: Senha Incorreta!");

ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", StrLogin, "Logar", "Sair");

? ? ? ? ? ? ? ? return 1;

? ? ? ? ? ? }

? ? ? ? }

? ? }

? ? return 1;

}

tts://imgur.com/UKuHCg

NOTE: i'm using sampctl

what's wrong here?



Error Print

https://imgur.com/UKuHCgi
  Reply


Messages In This Thread
Help with INI - by Nightmare - 2021-04-14, 10:07 PM
RE: Help with INI - by PutuSuhartawan - 2021-04-15, 10:09 PM

Forum Jump: