Saving SCORE WITH Y_INI PROBLEM
#1

I NEED HELP BADLY PLAYERS COMPLAINGING "admin wheres my score?" , "admin I WANT MY SCORE BAX"

and omfg it hurts ffs!


Okay this is the problem.

This is my script.

Does anyone knows how to make it save score because its not saving

pawn Код:
#include <a_samp>
#include <YSI\y_ini>


enum ENUM_DATA { Score }
new
    _pVars[ MAX_PLAYERS ][ ENUM_DATA ];


forward load_user_score( playerid, name[], value[] );
public load_user_score( playerid, name[], value[] )
{
    INI_Int( "Score", _pVars[ playerid ][ Score ] );
    return 1;
}

stock USER_PATH(playerid)
{
    new
        _str[ 128 ],P_NAME[ MAX_PLAYER_NAME ];

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

public OnPlayerConnect( playerid )
{
    _pVars[ playerid ][ Score ] = 0;
    INI_ParseFile( USER_PATH ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid );
        // I dont see the part where It says SetPlayerScore(playerid . I know its suppose to set the PLAYERS score                        //    when he connects.

    return ( true );
}

public OnPlayerDeath( playerid, killerid, reason )
{
    if ( killerid != INVALID_PLAYER_ID )
    {
        SetPlayerScore( killerid, GetPlayerScore( killerid ) + 0 );
    }
    return ( true );
}

public OnPlayerDisconnect( playerid, reason )
{
    new
        INI:File = INI_Open( USER_PATH ( playerid ) );
    INI_SetTag( File,"score" );

    INI_WriteInt( File,"Score", GetPlayerScore( playerid ) );
    INI_Close( File );
    return ( true );
}
Reply
#2

Try this:
https://sampforum.blast.hk/showthread.php?tid=273088
Reply
#3

DUDE IM LOOKING FOR IT TO SAVE SCORE , THAT DOESNT EVEN SAVE SCORE MAN!!! I REALLY NEED HELP ON THIS
Reply
#4

pawn Код:
INI_ParseFile( USER_PATH ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid );
to
pawn Код:
INI_ParseFile( USER_PATH ( playerid ), "load_user_%s", false, true, playerid );
Give me the USER_PATH( playerid ); function
Reply
#5

pawn Код:
stock USER_PATH(playerid)
{
    new
        _str[ 128 ],P_NAME[ MAX_PLAYER_NAME ];

    GetPlayerName( playerid, P_NAME, MAX_PLAYER_NAME );
    format( _str, sizeof ( _str ), "%s.ini", P_NAME );
    return _str;
}
PLEASE HELP MEH
Reply
#6

Try this:
pawn Код:
public OnPlayerDisconnect( playerid, reason )
{
    new INI:file = INI_Open( USER_PATH( playerid ) );

    INI_WriteInt( file,"Score", GetPlayerScore( playerid ) );
    INI_Close( file );
    return ( true );
}
And use this too:
pawn Код:
stock USER_PATH( playerid )
{
    new _str[ 128 ], P_NAME[ MAX_PLAYER_NAME + 1 ];

    GetPlayerName( playerid, P_NAME, sizeof P_NAME );
    format( _str, sizeof _str, "%s.ini", P_NAME );
    return _str;
}
Reply
#7

-_-- Thats ALREADY on it, I need to Make it LOAD THE SCORE!

ANYONE PLEASE HELP Roach Please I need it to LOAD THE SCORE In OnPlayerConnect
Reply
#8

Quote:
Originally Posted by California_
Посмотреть сообщение
DUDE IM LOOKING FOR IT TO SAVE SCORE , THAT DOESNT EVEN SAVE SCORE MAN!!! I REALLY NEED HELP ON THIS
This system is better to save the stuff. Just copy the money save and change code to score. Is that so hard?
Reply
#9

Yeah! Can you do it? and post it here.
Reply
#10

Oooooh, load it, a misunderstanding:
Use this:
pawn Код:
INI_ParseFile(playerfile, "load_user", .bExtra = true, .extra = playerid, .bPassTag = true);
Then add this:
pawn Код:
forward load_user(playerid, name[ ], value[ ]);
public load_user(playerid, name[], value[])
{
    INI_Int("Score", _pVars[ playerid ][ Score ]);
    SetPlayerScore( playerid, _pVars[ playerid ][ Score ] );
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)