login problem
#1

Hello,

I just want to know what's my problem with this code, if I registered or not, it always displays the register system

here is my code:

Код:
format(string, sizeof(string), "Users/%s.ini", playername);//register
			if (dini_Exists(string))
			{
		    	RegLogIn[playerid] = 1;
	    		SetPlayerCameraPos(playerid, 1363.3137,-1276.4448,21.6530);
				SetPlayerCameraLookAt(playerid, 1285.9583,-1219.0508,104.1589);
	    		ShowDialogID(playerid, 1);
	    		TextDrawHideForPlayer(playerid, MainTD[0]);
	    		TextDrawHideForPlayer(playerid, MainTD[1]);
	    		TogglePlayerControllable(playerid, false);
	    		SetPlayerPos(playerid, -1753.8430,885.1340,295.8750);
			}
			if (dini_Exists(string))//Login
			{
	    		ShowDialogID(playerid, 2);
	    		RegLogIn[playerid] = 1;
	    		TextDrawHideForPlayer(playerid, MainTD[0]);
	    		TextDrawHideForPlayer(playerid, MainTD[1]);
			}
Note: If you knew the problem , please don't just post a code or something like, please add an explanation with it, many thanks!!

Edit:dialog ids are not similar or even mixed with each other
Reply
#2

check this out first ;
https://sampforum.blast.hk/showthread.php?tid=308390
https://sampforum.blast.hk/showthread.php?tid=101560

and back to this thread. .
u get any Error ? warning ?
Reply
#3

Quote:
Originally Posted by Devilxz97
Посмотреть сообщение
check this out first ;
https://sampforum.blast.hk/showthread.php?tid=308390
https://sampforum.blast.hk/showthread.php?tid=101560

and back to this thread. .
u get any Error ? warning ?
first thanks for the help. second I thought that the topic says "Scripting Help"?, or am I not in that topic?
Reply
#4

Well it's a silly mistake, you can use the conditional operator ! different means.

I will show how your code using the conditional operator !


Код:
format(string, sizeof(string), "Users/%s.ini", playername);//register
			if (!dini_Exists(string))
			{
		    	RegLogIn[playerid] = 1;
	    		SetPlayerCameraPos(playerid, 1363.3137,-1276.4448,21.6530);
				SetPlayerCameraLookAt(playerid, 1285.9583,-1219.0508,104.1589);
	    		ShowDialogID(playerid, 1);
	    		TextDrawHideForPlayer(playerid, MainTD[0]);
	    		TextDrawHideForPlayer(playerid, MainTD[1]);
	    		TogglePlayerControllable(playerid, false);
	    		SetPlayerPos(playerid, -1753.8430,885.1340,295.8750);
			}
			if (dini_Exists(string))//Login
			{
	    		ShowDialogID(playerid, 2);
	    		RegLogIn[playerid] = 1;
	    		TextDrawHideForPlayer(playerid, MainTD[0]);
	    		TextDrawHideForPlayer(playerid, MainTD[1]);
			}
Well as I said above, notice now if (!dini_Exists(string)) if the file does not exist and the record will show if there is display the login.

I hope I have helped
Reply
#5

Quote:
Originally Posted by Marlon_Lorran
Посмотреть сообщение
Well it's a silly mistake, you can use the conditional operator ! different means.

I will show how your code using the conditional operator !


Код:
format(string, sizeof(string), "Users/%s.ini", playername);//register
			if (!dini_Exists(string))
			{
		    	RegLogIn[playerid] = 1;
	    		SetPlayerCameraPos(playerid, 1363.3137,-1276.4448,21.6530);
				SetPlayerCameraLookAt(playerid, 1285.9583,-1219.0508,104.1589);
	    		ShowDialogID(playerid, 1);
	    		TextDrawHideForPlayer(playerid, MainTD[0]);
	    		TextDrawHideForPlayer(playerid, MainTD[1]);
	    		TogglePlayerControllable(playerid, false);
	    		SetPlayerPos(playerid, -1753.8430,885.1340,295.8750);
			}
			if (dini_Exists(string))//Login
			{
	    		ShowDialogID(playerid, 2);
	    		RegLogIn[playerid] = 1;
	    		TextDrawHideForPlayer(playerid, MainTD[0]);
	    		TextDrawHideForPlayer(playerid, MainTD[1]);
			}
Well as I said above, notice now if (!dini_Exists(string)) if the file does not exist and the record will show if there is display the login.

I hope I have helped
okay thanks, but, nope you are wrong, "ShowDialogID(playerid, 1);" << = register , "ShowDialogID(playerid, 2);" <<= Login, and thanks for helping, and if I didn't get it, please post a reply
Reply
#6

Is this correct what I said, ShowDialogID (playerid, 1) == register and ShowDialogID (playerid, 2) == login, but tests there and see if it worked.

: D :: D D...
Reply
#7

