Registration + (auto) Login [problem]
#2

I hope that script you gave us was not full.

I did not found any commands, functions.
This is the max thing I can fix.
pawn Код:
#include <a_samp>
#include <YSI\y_ini>
#include <ZCMD>
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//Defines
//------------------------------------------------------------------------------

#define COLOR_GREEN 0x00FF04FF
#define COLOR_RED 0xFF0000FF
#define COLOR_YELLOW 0xFFFB00FF
#define COLOR_ORANGE 0xFFA200FF
#define COLOR_GREY 0xBABABAFF


#pragma tabsize 0

#define PATH "/Users/%s.ini"

//------------------------------------------------------------------------------

enum pInfo
{
    pPass,
    pSkin,
    pColor,
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    pIP[20]
}
new PlayerInfo[MAX_PLAYERS][pInfo];

//------------------------------------------------------------------------------

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Skin",PlayerInfo[playerid][pSkin]);
    INI_Int("Color",PlayerInfo[playerid][pColor]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}

//------------------------------------------------------------------------------

stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}

//------------------------------------------------------------------------------

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;
}

//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// OnPlayerConnect (Register, Login, Auto Login...
//------------------------------------------------------------------------------


public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                new tmpip[20];
                GetPlayerIp(playerid,tmpip,20);
               
                if(!strcmp(tmpip,PlayerInfo[playerid][pIP],true))
                        {
                        Login(playerid);
                        SendClientMessage(playerid,COLOR_GREEN,"You have been automatically logged in.");
                        }
                else
                {
                SendClientMessage(playerid,COLOR_ORANGE,"There was something wrong, you are not automatically logged in. Please /login.");
                }
    }
    else
    {
        SendClientMessage(playerid,COLOR_ORANGE,"Welcome, you are NOT registered. Please /register.");
    }
        return 1;
}

//------------------------------------------------------------------------------
// OnPlayerDisconnect
//------------------------------------------------------------------------------

public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
    INI_WriteInt(File,"Color",GetPlayerColor(playerid));
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);
    return 1;
}

//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// OnPlayerDeath +kills +Deaths etc..
//------------------------------------------------------------------------------

public OnPlayerDeath(playerid, killerid, reason)
{
    PlayerInfo[killerid][pKills]++;
    PlayerInfo[playerid][pDeaths]++;
    return 1;
}

//==============================================================================
Also, when player login/register add
pawn Код:
GetPlayerIp(playerid,PlayerInfo[playerid][pIP],20);
for auto login feature.
Reply


Messages In This Thread
Registration + (auto) Login [problem] - by mickos - 03.08.2012, 15:20
Re: Registration + (auto) Login [problem] - by [MM]RoXoR[FS] - 03.08.2012, 15:36
Re: Registration + (auto) Login [problem] - by mickos - 03.08.2012, 15:39
Re: Registration + (auto) Login [problem] - by mickos - 03.08.2012, 16:34
Re: Registration + (auto) Login [problem] - by [MM]RoXoR[FS] - 03.08.2012, 16:43
Re: Registration + (auto) Login [problem] - by mickos - 03.08.2012, 17:18

Forum Jump:


Users browsing this thread: 1 Guest(s)