Problem with dialog
#1

Hi guys,i've a problem with login dialog.

pawn Код:
}else
                    {
                        SendClientMessage(playerid, COLOR_RED, "Wrong Password!");
                        new str2[256];
                        new ip[30];
                        GetPlayerIp(playerid,ip,sizeof(ip));
                        format(str2,sizeof str2,"%s tried to login with password: %s - IP: %s", playername,inputtext,ip);
                        FailedLoginLog(str2);
                        return ShowPlayerDialog(playerid,60,DIALOG_STYLE_INPUT,"Login","Welcome to the server\n\nPlease enter your server password\n\nEnter a password:","Login","Quit");
                    }
                }
            }
The dialog is ok,but if i press ESC i can ply without login.

How fix this? I want do if i press ESC that dialog id 60 should appear again,Thanks.
Reply
#2

pawn Код:
if (!response) return ShowPlayerDialog...
Reply
#3

hm.. you could add a variable like "SetPVarInt(playerid, "Logged", 0);" at OnPlayerConnect..
and then on "OnPlayerRequestSpawn" you could do it like this:
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
  if(GetPVarInt(playerid, "Logged") == 0)
  {
    ShowPlayerDialog(........);
    return 0;
  }
  return 1;
}
and ofc add a "SetPVarInt(playerid, "Logged", 1);" at your login dialog
Reply
#4

...both you don't understand me...i don't need a variable becuase i dont need.

I need only fix the ESC problem,i wanna show the dialog again when a player press ESC...
Reply
#5

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
...both you don't understand me...i don't need a variable becuase i dont need.

I need only fix the ESC problem,i wanna show the dialog again when a player press ESC...
I understood that, however I don't know any way that allows you to do what you wish (re-showing the dialog after pausing), therefore a variable would work out, too for the first time, as it prevents players from playing without logging in.
Reply
#6

Umh,i see some servers doing it,plus for a security thing,because i can't use that dialog (a player can spawn without logging in)...also when a player press ESC after the dialog shows,it will be redirected directly on the spawn,also it must exist a way to do it..
Reply
#7

what about checking for a login variable and re-showing the dialog at "OnPlayerRequestClass" if he is not logged in?..
this should work out in the same way, as that's the callback called just behind "OnPlayerConnect"
Reply
#8

I've already a variable to check if player is logged in or not...
Reply
#9

pawn Код:
/*
Login / register system.
Saves Money, HP og score.
Remember to create a folder called "Users"
inside the "scriptfiles" folder on your server.
*/


// Includes
#include <a_samp>
#include <dini>
#include <dudb>
#include <dutils>

// Defines
#define UserFile "Users/%s.ini"
#define COLOR_YELLOW 0xFFFF00FF
#define COLOR_NORMALRED 0xAF0000FF
#define COLOR_SYSTEMRED 0xFF0000FF
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_PINK 0xFF66FFAA
#define COLOR_VIOLET 0x9955DEEE
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_PURPLE 0xC2A2DAAA
#define COLOR_GREEN 0x009900FF
#define COLOR_GREY 0xAFAFAFFF

// Enums
enum pInfo
{
    pMoney,
    pHealth,
    pScore,
    pWantedLevel
}

// Variables
new gPlayerLogged[MAX_PLAYERS];
new PlayerInfo[MAX_PLAYERS][pInfo];
new OnceLogged[MAX_PLAYERS];

// Unused
#pragma unused ret_memcpy

// Callbacks
public OnFilterScriptInit()
{
    print("Login/Register System by Sim_sima Loaded!");
    return 1;
}

