help me please
#1

Hey guys please convert this to y_ini please.

pawn Код:
/*
-------------------------------------*
Server Adminstrator Script.          *
-------------------------------------*
*/


#include <a_samp>
//#include <YSI/y_ini>
#include <dini>
#include <ldudb>
#include <zcmd>
#include <sscanf2>

new IsLoggedIn[MAX_PLAYERS];

new file[256];

enum pInfo
{
    pLevel,
    pCash,
    pKills,
    pDeaths,
    pColor,
    pScore,
    pSkin
}
new PlayerInfo[MAX_PLAYERS][pInfo];

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Server Adminstrator Script.");
    print("--------------------------------------\n");
    return 1;
}

#endif

public OnPlayerConnect(playerid)
{
    IsLoggedIn[playerid] = 0;
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "Server/Users/%s.ini", name);
    if (!dini_Exists(file))
    {
        ShowPlayerDialog(playerid, 2196, DIALOG_STYLE_INPUT, "Register Account.", "Welcome,\n\nYour Account is currently not registered in our Database, So if you feel glad to register you may register please.\n\nEnter your Desired Password Below:", "Register", "Later");
    }
    if(fexist(file))
    {
       ShowPlayerDialog(playerid, 7407, DIALOG_STYLE_INPUT, "Login Account", "Welcome,\n\nYour Account is currently registered in our Database, So if you feel glad to login you may login please.\n\nEnter your Desired Password Below:", "Login", "Later");
    }
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == 2196)
    {
        new name[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), "Server/Users/%s.ini", name);
        if(!response)
            return SendClientMessage(playerid, 0xFF0000FF, "You skiped to Register an account on our Database, Please Makesure your  Kills/Deaths/Cash/Level/Color and Skin won't be saved.");
        if(!strlen(inputtext))
            return ShowPlayerDialog(playerid, 2196523, DIALOG_STYLE_INPUT, "Register Account.", "Welcome,\n\nYour Account is currently not registered in our Database, So if you feel glad to register you may register please.\n\nEnter your Desired Password Below:", "Register", "Later");
        new File:fo = fopen(file, io_write);
        fclose(fo);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "Level",PlayerInfo[playerid][pLevel] = 0);
        dini_IntSet(file, "Cash",PlayerInfo[playerid][pCash] = 500);
        dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
        dini_IntSet(file, "Color",PlayerInfo[playerid][pColor] = 0);
        dini_IntSet(file, "Skin",PlayerInfo[playerid][pSkin] = 0);
        format(string, 2134, "Server: You succesfully registered the nickname %s with password %s.. You have been AutoLogged In.", name, inputtext);
        SendClientMessage(playerid, 0x00FF00FF, string);
        IsLoggedIn[playerid] = 1;
    }

if (dialogid == 7407)
    {
      new name[MAX_PLAYER_NAME];
      GetPlayerName(playerid, name, sizeof(name));
      format(file, sizeof(file), "Server/Users/%s.ini", name);
      if(!response) return SendClientMessage(playerid, 0xFF0000FF, "You skiped to Login your account, Please Makesure your  Kills/Deaths/Cash/Level/Color and Skin won't be saved.");
      if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2196, DIALOG_STYLE_INPUT, "Hi your registered", "You are registred, please login.", "Login", "Leave");
      new tmp;
      tmp = dini_Int(file, "Password");
      if(udb_hash(inputtext) != tmp) {
      SendClientMessage(playerid, 0xFF0000FF, "The Password you entered it feels like wrong, Try again..");
      ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login Account", "Welcome,\n\nYour Account is currently registered in our Database, So if you feel glad to login you may login please.\n\nEnter your Desired Password Below:", "Login", "Later");
      }
      else
      {
        IsLoggedIn[playerid] = 1;
        SetPlayerMoney(playerid, dini_Int(file, "pCash"));
        SetPlayerScore(playerid, dini_Int(file, "pScore"));
        SetPlayerColor(playerid, dini_Int(file, "pColor"));
        PlayerInfo[playerid][pLevel] = dini_Int(file, "pLevel");
        SetPlayerSkin(playerid, dini_Int(file, "pSkin"));
        SendClientMessage(playerid,0x00FF00FF, "Server: You have logged in your account!");
    }
    }
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new name[24];
    GetPlayerName(playerid,name,24);
    format(file,sizeof(file),"Server/Users/%s.ini",name);
    if(dini_Exists(file))
    {
        dini_IntSet(file,"pCash",GetPlayerMoney(playerid));
        dini_IntSet(file,"pScore",GetPlayerScore(playerid));
        dini_IntSet(file,"pColor",GetPlayerColor(playerid));
        dini_IntSet(file,"pLevel",PlayerInfo[playerid][pLevel]);
        dini_IntSet(file,"pSkin",GetPlayerSkin(playerid));
        IsLoggedIn[playerid] = 0;
        return 1;
    }
    return 1;
}


