Several of warnings and errors
#1

I've followed Kush's registering system tutorial

http://forum.sa-mp.com/showthread.ph...=enum+tutorial


I've completed few steps, had no problems til I reached 7th step, after I firstly received the error, I thought I might've miss-typed something wrong as I didn't copy paste or some shit.

Later on I checked if I had any typing errors, and apparently I had none. I proceed to check what's wrong with my code.

Afterwards I simply pasted the text from the tutorial, yet I received the same error.

Код:
stock UserPath(playerid)
{
	new string[128]PlayerName[MAX_PLAYER_NAME];
	GetPlayerName(playerid,PlayerName,sizeof(playername));
	format(string,sizeof(string),PATH,PlayerName);
	return string;
}
Errors / warnings:

Код:
(83) : error 001: expected token: ";", but found "-identifier-"
(83) : error 017: undefined symbol "PlayerName"
(83) : warning 215: expression has no effect
(83) : error 001: expected token: ";", but found "]"
(83) : fatal error 107: too many error messages on one line
Line 83 = new string[128]PlayerName[MAX_PLAYER_NAME];

Another problem that I experience is izcmd warnings (I decided to test a new include which is faster than the regular zcmd)

Код:
pawno\include\izcmd.inc(93) : warning 217: loose indentation
pawno\include\izcmd.inc(97) : warning 217: loose indentation
pawno\include\izcmd.inc(99) : warning 217: loose indentation
pawno\include\izcmd.inc(100) : warning 217: loose indentation
Is it possible that the include itself is bugged? Because the warning appears to be from the izcmd.inc file itself, it does not include the script name or whatsoever.


Thanks in advanced
Reply
#2

change

PHP код:
new string[128]PlayerName[MAX_PLAYER_NAME]; 
to

PHP код:
new string[128], PlayerName[MAX_PLAYER_NAME]; 
Reply
#3

pawn Код:
// DEVELOPMENT SCRIPT

// ** INCLUDES

#include <a_samp>
#include <YSI\y_ini>

// ** NATIVES

// *** WHIRLPOOL

native WP_Hash(buffer[], len, const str[]);

// ** UN-DEFINES

#undef isnull

// ** DEFINES

// *** FUNCTIONS

#define function%0(%1) forward%0(%1); public%0(%1)
#define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))

// *** DIALOGS

#define DIALOG_REGISTER 0
#define DIALOG_LOGIN 1

// *** DATABASE

#define USER_TAG "player_data"
#define USER_PASSWORD "password"
#define USER_SCORE "score"
#define USER_CASH "cash"
#define USER_KILLS "kills"
#define USER_DEATHS "deaths"
#define USER_ADMIN_LEVEL "admin_level"

// ** ARRAYS AND ENUMERATORS

enum eUserInfo
{
    user_password[129],
    user_score,
    user_cash,
    user_kills,
    user_deaths,
    user_admin_level
}

new aUserInfo[MAX_PLAYERS][eUserInfo];

// ** VARIABLES

// *** PER-PLAYER VARIABLES

new bool:sSignedIn[MAX_PLAYERS] = false;

// ** MAIN

main()
{
    print("Loaded \"ini_login_system.amx\".");
}

