INI_Load problems, still
#1

So, I now figured out the problem isn't with Y_ini here. First, let's see the code
pawn Код:
new Input[MAX_PASSWORD], Password[MAX_PLAYERS][MAX_PASSWORD], gPass[MAX_PASSWORD];

INI:playerlist[](name[], value[])
{
    INI_String(Input, gPass, sizeof(Input));
    return 0;
}

stock CheckPlayer(playerid){
    if(strlen(Password[playerid]) == 0){
        ShowPlayerDialog(playerid, 30, 1, "Register", "To register you must first give in the first name of your character.", "OK", "");
        return 1;
    }
    else{
        ShowPlayerDialog(playerid, 33, 1, "Login", "Please give in your password.", "OK", "");
        return 1;
    }
}

public OnPlayerConnect(playerid){
    strdel(Input, 0, MAX_PLAYER_NAME);
    GetPlayerName(playerid, Input, sizeof(Input));
    INI_Load("playerlist.ini");
    strpack(Password[playerid], gPass, sizeof(gPass));]
    SendClientMessage(playerid, COLOR_WHITE, Input);
    SendClientMessage(playerid, COLOR_WHITE, gPass);
    CheckPlayer(playerid);
    return 1;
}
My file looks like this
Код:
Max_Havelaar = mypass
Harr_Levis = mypass3
Lead_Admin = mypass67
When you log in as Harr_Levis, that name will be put in Input and the playername (Harr_Levis) and his password (mypass3) will be send to the player after each other. When I next log in with Lead_Admin for example, the playername will still be send to the player (Lead_Admin) but the password which is send is still the password from Harr_Levis (mypass3 and not mypass67). This means something is not right with Input, but I don't know what is going wrong exactly and how to solve it. I tried manually giving Input values (
pawn Код:
strpack(Input, "Harr_Levis", sizeof(Input))
) and with that I could get more than one value out of the file using gPass to store it in. SO Y_ini can't be the problem here, I think it is Input.

Please don't respond if you don't know what the problem is or how to solve it.

Thanks.
Reply
#2

Bump.
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
Also, I told you ages ago about hashing passwords and you still aren't.
I did but the whole code still didn't work so I temporarily removed that piece of code to prevent confusion about that part on the forums, cause you will have a lot of noobs saying I should try to remove the hashes, that it might be the reason it fails. And after some responds my topic will get outdated and nobody will respond, trust me I've been there.

But I got the hash code reasy to implement so thanks for your effort!
Reply
#4

