Error Already defined
#1

Hi,

I am getting an error on my script (a literal new one)
Error:
Код:
(34) : error 021: symbol already defined: "format"
Script:
Код:
#include <a_samp>
#include <YSI\y_ini>
#include <YSI\y_commands>
#include <YSI\y_timers>
#include <foreach>
#include <sscanf2>
native WP_Hash(_buffer[], len, const str[]);

#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2

#define COLOR_WHITE "{FFFFFF}"
#define COLOR_RED "{F81414}"
#define COLOR_GREEN "{00FF22}"

enum USER_ENUM { Password[ 129 ], Score, Deaths, Money, Admin_Level }
new
	userData[ MAX_PLAYERS ][ USER_ENUM ];
	

stock user_account_path(playerid)
{
    new
        string_path[ 128 ],
        player_name[ MAX_PLAYER_NAME ];

    GetPlayerName( playerid, player_name, MAX_PLAYER_NAME );
    format( string_path, sizeof ( string_path ), "%s.ini", player_name);
    return
        string_path;
}


format( string_path, sizeof ( string_path ), "Accounts/%s.ini", player_name);
forward @load_user_statistics(playerid, name[], value[]);

@load_user_statistics(playerid, name[], value[])
{
    INI_String("Password", userData[ playerid ][ Password ], 129);
    INI_Int("Money", userData[ playerid ][ Money ]);
    INI_Int("AdminLevel", userData[ playerid ][ Admin_Level ]);
    INI_Int("Deaths", userData[ playerid ][ Deaths ]);
	INI_Int("Score", userData[ playerid ][ Score ]);
    return 1;
}




main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}

public OnGameModeInit()
{
	// Don't use these lines if it's a filterscript
	SetGameModeText("Blank Script");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}

public OnPlayerConnect(playerid)
{
    if( fexist ( user_account_path ( playerid ) ) )
    {
		INI_ParseFile(user_account_path ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Welcome.Please log-in",""COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to log-in", #Log-in, #Quit);
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Please register!",""COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to register.", #Register, #Quit);
    }
	userData[ playerid ][ Admin_Level ] = 0;
	userData[ playerid ][ Money ] = 0;
	userData[ playerid ][ Deaths ] = 0;
	userData[ playerid ][ Score ] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open( user_account_path ( playerid ) );
    INI_SetTag(File, "statistics" );
    INI_WriteInt(File, "Money", GetPlayerMoney( playerid ) );
    INI_WriteInt(File, "AdminLevel", userData[ playerid ][ Admin_Level ] );
    INI_WriteInt(File, "Deaths", userData[ playerid ][ Deaths ] );
	INI_WriteInt(File, "Score", GetPlayerScore( playerid ) );
    INI_Close(File);
    return 1;
}

public OnPlayerSpawn(playerid)
{
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if( killerid != INVALID_PLAYER_ID ) SetPlayerScore( killerid, GetPlayerScore( killerid ) + 1 );

    userData[ playerid ][ Deaths ] ++;

    return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/mycommand", cmdtext, true, 10) == 0)
	{
		// Do something here
		return 1;
	}
	return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	return 1;
}

public OnRconCommand(cmd[])
{
	return 1;
}

public OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
	return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
	return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	return 1;
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
	return 1;
}

