Promote command.
#3

It says that PlayerInfo isn't defined.
can I take things from other filterscripts?
I got a login script where I want to take PlayerInfo from.
Or do I have to recreate that small part?
This is the login script:
Код:
#include <a_samp>
#include <YSI\y_ini>

//Dialogs
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4
//Users path
#define PATH "/users/%s.ini"
//Colors
#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{485CFF}"
#define COL_YELLOW "{F7C600}"

enum pInfo
{
    pPass,
    pCash,
    pRights,
    pKills,
    pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];

stock strreplace(string[], find, replace)
{
    for(new i=0; string[i]; i++)
    {
        if(string[i] == find)
        {
            string[i] = replace;
        }
    }
}

stock GetName(playerid)
{
    new
        name[24];
    GetPlayerName(playerid, name, sizeof(name));
    strreplace(name, '_', ' ');
    return name;
}

main()
{
	print("Login by Ruud");
}

public OnFilterScriptInit()
{
	SetGameModeText("Login script");
	return 1;
}

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Rights",PlayerInfo[playerid][pRights]);
    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;
}

public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        new string[128], playerName[24];
		GetPlayerName(playerid, playerName, sizeof(playerName));
		format(string, 128, COL_YELLOW"Welcome back "COL_LIGHTBLUE"%s "COL_WHITE"\nplease type your password below to log in.", GetName(playerid));
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Login", string, "Login", "Quit");
    }
    else
    {
    	new string[128], playerName[24];
		GetPlayerName(playerid, playerName, sizeof(playerName));
        format(string, 128, COL_YELLOW"Welcome "COL_LIGHTBLUE"%s "COL_WHITE"\n Type your password below to register a new account.", GetName(playerid));
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, COL_WHITE"Registering...", string, "Register", "Quit");
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Rights",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);

                SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                    SpawnPlayer(playerid);
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}

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

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


Messages In This Thread
Promote command. - by xX4m4zingXx - 18.01.2015, 10:36
Re: Promote command. - by CalvinC - 18.01.2015, 10:45
Re: Promote command. - by xX4m4zingXx - 18.01.2015, 11:31
Re: Promote command. - by CalvinC - 18.01.2015, 14:10
Re: Promote command. - by xX4m4zingXx - 18.01.2015, 15:35
Re: Promote command. - by xX4m4zingXx - 18.01.2015, 20:39
Re: Promote command. - by nezo2001 - 18.01.2015, 20:42
Re: Promote command. - by xX4m4zingXx - 18.01.2015, 20:48
Re: Promote command. - by nezo2001 - 18.01.2015, 21:05
Re: Promote command. - by xX4m4zingXx - 23.01.2015, 18:03

Forum Jump:


Users browsing this thread: 5 Guest(s)