******, why doesn't this work
pawn Код:
public OnPlayerConnect(playerid){
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    strpack(Input, name, sizeof(Input));
    INI_Load("playerlist.ini");
    strpack(Password[playerid], gPass, sizeof(gPass));
    SendClientMessage(playerid, COLOR_WHITE, Input);
    SendClientMessage(playerid, COLOR_WHITE, gPass);
    CheckPlayer(playerid);
    return 1;
}
while this does work
pawn Код:
public OnPlayerConnect(playerid){
    strpack(Input, "Har_Levis", sizeof(Input));
    INI_Load("playerlist.ini");
    SendClientMessage(playerid, COLOR_WHITE, gPass);
    strpack(Input, "Lead_Admin", sizeof(Input));
    INI_Load("playerlist.ini");
    SendClientMessage(playerid, COLOR_WHITE, (gPass);
}
I just don't get it, the first way, Input will be assigned the right playername but the wrong gPass is taken out of the file (the one of the player you log in with first), but when you manually assign a value to Input with strpack it will work!

What the heck, please help with this :S
Reply
#5

Quote:
Originally Posted by ******
Посмотреть сообщение
Why are you using strpack? Try it with normal strings first before trying anything more complicated.
I did!

Man I tried fricking everything over the last three weeks now! Just tell me how to solve it, you created Y_ini, I guess you know why this happens..
Reply
#6

Allrighty, here is my gamemode
pawn Код:
#define COLOR_WHITE         0xFFFFFFFF

#include <a_samp>
#include <YSI/y_ini>
#include <YSI/y_hooks>
#include "../include/loginsystem.inc"

main()
{
    printf("AnteinoServer started.");
    return 1;
}

public OnPlayerSpawn(playerid)
{

    if(GetPVarInt(playerid, "logstatus") == 0){
        SendClientMessage(playerid, COLOR_WHITE, "SERVER: Kicked for teleporting from login.");
        Kick(playerid);
        return 1;
    }
    SetPlayerPos(playerid, 1754.0000, -1893.9800, 14.5000);
    SetPlayerFacingAngle(playerid, 270);
    SetCameraBehindPlayer(playerid);
    SendClientMessage(playerid, COLOR_WHITE, "If you came to help just type your emailadress here and we'll be in contact!");
    return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
   return 1;
}

SetupPlayerForClassSelection(playerid)
{
    PlayerPlaySound(playerid,1052,0.0,0.0,0.0);
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetupPlayerForClassSelection(playerid);
    return 1;
}

public OnGameModeInit()
{
    SetGameModeText("Amsterdam Roleplay");
    ShowPlayerMarkers(1);
    ShowNameTags(1);
    EnableStuntBonusForAll(0);
    return 1;
}
And this is the loginsystem.inc
pawn Код:
new Input[MAX_PASSWORD], Password[MAX_PLAYERS][MAX_PASSWORD], gPass[MAX_PASSWORD];

INI:playerlist[](name[], value[])
{
    INI_String(Input, gPass, sizeof(Input));
    return 0;
}

stock CheckPlayer(playerid){
    if(strlen(Password[playerid]) == 0){
        ShowPlayerDialog(playerid, 30, 1, "Register", "To register you must first give in the first name of your character.", "OK", "");
        return 1;
    }
    else{
        ShowPlayerDialog(playerid, 33, 1, "Login", "Please give in your password.", "OK", "");
        return 1;
    }
}

stock CheckForSymbols(inputtext[], &error){
    if(strfind(inputtext, "/") != -1) error = true;
    if(strfind(inputtext, "~") != -1) error = true;
    if(strfind(inputtext, "`") != -1) error = true;
    if(strfind(inputtext, "!") != -1) error = true;
    if(strfind(inputtext, "@") != -1) error = true;
    if(strfind(inputtext, "#") != -1) error = true;
    if(strfind(inputtext, "$") != -1) error = true;
    if(strfind(inputtext, "%") != -1) error = true;
    if(strfind(inputtext, "^") != -1) error = true;
    if(strfind(inputtext, "&") != -1) error = true;
    if(strfind(inputtext, "*") != -1) error = true;
    if(strfind(inputtext, "(") != -1) error = true;
    if(strfind(inputtext, ")") != -1) error = true;
    if(strfind(inputtext, "-") != -1) error = true;
    if(strfind(inputtext, "+") != -1) error = true;
    if(strfind(inputtext, "=") != -1) error = true;
    if(strfind(inputtext, "|") != -1) error = true;
    if(strfind(inputtext, "1") != -1) error = true;
    if(strfind(inputtext, "2") != -1) error = true;
    if(strfind(inputtext, "3") != -1) error = true;
    if(strfind(inputtext, "4") != -1) error = true;
    if(strfind(inputtext, "5") != -1) error = true;
    if(strfind(inputtext, "6") != -1) error = true;
    if(strfind(inputtext, "7") != -1) error = true;
    if(strfind(inputtext, "8") != -1) error = true;
    if(strfind(inputtext, "9") != -1) error = true;
    if(strfind(inputtext, "0") != -1) error = true;
    if(strfind(inputtext, ",") != -1) error = true;
    if(strfind(inputtext, ".") != -1) error = true;
    if(strfind(inputtext, ";") != -1) error = true;
    if(strfind(inputtext, ":") != -1) error = true;
    if(strfind(inputtext, "'") != -1) error = true;
    if(strfind(inputtext, "\"") != -1) error = true;
    if(strfind(inputtext, "[") != -1) error = true;
    if(strfind(inputtext, "]") != -1) error = true;
    if(strfind(inputtext, "{") != -1) error = true;
    if(strfind(inputtext, "}") != -1) error = true;
    if(strfind(inputtext, "?") != -1) error = true;
    if(strfind(inputtext, "_") != -1) error = true;
    if(strfind(inputtext, " ") != -1) error = true;
    return 1;
}

public OnPlayerConnect(playerid){
    GetPlayerName(playerid, Input, sizeof(Input));
    INI_Load("playerlist.ini");
    strpack(Password[playerid], gPass, sizeof(gPass));
    CheckPlayer(playerid);
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
    if(response == 0){
        if(dialogid >= 30 && dialogid <= 33){
            CheckPlayer(playerid);
            return 0;
        }
    }
    if(response){
        switch(dialogid){
            case 30:{
                new bool:error;
                CheckForSymbols(inputtext, error);
                if(error == true){
                    SendClientMessage(playerid, COLOR_WHITE, "SERVER: Don't use symbols.");
                    ShowPlayerDialog(playerid, 30, 1, "Register", "Please give in the first name of your character.", "OK", "");
                    return 0;
                }
                if(strlen(inputtext) < 2){
                    SendClientMessage(playerid, COLOR_WHITE, "SERVER: That firstname is too short.");
                    ShowPlayerDialog(playerid, 30, 1, "Register", "Please give in the first name of your character.", "OK", "");
                    return 0;
                }
                SetPVarString(playerid, "FirstName", inputtext);
                ShowPlayerDialog(playerid, 31, 1, "Register", "Please give in the last name of your character.", "OK", "Back");
                return 0;
            }
            case 31:{
                new bool:error, msg[128], name;
                CheckForSymbols(inputtext, error);
                if(error == true){
                    SendClientMessage(playerid, COLOR_WHITE, "SERVER: Don't use symbols.");
                    ShowPlayerDialog(playerid, 31, 1, "Register", "Please give in the last name of your character.", "OK", "Back");
                    return 0;
                }
                if(strlen(inputtext) < 2){
                    SendClientMessage(playerid, COLOR_WHITE, "SERVER: That lastname is too short.");
                    ShowPlayerDialog(playerid, 31, 1, "Register", "Please give in the last name of your character.", "OK", "");
                    return 0;
                }
                SetPVarString(playerid, "LastName", inputtext);
                name = GetPVarString(playerid, "FirstName", msg, sizeof(msg)) + GetPVarString(playerid, "LastName", msg, sizeof(msg));
                if(name > 23 || name < 5){
                    SendClientMessage(playerid, COLOR_WHITE, "SERVER: Your character's total name is either too long or too short.");
                    ShowPlayerDialog(playerid, 31, 1, "Register", "Please give in the last name of your character.", "OK", "Back");
                    return 0;
                }
                format(msg, sizeof(msg), "Please give in a password between 5 and %d characters.", MAX_PASSWORD);
                ShowPlayerDialog(playerid, 32, 1, "Register", msg, "OK", "Back");
                return 0;
            }
            case 32:{
                if(strlen(inputtext) < 5 || strlen(inputtext) > MAX_PASSWORD){
                    new msg[128];
                    SendClientMessage(playerid, COLOR_WHITE, "SERVER: Your password is either too long or too short.");
                    format(msg, sizeof(msg), "Please give in a password between 5 and %d characters.", MAX_PASSWORD);
                    ShowPlayerDialog(playerid, 32, 1, "Register", msg, "OK", "Back");
                    return 0;
                }
                new FirstName[MAX_PLAYER_NAME - 4], LastName[MAX_PLAYER_NAME - 4], FullName[MAX_PLAYER_NAME], msg[128];
                GetPVarString(playerid, "FirstName", FirstName, sizeof(FirstName));
                GetPVarString(playerid, "LastName", LastName, sizeof(LastName));
                format(msg, sizeof(msg), "SERVER: You can now login with username %s_%s.", FirstName, LastName);
                SendClientMessage(playerid, COLOR_WHITE, msg);
                format(FullName, sizeof(FullName), "%s_%s", FirstName, LastName);
                new INI:playerlist = INI_Open("playerlist.ini");
                INI_WriteString(playerlist, FullName, inputtext);
                INI_Close(playerlist);
                SetPlayerName(playerid, FullName);
                SetPVarInt(playerid, "logstatus", 1);
                return 0;
            }
            case 33:{
                if(strlen(inputtext) == 0){
                    SendClientMessage(playerid, COLOR_WHITE, "SERVER: Wrong password.");
                    ShowPlayerDialog(playerid, 33, 1, "Login", "Please give in your password.", "OK", "");
                    return 0;
                }
                if(strcmp(Password[playerid], inputtext, false) == 0){
                    SetPVarInt(playerid, "logstatus", 1);
                    return 0;
                }
                else{
                    SendClientMessage(playerid, COLOR_WHITE, "SERVER: Wrong password.");
                    ShowPlayerDialog(playerid, 33, 1, "Login", "Please give in your password.", "OK", "");
                    return 0;
                }
            }
        }
    }
    return 0;
}
Reply
#7

When this all works the hashes will also come ******
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)