COMMAND:register(playerid, params[])
{
    if (!dini_Exists(file))
    {
        ShowPlayerDialog(playerid, 2196, DIALOG_STYLE_INPUT, "Register Account.", "Welcome,\n\nYour Account is currently not registered in our Database, So if you feel glad to register you may register please.\n\nEnter your Desired Password Below:", "Register", "Later");
    }
    if(fexist(file))
    {
       ShowPlayerDialog(playerid, 7407, DIALOG_STYLE_INPUT, "Login Account", "Welcome,\n\nYour Account is currently registered in our Database, So if you feel glad to login you may login please.\n\nEnter your Desired Password Below:", "Login", "Later");
    }
    return 1;
}
Its not even working please convert it to Y_ini, y_ini works.

thanks.
Reply
#2

I am sorry for one 'Bump' but 3 or 4 hours ago, And no reply.


Hi guys please convert this to y_ini.

Thanks
Reply
#3

Here --> https://sampforum.blast.hk/showthread.php?tid=273088
Reply
#4

Hi kush i know your tutorial is good.

But please i am not good at converting, as you know more than me i think.

Please convert this to y_ini, if you need any help or something i can do it for you.
Reply
#5

no, effort to man!
Reply
#6

Ok listen i am converting it my self.

So i tried Kush's tutorial Loaduser.

Here is code:

pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Level",PlayerInfo[playerid][pLevel]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Skin",SetPlayerSkin[playerid][pSkin]);

    return 1;
}
Error:

pawn Код:
C:\Users\Axme\Desktop\Server\filterscripts\Sas.pwn(49) : error 028: invalid subscript (not an array or too many subscripts): "SetPlayerSkin"
C:\Users\Axme\Desktop\Server\filterscripts\Sas.pwn(49) : warning 215: expression has no effect
C:\Users\Axme\Desktop\Server\filterscripts\Sas.pwn(49) : error 001: expected token: ";", but found "]"
C:\Users\Axme\Desktop\Server\filterscripts\Sas.pwn(49) : error 029: invalid expression, assumed zero
C:\Users\Axme\Desktop\Server\filterscripts\Sas.pwn(49) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

49 line:> INI_Int("Skin",SetPlayerSkin[playerid][pSkin]);

Thanks
Reply
#7

Here, untested: (You have some dialogids messed up BTW)
+ I don't think it's a good idea to use single global variable to format and use it as the userfile path.

pawn Код:
/*
-------------------------------------*
Server Adminstrator Script.          *
-------------------------------------*
*/


#include <a_samp>
#include <YSI/y_ini>
#include <zcmd>
#include <sscanf2>

new IsLoggedIn[MAX_PLAYERS];

new userfile[256];

enum pInfo
{
    pPassword[64],
    pLevel,
    pCash,
    pKills,
    pDeaths,
    pColor,
    pScore,
    pSkin
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward load_userfile(playerid, name[], value[]);
public load_userfile(playerid, name[], value[])
{
    INI_String("pPassword", PlayerInfo[playerid][pPassword], 64);
    INI_Int("pLevel", PlayerInfo[playerid][pLevel]);
    INI_Int("pCash", PlayerInfo[playerid][pCash]);
    INI_Int("pKills", PlayerInfo[playerid][pKills]);
    INI_Int("pDeaths", PlayerInfo[playerid][pDeaths]);
    INI_Int("pColor", PlayerInfo[playerid][pColor]);
    INI_Int("pScore", PlayerInfo[playerid][pScore]);
    INI_Int("pSkin", PlayerInfo[playerid][pSkin]);
    return true;
}

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Server Adminstrator Script.");
    print("--------------------------------------\n");
    return 1;
}

