Szerző Téma: Regisztrációs script kellene  (Megtekintve 1182 alkalommal)

Regisztrációs script kellene
« Dátum: 2012. Február 11. - 11:07:58 »
0 Show voters
Sziasztok
Egy egyszerû regisztrációs script kellene, beléptetõ rendszerrel. Még jó lenne ha tárolná a score-t és pénzt. Köszönöm

Nem elérhető nyE

  • 1745
    • Profil megtekintése
Regisztrációs script kellene
« Válasz #1 Dátum: 2012. Február 11. - 11:31:08 »
0 Show voters
Ez menti a pénzt, pontokat, öléseket, halálozásokat és a szerveren töltött idõt. Link.

Regisztrációs script kellene
« Válasz #2 Dátum: 2012. Február 11. - 17:48:48 »
0 Show voters
Egy olyan script kellene amit egyszerûen be tudok rakni egy gamemode-ba. Valamiért ez a regisztrációs dolog nekem nem megy.

Nem elérhető Gabor..

  • 1883
  • Gabor..
    • Profil megtekintése
Regisztrációs script kellene
« Válasz #3 Dátum: 2012. Február 11. - 18:26:33 »
0 Show voters
Csá! MySQL-es Regisztrációs Rendszert ajánlom, nagyon jó, könnyen kezelhetõ stb...
Itt van kurta Reg Rendszere: http://sampforum.hu/index.php?topic=7449.0

Nem elérhető nyE

  • 1745
    • Profil megtekintése