Quote:
Originally Posted by Marlon_Lorran
Посмотреть сообщение
Is this correct what I said, ShowDialogID (playerid, 1) == register and ShowDialogID (playerid, 2) == login, but tests there and see if it worked.

: D :: D D...
ooh man, I just forget to add to the post this "!", I thought it was in, my bad, that's why I told you , you were wrong
Reply
#8

try this

pawn Код:
//Includes
#include <a_samp>
#include <dini>
#include <dudb>

//Pragma unused
#pragma unused strtok
#pragma unused ret_memcpy

#define DIALOG_REGISTER 227 // Define a Dialog for Register
#define DIALOG_LOGIN 225 // Define a Dialog for Login

#define SERVER_USER_FILE "PlayerAccount/%s.ini" // This will save the Player Account when he's Register

new PlayerLogged[MAX_PLAYERS];

enum pInfo // Setup your Variables
{
    pAdmin, //Admin Variables
    pMoney //Money Variables
}
new PlayerInfo[MAX_PLAYERS][pInfo];

public OnPlayerRequestClass(playerid, classid)
{
        // You can change this to OnplayerConnect / OnplayerSpawn / OnplayerRequestClass
        new name[MAX_PLAYER_NAME], dfile[256];
        GetPlayerName(playerid, name, sizeof(name));
        format(dfile, sizeof(dfile), SERVER_USER_FILE, name);
        if (!dini_Exists(dfile))
        {
            ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Welcome {FF0000}Guest! {FFFFFF}- {FFFF00}Register", "{00FF00}Welcome! {FFFFFF}This account isn't {FF0000}registered!\n{FFFFFF}Please input your password to {FF0000}register!", "Register", "Refuse");
        }
        if(fexist(dfile))
        {
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome {00FF00}Back! {FFFFFF}- {FFFF00}Login", "{00FF00}Welcome Back! {FFFFFF}This account is {FF0000}{00FF00}registered!\n{FFFFFF}Please input your password to {00FF00}login!", "Login", "Refuse");
        }
        return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    //here when the player left the server , the Admin/Money will be save !
    new pName[MAX_PLAYER_NAME], dfile[256];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(dfile, sizeof(dfile), SERVER_USER_FILE, pName);
    if(PlayerLogged[playerid] == 1)
    {
        dini_IntSet(dfile, "Admin", PlayerInfo[playerid][pAdmin]);
        dini_IntSet(dfile, "Money", GetPlayerMoney(playerid));
    }
    PlayerLogged[playerid] = 0;
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if (dialogid == DIALOG_REGISTER) // Dialog Register
    {
        new name[MAX_PLAYER_NAME], dfile[256], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(dfile, sizeof(dfile), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Welcome {FF0000}Guest! {FFFFFF}- {FFFF00}Register", "{00FF00}Welcome! {FFFFFF}This account isn't {FF0000}registered!\n{FFFFFF}Please input your password to {FF0000}register!", "Register", "Refuse");
        dini_Create(dfile);
        dini_IntSet(dfile, "Password", udb_hash(inputtext));
        dini_IntSet(dfile, "Admin", PlayerInfo[playerid][pAdmin]);
        dini_IntSet(dfile, "Money", GetPlayerMoney(playerid));
        format(string, 128, "[SERVER]: You succesfully registered the nickname {00FF00}%s", name);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome {00FF00}Back! {FFFFFF}- {FFFF00}Login", "{00FF00}Welcome Back! {FFFFFF}This account is {FF0000}{00FF00}registered!\n{FFFFFF}Please input your password to {00FF00}login!", "Login", "Refuse");
    }
    if (dialogid == DIALOG_LOGIN) // Dialog Login
    {
        new name[MAX_PLAYER_NAME], dfile[256];
        GetPlayerName(playerid, name, sizeof(name));
        format(dfile, sizeof(dfile), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return  ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome {00FF00}Back! {FFFFFF}- {FFFF00}Login", "{00FF00}Welcome Back! {FFFFFF}This account is {FF0000}{00FF00}registered!\n{FFFFFF}Please input your password to {00FF00}login!", "Login", "Refuse");
        new tmp;
        tmp = dini_Int(dfile, "Password");
        if(udb_hash(inputtext) != tmp) {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome {00FF00}Back! {FFFFFF}- {FFFF00}Login", "{00FF00}Welcome Back! {FFFFFF}This account is {FF0000}{00FF00}registered!\n{FFFFFF}Please input your password to {00FF00}login!", "Login", "Refuse");
        }
        else
        {
            PlayerInfo[playerid][pAdmin] = dini_Int(dfile, "Admin");
            GivePlayerMoney(playerid, dini_Int(dfile, "Cash")-GetPlayerMoney(playerid));
            SpawnPlayer(playerid);
        }
    }
    return 1;
}
a new login/register i made in a few mins to help you
this is more simple and easy

EDIT:Let me try fix your script . .
Reply
#9

Quote:
Originally Posted by Youice
Посмотреть сообщение
ooh man, I just forget to add to the post this "!", I thought it was in, my bad, that's why I told you , you were wrong
but solve your problem?
Reply
#10

Quote:
Originally Posted by Devilxz97
Посмотреть сообщение
try this

pawn Код:
//Includes
#include <a_samp>
#include <dini>
#include <dudb>

//Pragma unused
#pragma unused strtok
#pragma unused ret_memcpy

#define DIALOG_REGISTER 227 // Define a Dialog for Register
#define DIALOG_LOGIN 225 // Define a Dialog for Login

#define SERVER_USER_FILE "PlayerAccount/%s.ini" // This will save the Player Account when he's Register

new PlayerLogged[MAX_PLAYERS];

enum pInfo // Setup your Variables
{
    pAdmin, //Admin Variables
    pMoney //Money Variables
}
new PlayerInfo[MAX_PLAYERS][pInfo];

public OnPlayerRequestClass(playerid, classid)
{
        // You can change this to OnplayerConnect / OnplayerSpawn / OnplayerRequestClass
        new name[MAX_PLAYER_NAME], dfile[256];
        GetPlayerName(playerid, name, sizeof(name));
        format(dfile, sizeof(dfile), SERVER_USER_FILE, name);
        if (!dini_Exists(dfile))
        {
            ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Welcome {FF0000}Guest! {FFFFFF}- {FFFF00}Register", "{00FF00}Welcome! {FFFFFF}This account isn't {FF0000}registered!\n{FFFFFF}Please input your password to {FF0000}register!", "Register", "Refuse");
        }
        if(fexist(dfile))
        {
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome {00FF00}Back! {FFFFFF}- {FFFF00}Login", "{00FF00}Welcome Back! {FFFFFF}This account is {FF0000}{00FF00}registered!\n{FFFFFF}Please input your password to {00FF00}login!", "Login", "Refuse");
        }
        return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    //here when the player left the server , the Admin/Money will be save !
    new pName[MAX_PLAYER_NAME], dfile[256];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(dfile, sizeof(dfile), SERVER_USER_FILE, pName);
    if(PlayerLogged[playerid] == 1)
    {
        dini_IntSet(dfile, "Admin", PlayerInfo[playerid][pAdmin]);
        dini_IntSet(dfile, "Money", GetPlayerMoney(playerid));
    }
    PlayerLogged[playerid] = 0;
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if (dialogid == DIALOG_REGISTER) // Dialog Register
    {
        new name[MAX_PLAYER_NAME], dfile[256], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(dfile, sizeof(dfile), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Welcome {FF0000}Guest! {FFFFFF}- {FFFF00}Register", "{00FF00}Welcome! {FFFFFF}This account isn't {FF0000}registered!\n{FFFFFF}Please input your password to {FF0000}register!", "Register", "Refuse");
        dini_Create(dfile);
        dini_IntSet(dfile, "Password", udb_hash(inputtext));
        dini_IntSet(dfile, "Admin", PlayerInfo[playerid][pAdmin]);
        dini_IntSet(dfile, "Money", GetPlayerMoney(playerid));
        format(string, 128, "[SERVER]: You succesfully registered the nickname {00FF00}%s", name);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome {00FF00}Back! {FFFFFF}- {FFFF00}Login", "{00FF00}Welcome Back! {FFFFFF}This account is {FF0000}{00FF00}registered!\n{FFFFFF}Please input your password to {00FF00}login!", "Login", "Refuse");
    }
    if (dialogid == DIALOG_LOGIN) // Dialog Login
    {
        new name[MAX_PLAYER_NAME], dfile[256];
        GetPlayerName(playerid, name, sizeof(name));
        format(dfile, sizeof(dfile), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return  ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome {00FF00}Back! {FFFFFF}- {FFFF00}Login", "{00FF00}Welcome Back! {FFFFFF}This account is {FF0000}{00FF00}registered!\n{FFFFFF}Please input your password to {00FF00}login!", "Login", "Refuse");
        new tmp;
        tmp = dini_Int(dfile, "Password");
        if(udb_hash(inputtext) != tmp) {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome {00FF00}Back! {FFFFFF}- {FFFF00}Login", "{00FF00}Welcome Back! {FFFFFF}This account is {FF0000}{00FF00}registered!\n{FFFFFF}Please input your password to {00FF00}login!", "Login", "Refuse");
        }
        else
        {
            PlayerInfo[playerid][pAdmin] = dini_Int(dfile, "Admin");
            GivePlayerMoney(playerid, dini_Int(dfile, "Cash")-GetPlayerMoney(playerid));
            SpawnPlayer(playerid);
        }
    }
    return 1;
}
a new login/register i made in a few mins to help you
this is more simple and easy

EDIT:Let me try fix your script . .
Quote:
Originally Posted by Marlon_Lorran
Посмотреть сообщение
but solve your problem?
oka-ay, Thanks all, (rep++)
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)