public OnPlayerUpdate(playerid)
{
	return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
	return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
	return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
	return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick( playerid );
            if ( response )
            {
                if( !strlen ( inputtext ) ) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COLOR_WHITE"Welcome.Please log-in","You have entered an "COLOR_RED"invalid"COLOR_WHITE" password\n"COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to log-in", #Register, #Quit);

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

				new INI:File = INI_Open( user_account_path( playerid ) );
                INI_SetTag(File, "statistics" );
                INI_WriteString(File, "Password", hashed_password );
                INI_WriteInt(File, "Money", 0 );
                INI_WriteInt(File, "AdminLevel", 0 );
                INI_WriteInt(File, "Deaths", 0 );
				INI_WriteInt(File, "Score", 0 );
                INI_Close(File);
                SetSpawnInfo( playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0 );
                SpawnPlayer( playerid );
			}
        }
        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
				new
					hashed_password[ 129 ];
				WP_Hash( hashed_password, sizeof ( hashed_password ), inputtext );

                if( !strcmp ( hashed_password, userData[ playerid ][ Password ] ) )
                {
                    INI_ParseFile(user_account_path ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney( playerid, userData[ playerid ][ Money ] );
					SetPlayerScore( playerid, userData[ playerid ][ Score ] );
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COLOR_WHITE"Login",""COLOR_RED"You have entered an incorrect password.\n"COLOR_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}
Thanks
Reply
#2

Remove that line as it has no purpose. If it saves in "Accounts" folder, add it in user_account_path because it currently saves in scriptfiles.
Reply
#3

this error is because your code is outside of a function. For example:

PHP код:
format(...);
main()
{

Right way to do is :

PHP код:
main()
{
    
format(...);

good luck
Reply
#4

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Remove that line as it has no purpose. If it saves in "Accounts" folder, add it in user_account_path because it currently saves in scriptfiles.
Can you send me the code?
Reply
#5

Guysss
Reply
#6

Have you created "Accounts" Folder in scriptfiles?
Reply
#7

Quote:
Originally Posted by UberEverywhere
Посмотреть сообщение
Have you created "Accounts" Folder in scriptfiles?
Real stupid [HiT]Uber lol
Reply
#8

Quote:
Originally Posted by MCZOFT
Посмотреть сообщение
this error is because your code is outside of a function. For example:

PHP код:
format(...);
main()
{

Right way to do is :

PHP код:
main()
{
    
format(...);

good luck
He's right.. Your line is sitting outside of its boundaries.
Reply
#9

Here, I've fixed the error for you.

PHP код:
#include <a_samp>
#include <YSI\y_ini>
#include <YSI\y_commands>
#include <YSI\y_timers>
#include <foreach>
#include <sscanf2>
native WP_Hash(_buffer[], len, const str[]);
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define COLOR_WHITE "{FFFFFF}"
#define COLOR_RED "{F81414}"
#define COLOR_GREEN "{00FF22}"
#define PATH "/Accounts/%s.ini"
enum USER_ENUM {Password[129], ScoreDeathsMoneyAdmin_Level}
new 
userData[MAX_PLAYERS][USER_ENUM];
UserAccountPath(playerid)
{
    new 
string_path[128], player_name[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,player_name,sizeof(player_name));
    
format(string_pathsizeof(string_path), PATHplayer_name);
    return 
string_path;
}
forward LoadUser_data(playeridname[], value[]);
public 
LoadUser_data(playeridname[], value[])
{
    
INI_String("Password"userData[playerid][Password], 129);
    
INI_Int("Money"userData[playerid][Money]);
    
INI_Int("AdminLevel"userData[playerid][Admin_Level]);
    
INI_Int("Deaths"userData[playerid][Deaths]);
    
INI_Int("Score"userData[playerid][Score]);
    return 
1;
}
main()
{
    print(
"\n----------------------------------");
    print(
" Blank Gamemode by your name here");
    print(
"----------------------------------\n");
}
public 
OnGameModeInit()
{
    
// Don't use these lines if it's a filterscript
    
SetGameModeText("Blank Script");
    
AddPlayerClass(01958.37831343.157215.3746269.1425000000);
    return 
1;
}
public 
OnGameModeExit()
{
    return 
1;
}
public 
OnPlayerRequestClass(playeridclassid)
{
    
SetPlayerPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraLookAt(playerid1958.37831343.157215.3746);
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    if(
fexist(UserAccountPath(playerid)))
    {
        
INI_ParseFile(UserAccountPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,"Welcome.Please log-in",""COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to log-in"#Log-in, #Quit);
    
}
    else
    {
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT,"Please register!",""COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to register."#Register, #Quit);
    
}
    
userData[playerid][Admin_Level] = 0;
    
userData[playerid][Money] = 0;
    
userData[playerid][Deaths] = 0;
    
userData[playerid][Score] = 0;
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    new 
INI:File INI_Open(UserAccountPath(playerid));
    
INI_SetTag(File"Statistics");
    
INI_WriteInt(File"Money"GetPlayerMoney(playerid));
    
INI_WriteInt(File"AdminLevel"userData[playerid][Admin_Level]);
    
INI_WriteInt(File"Deaths"userData[playerid][Deaths]);
    
INI_WriteInt(File"Score"GetPlayerScore(playerid));
    
INI_Close(File);
    return 
1;
}

public 
OnPlayerDeath(playeridkilleridreason)
{
    if( 
killerid != INVALID_PLAYER_ID SetPlayerScorekilleridGetPlayerScorekillerid ) + );
    
userDataplayerid ][ Deaths ] ++;
    return 
1;
}

public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_REGISTER:
        {
            if (!
response) return Kick(playerid);
            if (
response)
            {
                if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT,""COLOR_WHITE"Welcome.Please log-in","You have entered an "COLOR_RED"invalid"COLOR_WHITE" password\n"COLOR_WHITE"Type your "COLOR_GREEN"password "COLOR_WHITE"here to log-in"#Register, #Quit);

                
new hashed_password[129];
                
WP_Hash(hashed_passwordsizeof(hashed_password), inputtext);
                new 
INI:File INI_Open(UserAccountPath(playerid));
                
INI_SetTag(File"statistics");
                
INI_WriteString(File"Password"hashed_password);
                
INI_WriteInt(File"Money"0);
                
INI_WriteInt(File"AdminLevel"0);
                
INI_WriteInt(File"Deaths"0);
                
INI_WriteInt(File"Score"0);
                
INI_Close(File);
                
SetSpawnInfo(playerid001958.331343.1215.36269.1500000);
                
SpawnPlayer(playerid);
            }
        }
        case 
DIALOG_LOGIN:
        {
            if (!
response) return Kick (playerid);
            if(
response)
            {
                new 
hashed_password[129];
                
WP_Hash(hashed_password,sizeof(hashed_password), inputtext);
                if(!
strcmp(hashed_passworduserData[playerid][Password]))
                {
                    
INI_ParseFile(UserAccountPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
                    
GivePlayerMoney(playeriduserData[playerid][Money]);
                    
SetPlayerScore(playeriduserData[playerid][Score]);
                }
                else
                {
                    
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""COLOR_WHITE"Login",""COLOR_RED"You have entered an incorrect password.\n"COLOR_WHITE"Type your password below to login.","Login","Quit");
                }
                return 
1;
            }
        }
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)