Regisztrációs script kellene
« Válasz #4 Dátum: 2012. Február 11. - 18:58:01 »
0 Show voters
Nem olyan nehéz mint amilyennek tûnik.
Ezt a mód elejére:
[pawn]
#include <a_samp>
#include <dini>
#include <dudb>
#include <zcmd>
#include <sscanf2> // ezt akkor ha nem szeretnéd a kódot formályát használni!
#define SCRIPT_VERSION          \"v3\"
#define colorRed                0xFF0000FF
#define colorGreen              0x008000FF
#define DIALOG_REGISTER                 1
#define DIALOG_LOGIN            2
#define DIALOG_ACCOUNT          3
#define DIALOG_CHANGEPASS       4
#define DIALOG_CHANGENAME       5
#define DIALOG_VIEWSTATS        6
#define DIALOG_CHECKSTATS       7
#pragma unused                  ret_memcpy
#pragma unused                  strtok
forward UpdateTime(playerid);
new str[128];
new file[128];
new playerIP[16];
new Update;
[/pawn]
A csatlakozás azaz OnPlayerConnect:
[pawn]
public OnPlayerConnect(playerid)
{
        format(file, 128, \"/tReg/%s.ini\", GetName(playerid));
        GetPlayerIp(playerid, playerIP, 16);
       
        TogglePlayerSpectating(playerid, 1);
        if(!dini_Exists(file))
        {
            format(str, 128, \"Welcome %s \\n\\nPlease register your account\", GetName(playerid));
                ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, \"Account Management\", str, \"Register\", \"Quit\");
        }
    if(dini_Exists(file))
    {
                if(strcmp(playerIP, dini_Get(file, \"IP\"), true) == 0)
                {
                        dini_Set(file, \"IP\", playerIP);
                    SetPVarInt(playerid, \"Logged\", 1);
                        SetPlayerCash(playerid, dini_Int(file, \"Money\"));
                        SetPlayerScore(playerid, dini_Int(file, \"Score\"));
                        SetPVarInt(playerid, \"Kills\", dini_Int(file, \"Kills\"));
                        SetPVarInt(playerid, \"Deaths\", dini_Int(file, \"Deaths\"));
                        SetPVarInt(playerid, \"Time\", dini_Int(file, \"Minutes Ingame\"));
                        Update = SetTimerEx(\"UpdateTime\", 60*1000, 1, \"i\", playerid);
                    SendClientMessage(playerid, colorGreen, \"You have been automatically logged in.\");
                }
                else
                {
                format(str, 128, \"Welcome %s \\n\\nPlease login to your account\", GetName(playerid));
                        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, \"Account Management\", str, \"Login\", \"Quit\");
                }
        }
        return 1;
}[/pawn]
A lekapcsolódás azaz OnPlayerDisconnect:
[pawn]
public OnPlayerDisconnect(playerid, reason)
{
    format(file, 128, \"/tReg/%s.ini\", GetName(playerid));
        if(GetPVarInt(playerid, \"Logged\") == 1)
        {
                dini_IntSet(file, \"Money\", GetPlayerMoney(playerid));
                dini_IntSet(file, \"Score\", GetPlayerScore(playerid));
                dini_IntSet(file, \"Kills\", GetPVarInt(playerid, \"Kills\"));
                dini_IntSet(file, \"Deaths\", GetPVarInt(playerid, \"Deaths\"));
                dini_IntSet(file, \"Minutes Ingame\", GetPVarInt(playerid, \"Time\"));
                KillTimer(Update);
        }
        return 1;
}
[/pawn]
Dialogok:
[pawn]
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    format(file, 128, \"/tReg/%s.ini\", GetName(playerid));
    if(dialogid == DIALOG_REGISTER)
    {
                if(!response) return Kick(playerid);
                if(response)
                {
                    if(strlen(inputtext) == 0)
                        {
                                format(str, 128, \"Welcome %s \\n\\nPlease register your account\", GetName(playerid));
                                ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, \"Account Management\", str, \"Register\", \"Quit\");
                                return 0;
                        }
                        if(!dini_Exists(file))
                        {
                                dini_Create(file);
                                dini_IntSet(file, \"Password\", udb_hash(inputtext));
                                dini_IntSet(file, \"Money\", GetPlayerMoney(playerid));
                                dini_IntSet(file, \"Score\", GetPlayerScore(playerid));
                                dini_IntSet(file, \"Kills\", GetPVarInt(playerid, \"Kills\"));
                                dini_IntSet(file, \"Deaths\", GetPVarInt(playerid, \"Deaths\"));
                                dini_IntSet(file, \"Minutes Ingame\", GetPVarInt(playerid, \"Time\"));
                format(str, 128, \"Account successfully Registered \\n\\n\\nWelcome %s \\n\\nPlease login to your account\", GetName(playerid));
                                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, \"Account Management\", str, \"Login\", \"Quit\");
                        }
                }
        }
        if(dialogid == DIALOG_LOGIN)
        {
            if(!response) return Kick(playerid);
                if(response)
                {
                    if(strlen(inputtext) == 0)
                        {
                                format(str, 128, \"Welcome %s \\n\\nPlease login to your account\", GetName(playerid));
                                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, \"Account Management\", str, \"Login\", \"Quit\");
                                return 0;
                        }
                        if(fexist(file))
                        {
                                new password = dini_Int(file, \"Password\");
                                if(udb_hash(inputtext) != password)
                                {
                                        if(GetPVarInt(playerid, \"Attempts\") == 0)
                                        {
                                            SetPVarInt(playerid, \"Attempts\", 1);
                                            SendClientMessage(playerid, colorRed, \"Incorrect password, You have 1 more attempt\");
                                            format(str, 128, \"Welcome %s \\n\\nPlease login to your account\", GetName(playerid));
                                                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, \"Account Management\", str, \"Login\", \"Quit\");
                                        }
                                        else if(GetPVarInt(playerid, \"Attempts\") == 1)
                                        {
                                            SendClientMessage(playerid, colorRed, \"Incorrect password, You do not have any attempts left\");
                                            Kick(playerid);
                                        }
                                }
                                else
                                {
                                        SetPVarInt(playerid, \"Logged\", 1);
                                        SetPlayerCash(playerid, dini_Int(file, \"Money\"));
                                        SetPlayerScore(playerid, dini_Int(file, \"Score\"));
                                        SetPVarInt(playerid, \"Kills\", dini_Int(file, \"Kills\"));
                                        SetPVarInt(playerid, \"Deaths\", dini_Int(file, \"Deaths\"));
                                        SetPVarInt(playerid, \"Time\", dini_Int(file, \"Minutes Ingame\"));
                                        GetPlayerIp(playerid, playerIP, 16);
                                        dini_Set(file, \"IP\", playerIP);
                                        Update = SetTimerEx(\"UpdateTime\", 60*1000, 1, \"i\", playerid);
                                        TogglePlayerSpectating(playerid, 0);
                                        SendClientMessage(playerid, colorGreen, \"You have successfully logged in.\");
                                }
                        }
                }
        }
        if(dialogid == DIALOG_CHANGEPASS)
        {
                if(response)
                {
                    if(GetPVarInt(playerid, \"PassStage\") == 1)
                    {
                        new password = dini_Int(file, \"Password\");
                        if(udb_hash(inputtext) == password)
                        {
                                SetPVarInt(playerid, \"PassStage\", 2);
                                        ShowPlayerDialog(playerid, DIALOG_CHANGEPASS, DIALOG_STYLE_INPUT, \"Account Management\", \"Please input your new password\", \"Change Pass\", \"Cancel\");
                                }
                                else
                                {
                                    SendClientMessage(playerid, colorRed, \"Incorrect password.\");
                                }
                        }
                        else if(GetPVarInt(playerid, \"PassStage\") == 2)
                        {
                            if(GetPVarInt(playerid, \"Logged\") == 1)
                            {
                                        dini_IntSet(file, \"Password\", udb_hash(inputtext));
                                        SendClientMessage(playerid, colorGreen, \"Password successfully changed.\");
                                }
                        }
                }
        }
        if(dialogid == DIALOG_CHANGENAME)
        {
                if(response)
                {
                    if(GetPVarInt(playerid, \"NameStage\") == 1)
                    {
                        new password = dini_Int(file, \"Password\");
                        if(udb_hash(inputtext) == password)
                        {
                                SetPVarInt(playerid, \"NameStage\", 2);
                                        ShowPlayerDialog(playerid, DIALOG_CHANGENAME, DIALOG_STYLE_INPUT, \"Account Management\", \"Please input your new name\", \"Change\", \"Cancel\");
                                }
                                else
                                {
                                    SendClientMessage(playerid, colorRed, \"Incorrect password.\");
                                }
                        }
                        else if(GetPVarInt(playerid, \"NameStage\") == 2)
                        {
                                format(file, 128, \"/tReg/%s.ini\", inputtext);
                            if(dini_Exists(file))
                            {
                                        SetPVarInt(playerid, \"NameStage\", 2);
                                        ShowPlayerDialog(playerid, DIALOG_CHANGENAME, DIALOG_STYLE_INPUT, \"Account Management\", \"A user has already registered with this name \\nIf this is you please reconnect using that account\\n\\nElse please enter your new name\", \"Change\", \"Cancel\");
                                }
                                else
                                {
                                    format(file, 128, \"/tReg/%s.ini\", GetName(playerid)); dini_Remove(file);
                                    format(file, 128, \"/tReg/%s.ini\", inputtext); dini_Create(file);
                                        dini_IntSet(file, \"Password\", udb_hash(inputtext));
                                        dini_IntSet(file, \"Money\", GetPlayerMoney(playerid));
                                        dini_IntSet(file, \"Score\", GetPlayerScore(playerid));
                                        dini_IntSet(file, \"Kills\", GetPVarInt(playerid, \"Kills\"));
                                        dini_IntSet(file, \"Deaths\", GetPVarInt(playerid, \"Deaths\"));
                                        dini_IntSet(file, \"Minutes Ingame\", GetPVarInt(playerid, \"Time\"));
                                       
                                        SetPlayerName(playerid, inputtext);
                                       
                                        SendClientMessage(playerid, colorGreen, \"Name successfully changed.\");
                                }
                        }
                }
        }
        return 0;
}[/pawn]
Szerveren töltött idõ mérése:
[pawn]
public UpdateTime(playerid)
{
    format(file, 128, \"/tReg/%s.ini\", GetName(playerid));
    SetPVarInt(playerid, \"Time\", GetPVarInt(playerid, \"Time\")+1);
    return 1;
}
[/pawn]
A parancsok:
[pawn]
CMD:changepass(playerid, params[])
{
        if(GetPVarInt(playerid, \"Logged\") == 1)
        {
            SetPVarInt(playerid, \"PassStage\", 1);
                ShowPlayerDialog(playerid, DIALOG_CHANGEPASS, DIALOG_STYLE_INPUT, \"Account Management\", \"Please input your current password for verification\", \"Continue\", \"Cancel\");
        }
        return 1;
}
CMD:changename(playerid, params[])
{
        if(GetPVarInt(playerid, \"Logged\") == 1)
        {
            SetPVarInt(playerid, \"NameStage\", 1);
                ShowPlayerDialog(playerid, DIALOG_CHANGENAME, DIALOG_STYLE_INPUT, \"Account Management\", \"Please input your password for verification\", \"Continue\", \"Cancel\");
        }
        return 1;
}
CMD:viewstats(playerid, params[])
{
    if(GetPVarInt(playerid, \"Logged\") == 1)
        {
            new Float:health; GetPlayerHealth(playerid, health);
            new Float:armour; GetPlayerArmour(playerid, armour);
           
            format(str, 128, \"Name: %s\\nHealth: %0.00f\\nArmour: %0.00f\\nMoney: %i\\nScore: %i\\nKills: %i\\nDeaths: %i\", GetName(playerid), health, armour, GetPlayerMoney(playerid), GetPlayerScore(playerid), GetPVarInt(playerid, \"Kills\"), GetPVarInt(playerid, \"Deaths\"));
                ShowPlayerDialog(playerid, DIALOG_VIEWSTATS, DIALOG_STYLE_MSGBOX, \"Account Management\", str, \"Ok\", \"Cancel\");
        }
        return 1;
}
CMD:checkstats(playerid, params[])
{
        new targetid;
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, colorRed, \"You need to be an RCON Admin to use this command.\");
        if(sscanf(params, \"u\", targetid)) return SendClientMessage(playerid, colorRed, \"Usage: /checkstats [PlayerID/PartOfName]\");
        if(targetid == playerid) return SendClientMessage(playerid, colorRed, \"You are trying to view the stats of you, To do this type: /viewstats\");
        if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, colorRed, \"Player not Found\");
       
    if(GetPVarInt(playerid, \"Logged\") == 1)
        {
            new Float:health; GetPlayerHealth(targetid, health);
            new Float:armour; GetPlayerArmour(targetid, armour);
            format(str, 128, \"Name: %s\\nHealth: %0.00f\\nArmour: %0.00f\\nMoney: %i\\nScore: %i\\nKills: %i\\nDeaths: %i\", GetName(targetid), health, armour, GetPlayerMoney(targetid), GetPlayerScore(targetid), GetPVarInt(targetid, \"Kills\"), GetPVarInt(targetid, \"Deaths\"));
                ShowPlayerDialog(playerid, DIALOG_VIEWSTATS, DIALOG_STYLE_MSGBOX, \"Account Management\", str, \"Ok\", \"Cancel\");
        }
        return 1;
}
[/pawn]
GetName, SetPlayerCash:
[pawn]
stock GetName(playerid)
{
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof name);
        return name;
}
stock SetPlayerCash(playerid, amount)
{
        ResetPlayerMoney(playerid);
        return GivePlayerMoney(playerid, amount);
}
[/pawn]
sscanf (csak akkor ha nem használod a plugin verzióját):
[pawn]
stock sscanf(string[], format[], {Float,_}:...)
{
        #if defined isnull
                if (isnull(string))
        #else
                if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
        #endif
                {
                        return format[0];
                }
        #pragma tabsize 4
        new
                formatPos = 0,
                stringPos = 0,
                paramPos = 2,
                paramCount = numargs(),
                delim = \' \';
        while (string[stringPos] && string[stringPos] <= \' \')
        {
                stringPos++;
        }
        while (paramPos < paramCount && string[stringPos])
        {
                switch (format[formatPos++])
                {
                        case \'\\0\':
                        {
                                return 0;
                        }
                        case \'i\', \'d\':
                        {
                                new
                                        neg = 1,
                                        num = 0,
                                        ch = string[stringPos];
                                if (ch == \'-\')
                                {
                                        neg = -1;
                                        ch = string[++stringPos];
                                }
                                do
                                {
                                        stringPos++;
                                        if (\'0\' <= ch <= \'9\')
                                        {
                                                num = (num * 10) + (ch - \'0\');
                                        }
                                        else
                                        {
                                                return -1;
                                        }
                                }
                                while ((ch = string[stringPos]) > \' \' && ch != delim);
                                setarg(paramPos, 0, num * neg);
                        }
                        case \'h\', \'x\':
                        {
                                new
                                        num = 0,
                                        ch = string[stringPos];
                                do
                                {
                                        stringPos++;
                                        switch (ch)
                                        {
                                                case \'x\', \'X\':
                                                {
                                                        num = 0;
                                                        continue;
                                                }
                                                case \'0\' .. \'9\':
                                                {
                                                        num = (num << 4) | (ch - \'0\');
                                                }
                                                case \'a\' .. \'f\':
                                                {
                                                        num = (num << 4) | (ch - (\'a\' - 10));
                                                }
                                                case \'A\' .. \'F\':
                                                {
                                                        num = (num << 4) | (ch - (\'A\' - 10));
                                                }
                                                default:
                                                {
                                                        return -1;
                                                }
                                        }
                                }
                                while ((ch = string[stringPos]) > \' \' && ch != delim);
                                setarg(paramPos, 0, num);
                        }
                        case \'c\':
                        {
                                setarg(paramPos, 0, string[stringPos++]);
                        }
                        case \'f\':
                        {
                                new changestr[16], changepos = 0, strpos = stringPos;
                                while(changepos < 16 && string[strpos] && string[strpos] != delim)
                                {
                                        changestr[changepos++] = string[strpos++];
                                }
                                changestr[changepos] = \'\\0\';
                                setarg(paramPos,0,_:floatstr(changestr));
                        }
                        case \'p\':
                        {
                                delim = format[formatPos++];
                                continue;
                        }
                        case \'\\\'\':
                        {
                                new
                                        end = formatPos - 1,
                                        ch;
                                while ((ch = format[++end]) && ch != \'\\\'\') {}
                                if (!ch)
                                {
                                        return -1;
                                }
                                format[end] = \'\\0\';
                                if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
                                {
                                        if (format[end + 1])
                                        {
                                                return -1;
                                        }
                                        return 0;
                                }
                                format[end] = \'\\\'\';
                                stringPos = ch + (end - formatPos);
                                formatPos = end + 1;
                        }
                        case \'u\':
                        {
                                new
                                        end = stringPos - 1,
                                        id = 0,
                                        bool:num = true,
                                        ch;
                                while ((ch = string[++end]) && ch != delim)
                                {
                                        if (num)
                                        {
                                                if (\'0\' <= ch <= \'9\')
                                                {
                                                        id = (id * 10) + (ch - \'0\');
                                                }
                                                else
                                                {
                                                        num = false;
                                                }
                                        }
                                }
                                if (num && IsPlayerConnected(id))
                                {
                                        setarg(paramPos, 0, id);
                                }
                                else
                                {
                                        #if !defined foreach
                                                #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
                                                #define __SSCANF_FOREACH__
                                        #endif
                                        string[end] = \'\\0\';
                                        num = false;
                                        new
                                                name[MAX_PLAYER_NAME];
                                        id = end - stringPos;
                                        foreach (Player, playerid)
                                        {
                                                GetPlayerName(playerid, name, sizeof (name));
                                                if (!strcmp(name, string[stringPos], true, id))
                                                {
                                                        setarg(paramPos, 0, playerid);
                                                        num = true;
                                                        break;
                                                }
                                        }
                                        if (!num)
                                        {
                                                setarg(paramPos, 0, INVALID_PLAYER_ID);
                                        }
                                        string[end] = ch;
                                        #if defined __SSCANF_FOREACH__
                                                #undef foreach
                                                #undef __SSCANF_FOREACH__
                                        #endif
                                }
                                stringPos = end;
                        }
                        case \'s\', \'z\':
                        {
                                new
                                        i = 0,
                                        ch;
                                if (format[formatPos])
                                {
                                        while ((ch = string[stringPos++]) && ch != delim)
                                        {
                                                setarg(paramPos, i++, ch);
                                        }
                                        if (!i)
                                        {
                                                return -1;
                                        }
                                }
                                else
                                {
                                        while ((ch = string[stringPos++]))
                                        {
                                                setarg(paramPos, i++, ch);
                                        }
                                }
                                stringPos--;
                                setarg(paramPos, i, \'\\0\');
                        }
                        default:
                        {
                                continue;
                        }
                }
                while (string[stringPos] && string[stringPos] != delim && string[stringPos] > \' \')
                {
                        stringPos++;
                }
                while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= \' \'))
                {
                        stringPos++;
                }
                paramPos++;
        }
        do
        {
                if ((delim = format[formatPos++]) > \' \')
                {
                        if (delim == \'\\\'\')
                        {
                                while ((delim = format[formatPos++]) && delim != \'\\\'\') {}
                        }
                        else if (delim != \'z\')
                        {
                                return delim;
                        }
                }
        }
        while (delim > \' \');
        return 0;
}
[/pawn]

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal