INI_Load problems, still
#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


Messages In This Thread
INI_Load problems, still - by Anteino - 28.04.2011, 11:49
Re: INI_Load problems, still - by Anteino - 01.05.2011, 13:58
Re: INI_Load problems, still - by Anteino - 01.05.2011, 19:44
Re: INI_Load problems, still - by Anteino - 02.05.2011, 15:18
Re: INI_Load problems, still - by Anteino - 02.05.2011, 16:36
Re: INI_Load problems, still - by Anteino - 02.05.2011, 22:27
Re: INI_Load problems, still - by Anteino - 03.05.2011, 08:47

Forum Jump:


Users browsing this thread: 1 Guest(s)