public OnPlayerConnect(playerid)
{
    gPlayerLogged[playerid] = 0;
    OnceLogged[playerid] = 0;
    new name[MAX_PLAYER_NAME], file[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), UserFile, name);
    if(!dini_Exists(file))
    {
        new string[75 + MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "( ! ) The username '%s' is not registered. Please enter a password",name);
        SendClientMessage(playerid, COLOR_GREEN, string);
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{FFFF00}Account Management", "{009900}Register new account\n{FFFFFF}Enter a password", "Register", "Quit");
    }
    if(dini_Exists(file))
    {
        new string[80 + MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "( ! ) The username '%s' is already registered. Please enter your password",name);
        SendClientMessage(playerid, COLOR_GREEN, string);
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{FFFF00}Account Management", "{FFFFFF}Enter your password", "Login", "Quit");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new name[MAX_PLAYER_NAME], file[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), UserFile, name);
    if(gPlayerLogged[playerid] == 1)
    {
        if(dini_Exists(file))
        {
            PlayerInfo[playerid][pMoney] = GetPlayerMoney(playerid);
            PlayerInfo[playerid][pScore] = GetPlayerScore(playerid);
            PlayerInfo[playerid][pWantedLevel] = GetPlayerWantedLevel(playerid);
            dini_IntSet(file, "Money",PlayerInfo[playerid][pMoney]);
            new Float:Health;
            GetPlayerHealth(playerid, Health);
            dini_FloatSet(file, "Health", floatround(Health));
            dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
            dini_IntSet(file, "WantedLevel", PlayerInfo[playerid][pWantedLevel]);
        }
    }
    gPlayerLogged[playerid] = 0;
    OnceLogged[playerid] = 0;
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        new name[MAX_PLAYER_NAME], file[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), UserFile, name);
        if(response)
        {
            if(strlen(inputtext) > 15)
            {
                ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{FFFF00}Account Management", "{AF0000}Password must be between 5-15 characters\n{FFFFFF}Enter a password", "Login", "Quit");
            }
            else if(strlen(inputtext) < 5)
            {
                ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{FFFF00}Account Management", "{AF0000}Password must be between 5-15 characters\n{FFFFFF}Enter a password", "Login", "Quit");
            }
            else
            {
                dini_Create(file);
                dini_IntSet(file, "Password", udb_hash(inputtext));
                dini_IntSet(file, "Money",PlayerInfo[playerid][pMoney] = 0);
                dini_FloatSet(file, "Health",PlayerInfo[playerid][pHealth] = 100);
                dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
                dini_IntSet(file, "WantedLevel", PlayerInfo[playerid][pWantedLevel] = 0);
                GameTextForPlayer(playerid, "Welcome", 3000, 5);
                gPlayerLogged[playerid] = 1;
                OnceLogged[playerid] = 1;
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_SYSTEMRED, "( ! ) You need to log in to play on this server. Please come again soon");
            Kick(playerid);
            gPlayerLogged[playerid] = 0;
            OnceLogged[playerid] = 0;
        }
    }
    if(dialogid == 2)
    {
        new name[MAX_PLAYER_NAME], file[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), UserFile, name);
        if(!response)
        {
            SendClientMessage(playerid, COLOR_SYSTEMRED, "( ! ) You need to log in to play on this server. Please come again soon");
            Kick(playerid);
        }
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp)
        {
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{FFFF00}Account Management", "{AF0000}Wrong password\n{FFFFFF}Enter your password", "Login", "Quit");
        }
        else
        {
            gPlayerLogged[playerid] = 1;
            OnceLogged[playerid] = 1;
            GameTextForPlayer(playerid, "Welcome", 3000, 5);
            // Give loaded stuff to player from file
            GivePlayerMoney(playerid, dini_Int(file, "Money"));
            SetPlayerHealth(playerid, dini_Float(file, "Health"));
            SetPlayerScore(playerid, dini_Int(file, "Score"));
            SetPlayerWantedLevel(playerid, dini_Int(file, "WantedLevel"));
        }
    }
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    new name[MAX_PLAYER_NAME], file[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), UserFile, name);
    if(OnceLogged[playerid] == 1)
    {
        SetPlayerWantedLevel(playerid, dini_Int(file, "WantedLevel"));
        OnceLogged[playerid] = 0;
    }
    if(gPlayerLogged[playerid] == 0)
    {
        SendClientMessage(playerid, COLOR_SYSTEMRED, "( ! ) Please log in first");
        return 0;
    }
    return 1;
}

public OnFilterScriptExit()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        CallLocalFunction("OnPlayerDisconnect", "%d", i);
    }
    return 1;
}
Reply
#10

-_- Please don't do stupid answers...

I've already:

My login variable.
My register script.

I just need to RESHOW THE DIALOG AFTER A PLAYER PRESS ESC.

EDIT: Fixed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)