// ** CALLBACKS

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUserData", .bExtra = true, .extra = playerid);
        ShowLoginDialog(playerid, "");
    }
    else
    {
        ShowRegisterDialog(playerid, "");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(IsPlayerSignedIn(playerid))
    {
        new INI:file = INI_Open(UserPath(playerid));
        INI_SetTag(file, USER_TAG);

        INI_WriteInt(file, USER_SCORE, GetPlayerScore(playerid));
        INI_WriteInt(file, USER_CASH, GetPlayerMoney(playerid));
        INI_WriteInt(file, USER_KILLS, aUserInfo[playerid][user_kills]);
        INI_WriteInt(file, USER_DEATHS, aUserInfo[playerid][user_deaths]);
        INI_WriteInt(file, USER_ADMIN_LEVEL, aUserInfo[playerid][user_admin_level]);

        INI_Close(file);
    }

    ResetPlayerVariables(playerid);
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if(!response) return KickPlayer(playerid);
            if(response)
            {
                if(isnull(inputtext)) return ShowRegisterDialog(playerid, "Enter a password.");

                new length = strlen(inputtext);
                if(length < 6) return ShowRegisterDialog(playerid, "Password is too short.");
                if(length > 20) return ShowRegisterDialog(playerid, "Password is too long.");

                new hash[129];
                WP_Hash(hash, sizeof(hash), inputtext);

                new INI:file = INI_Open(UserPath(playerid));
                INI_SetTag(file, USER_TAG);

                INI_WriteString(file, USER_PASSWORD, hash);
                INI_WriteInt(file, USER_SCORE, 0);
                INI_WriteInt(file, USER_CASH, 0);
                INI_WriteInt(file, USER_KILLS, 0);
                INI_WriteInt(file, USER_DEATHS, 0);
                INI_WriteInt(file, USER_ADMIN_LEVEL, 0);

                INI_Close(file);

                sSignedIn[playerid] = true;

                return SendClientMessage(playerid, -1, "You have successfully registered an account.");
            }
        }
        case DIALOG_LOGIN:
        {
            if(!response) return KickPlayer(playerid);
            if(response)
            {
                if(isnull(inputtext)) return ShowLoginDialog(playerid, "Enter a password.");

                new hash[129];
                WP_Hash(hash, sizeof(hash), inputtext);

                if(strcmp(aUserInfo[playerid][user_password], hash, false) == 0)
                {
                    INI_ParseFile(UserPath(playerid), "LoadUserData", .bExtra = true, .extra = playerid);
                    SetPlayerScore(playerid, aUserInfo[playerid][user_score]);
                    GivePlayerMoney(playerid, aUserInfo[playerid][user_cash]);

                    sSignedIn[playerid] = true;

                    return SendClientMessage(playerid, -1, "You have successfully logged in to your account.");
                }
                else
                {
                    return ShowLoginDialog(playerid, "Incorrect password.");
                }
            }
        }
    }
    return 1;
}

// ** FUNCTIONS

stock ResetPlayerVariables(playerid)
{
    // ** ARRAYS AND ENUMERATORS:

    aUserInfo[playerid][user_password] = EOS;
    aUserInfo[playerid][user_score] = 0;
    aUserInfo[playerid][user_cash] = 0;
    aUserInfo[playerid][user_kills] = 0;
    aUserInfo[playerid][user_deaths] = 0;
    aUserInfo[playerid][user_admin_level] = 0;

    // ** PER-PLAYER VARIABLES:

    sSignedIn[playerid] = false;
    return 1;
}

function LoadUserData(playerid, name[], value[])
{
    INI_String(USER_PASSWORD, aUserInfo[playerid][user_password], 129);
    INI_Int(USER_SCORE, aUserInfo[playerid][user_score]);
    INI_Int(USER_CASH, aUserInfo[playerid][user_cash]);
    INI_Int(USER_KILLS, aUserInfo[playerid][user_kills]);
    INI_Int(USER_DEATHS, aUserInfo[playerid][user_deaths]);
    INI_Int(USER_ADMIN_LEVEL, aUserInfo[playerid][user_admin_level]);
    return 1;
}

stock ShowRegisterDialog(playerid, error[])
{
    new string[256];
    strcat(string, "Welcome. This account is not registered.\n");
    strcat(string, "Enter a password below to register an account.");
   
    if(!isnull(error))
    {
        strcat(string, "\n\n{FF0000}");
        strcat(string, error);
    }

    return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register", string, "Register", "Close");
}

stock ShowLoginDialog(playerid, error[])
{
    new string[256];
    strcat(string, "Welcome back. This account is already registered.\n");
    strcat(string, "Insert your password to log into your account.");

    if(!isnull(error))
    {
        strcat(string, "\n\n{FF0000}");
        strcat(string, error);
    }

    return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", string, "Login", "Close");
}

stock KickPlayer(playerid) return SetTimerEx("KickPlayerEx", 100, false, "i", playerid);

function KickPlayerEx(playerid) return Kick(playerid);

stock UserPath(playerid)
{
    new string[50], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));

    format(string, sizeof(string), "/Users/%s.ini", name);
    return string;
}

function bool:IsPlayerSignedIn(playerid) return sSignedIn[playerid];
YSI: https://sampforum.blast.hk/showthread.php?tid=570883
Whirlpool: https://sampforum.blast.hk/showthread.php?tid=570945
Reply
#4

alright

REPLACE:
Код:
format(string,sizeof(string),PATH,PlayerName);
WITH:

Код:
format(string,sizeof(string),PATH,PlayerName));
Reply
#5

EDIT: Forget what i said..
Reply
#6

The error still appears and as for Kelvn...I don't need a whole registration code bruv I'm trying fix my error lol
Reply
#7

Код:
#define PATH "/Users/%s.ini" //Please make A FOLDER IN SCRIPTFILES  NAMED Users
stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)