public OnPlayerConnect(playerid)
{
    IsLoggedIn[playerid] = 0;
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(userfile, sizeof(userfile), "Server/Users/%s.ini", name);
    if (!fexist(userfile))
    {
        ShowPlayerDialog(playerid, 2196, DIALOG_STYLE_INPUT, "Register Account.", "Welcome,\n\nYour Account is currently not registered in our Database, So if you feel glad to register you may register please.\n\nEnter your Desired Password Below:", "Register", "Later");
    } else {
       INI_ParseFile(userfile, "load_userfile", .bExtra = true, .extra = playerid);
       ShowPlayerDialog(playerid, 7407, DIALOG_STYLE_INPUT, "Login Account", "Welcome,\n\nYour Account is currently registered in our Database, So if you feel glad to login you may login please.\n\nEnter your Desired Password Below:", "Login", "Later");
    }
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == 2196)
    {
        new name[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(userfile, sizeof(userfile), "Server/Users/%s.ini", name);
        if(!response)
            return SendClientMessage(playerid, 0xFF0000FF, "You skiped to Register an account on our Database, Please Makesure your  Kills/Deaths/Cash/Level/Color and Skin won't be saved.");
        if(!strlen(inputtext))
            return ShowPlayerDialog(playerid, 2196523, DIALOG_STYLE_INPUT, "Register Account.", "Welcome,\n\nYour Account is currently not registered in our Database, So if you feel glad to register you may register please.\n\nEnter your Desired Password Below:", "Register", "Later");
        SaveStats(playerid);
        format(string, 256, "Server: You succesfully registered the nickname %s with password %s.. You have been AutoLogged In.", name, inputtext);
        SendClientMessage(playerid, 0x00FF00FF, string);
        IsLoggedIn[playerid] = 1;
    }

if (dialogid == 7407)
    {
      new name[MAX_PLAYER_NAME];
      GetPlayerName(playerid, name, sizeof(name));
      format(userfile, sizeof(userfile), "Server/Users/%s.ini", name);
      if(!response) return SendClientMessage(playerid, 0xFF0000FF, "You skiped to Login your account, Please Makesure your  Kills/Deaths/Cash/Level/Color and Skin won't be saved.");
      if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2196, DIALOG_STYLE_INPUT, "Hi your registered", "You are registred, please login.", "Login", "Leave");
      if(!strcmp(udb_hash(inputtext),PlayerInfo[playerid][pPassword],false)
      {
        IsLoggedIn[playerid] = 1;
        SetPlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
        SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
        SetPlayerColor(playerid, PlayerInfo[playerid][pColor]);
        SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
        SendClientMessage(playerid,0x00FF00FF, "Server: You have logged in your account!");
      } else {
        SendClientMessage(playerid, 0xFF0000FF, "The Password you entered it feels like wrong, Try again..");
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login Account", "Welcome,\n\nYour Account is currently registered in our Database, So if you feel glad to login you may login please.\n\nEnter your Desired Password Below:", "Login", "Later");
      }
    }
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new name[24];
    GetPlayerName(playerid,name,24);
    format(userfile,sizeof(userfile),"Server/Users/%s.ini",name);
    if(fexist(userfile))
    {
        SaveStats(playerid);
        IsLoggedIn[playerid] = 0;
    }
    return 1;
}

COMMAND:register(playerid, params[])
{
    if (!fexist(userfile))
    {
        ShowPlayerDialog(playerid, 2196, DIALOG_STYLE_INPUT, "Register Account.", "Welcome,\n\nYour Account is currently not registered in our Database, So if you feel glad to register you may register please.\n\nEnter your Desired Password Below:", "Register", "Later");
    } else {
       ShowPlayerDialog(playerid, 7407, DIALOG_STYLE_INPUT, "Login Account", "Welcome,\n\nYour Account is currently registered in our Database, So if you feel glad to login you may login please.\n\nEnter your Desired Password Below:", "Login", "Later");
    }
    return 1;
}

forward SaveStats(playerid);
public SaveStats(playerid)
{
    new name[24];
    GetPlayerName(playerid,name,24);
    format(userfile,sizeof(userfile),"Server/Users/%s.ini",name);
    new INI:file = INI_Open(userfile);
    INI_WriteString(file, "pPassword", udb_hash(PlayerInfo[playerid][pPassword]));
    INI_WriteInt(file, "pLevel", PlayerInfo[playerid][pLevel]);
    INI_WriteInt(file, "pCash", PlayerInfo[playerid][pCash]);
    INI_WriteInt(file, "pKills", PlayerInfo[playerid][pKills]);
    INI_WriteInt(file, "pDeaths", PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(file, "pColor", PlayerInfo[playerid][pColor]);
    INI_WriteInt(file, "pScore", PlayerInfo[playerid][pScore]);
    INI_WriteInt(file, "pSkin", PlayerInfo[playerid][pSkin]);
    INI_Close(file);
    return true;
}
Reply
#8

Oh my god you're awesome iPleomax.

I have to rep+ you for this if it works.

Here are three simple errors:

pawn Код:
C:\Users\Axme\Desktop\Server\filterscripts\Sas.pwn(90) : error 017: undefined symbol "udb_hash"
C:\Users\Axme\Desktop\Server\filterscripts\Sas.pwn(93) : error 017: undefined symbol "SetPlayerMoney"
C:\Users\Axme\Desktop\Server\filterscripts\Sas.pwn(137) : error 017: undefined symbol "udb_hash"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.
Reply
#9

Lol, I though you already had SetPlayerScore and udb_hash..

pawn Код:
/*
-------------------------------------*
Server Adminstrator Script.          *
-------------------------------------*
*/


#include <a_samp>
#include <YSI/y_ini>
#include <zcmd>
#include <sscanf2>

#define DIALOG_REGISTER 2196
#define DIALOG_LOGIN 7407

new IsLoggedIn[MAX_PLAYERS];

new userfile[256];

enum pInfo
{
    pPassword,
    pLevel,
    pCash,
    pKills,
    pDeaths,
    pColor,
    pScore,
    pSkin
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward load_userfile(playerid, name[], value[]);
public load_userfile(playerid, name[], value[])
{
    INI_Int("pPassword", PlayerInfo[playerid][pPassword]);
    INI_Int("pLevel", PlayerInfo[playerid][pLevel]);
    INI_Int("pCash", PlayerInfo[playerid][pCash]);
    INI_Int("pKills", PlayerInfo[playerid][pKills]);
    INI_Int("pDeaths", PlayerInfo[playerid][pDeaths]);
    INI_Int("pColor", PlayerInfo[playerid][pColor]);
    INI_Int("pScore", PlayerInfo[playerid][pScore]);
    INI_Int("pSkin", PlayerInfo[playerid][pSkin]);
    return true;
}

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Server Adminstrator Script.");
    print("--------------------------------------\n");
    return 1;
}

public OnPlayerConnect(playerid)
{
    IsLoggedIn[playerid] = 0;
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(userfile, sizeof(userfile), "Server/Users/%s.ini", name);
    if (!fexist(userfile))
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register Account.", "Welcome,\n\nYour Account is currently not registered in our Database, So if you feel glad to register you may register please.\n\nEnter your Desired Password Below:", "Register", "Later");
    } else {
       INI_ParseFile(userfile, "load_userfile", .bExtra = true, .extra = playerid);
       ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login Account", "Welcome,\n\nYour Account is currently registered in our Database, So if you feel glad to login you may login please.\n\nEnter your Desired Password Below:", "Login", "Later");
    }
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == DIALOG_REGISTER)
    {
        new name[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(userfile, sizeof(userfile), "Server/Users/%s.ini", name);
        if(!response)
            return SendClientMessage(playerid, 0xFF0000FF, "You skiped to Register an account on our Database, Please Makesure your  Kills/Deaths/Cash/Level/Color and Skin won't be saved.");
        if(!strlen(inputtext))
            return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register Account.", "Welcome,\n\nYour Account is currently not registered in our Database, So if you feel glad to register you may register please.\n\nEnter your Desired Password Below:", "Register", "Later");
        PlayerInfo[playerid][pPassword] = udb_hash(inputtext);
        SaveStats(playerid);
        format(string, 256, "Server: You succesfully registered the nickname %s with password %s.. You have been AutoLogged In.", name, inputtext);
        SendClientMessage(playerid, 0x00FF00FF, string);
        IsLoggedIn[playerid] = 1;
    }

if (dialogid == DIALOG_LOGIN)
    {
      new name[MAX_PLAYER_NAME];
      GetPlayerName(playerid, name, sizeof(name));
      format(userfile, sizeof(userfile), "Server/Users/%s.ini", name);
      if(!response) return SendClientMessage(playerid, 0xFF0000FF, "You skiped to Login your account, Please Makesure your  Kills/Deaths/Cash/Level/Color and Skin won't be saved.");
      if (!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Hi your registered", "You are registred, please login.", "Login", "Leave");
      if(udb_hash(inputtext) == PlayerInfo[playerid][pPassword])
      {
        IsLoggedIn[playerid] = 1;
        GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
        SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
        SetPlayerColor(playerid, PlayerInfo[playerid][pColor]);
        SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
        SendClientMessage(playerid,0x00FF00FF, "Server: You have logged in your account!");
      } else {
        SendClientMessage(playerid, 0xFF0000FF, "The Password you entered it feels like wrong, Try again..");
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login Account", "Welcome,\n\nYour Account is currently registered in our Database, So if you feel glad to login you may login please.\n\nEnter your Desired Password Below:", "Login", "Later");
      }
    }
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new name[24];
    GetPlayerName(playerid,name,24);
    format(userfile,sizeof(userfile),"Server/Users/%s.ini",name);
    if(fexist(userfile))
    {
        SaveStats(playerid);
        IsLoggedIn[playerid] = 0;
    }
    return 1;
}

COMMAND:register(playerid, params[])
{
    if (!fexist(userfile))
    {
        ShowPlayerDialog(playerid, 2196, DIALOG_STYLE_INPUT, "Register Account.", "Welcome,\n\nYour Account is currently not registered in our Database, So if you feel glad to register you may register please.\n\nEnter your Desired Password Below:", "Register", "Later");
    } else {
       ShowPlayerDialog(playerid, 7407, DIALOG_STYLE_INPUT, "Login Account", "Welcome,\n\nYour Account is currently registered in our Database, So if you feel glad to login you may login please.\n\nEnter your Desired Password Below:", "Login", "Later");
    }
    return 1;
}

forward SaveStats(playerid);
public SaveStats(playerid)
{
    new name[24];
    GetPlayerName(playerid,name,24);
    format(userfile,sizeof(userfile),"Server/Users/%s.ini",name);
    new INI:file = INI_Open(userfile);
    INI_WriteInt(file, "pPassword", PlayerInfo[playerid][pPassword]);
    INI_WriteInt(file, "pLevel", PlayerInfo[playerid][pLevel]);
    INI_WriteInt(file, "pCash", PlayerInfo[playerid][pCash]);
    INI_WriteInt(file, "pKills", PlayerInfo[playerid][pKills]);
    INI_WriteInt(file, "pDeaths", PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(file, "pColor", PlayerInfo[playerid][pColor]);
    INI_WriteInt(file, "pScore", PlayerInfo[playerid][pScore]);
    INI_WriteInt(file, "pSkin", PlayerInfo[playerid][pSkin]);
    INI_Close(file);
    return true;
}

stock udb_hash(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;
}
Reply
#10

So it seems you really helped me i am really thank ful to you.
Reply
#11

Quote:
Originally Posted by Davz*|*Criss
Посмотреть сообщение
So it seems you really helped me i am really thank ful to you.
No problem. If the code isn't working correctly, pm me.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)