Problem with loading position (used SmiT tutorial)
#1

Hello guys, please can somebody help me? I have got a problem, I tried the SmiT tutorial (Save, load and set player position - using y_ini) but i got problem. I normally put all codes to my GM, compiled with no error or warning. I have started server, normally logged in. Then i disconnected and my account .ini file was successfuly created, coordinates were saved. But, when i relloged to server, these coordinates won't load, it keeps spawn me on defualt spawn. I tried to download .pwn script created by he, same problem. Thanks for reply. And, excuse my bad english.

Here is pawn code:

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

new
    Float: PosX[ MAX_PLAYERS ],
    Float: PosY[ MAX_PLAYERS ],
    Float: PosZ[ MAX_PLAYERS ],
    Float: Angle[ MAX_PLAYERS ],
    Interior[ MAX_PLAYERS ],
    VirtualWorld[ MAX_PLAYERS ]
;

stock user_ini_file(playerid)
{
    new
        string[ 128 ],
        user_name[ MAX_PLAYER_NAME ]
    ;

    GetPlayerName( playerid, user_name, MAX_PLAYER_NAME );
    format( string, sizeof ( string ), "%s.ini", user_name );
    /* scriptfiles directory */
    return
        string;
}

forward @load_user_position( playerid, name[], value[] );

@load_user_position( playerid, name[], value[] )
{
    INI_Float( "PositionX", PosX[ playerid ] );
    INI_Float( "PositionY", PosY[ playerid ] );
    INI_Float( "PositionZ", PosZ[ playerid ] );
    INI_Float( "Angle", Angle[ playerid ] );
    INI_Int( "Interior", Interior[ playerid ] );
    INI_Int( "VirtualWorld", VirtualWorld[ playerid ] );
    return ( 1 );
}

public OnPlayerDisconnect( playerid, reason )
{
    GetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
    GetPlayerFacingAngle( playerid, Angle[ playerid ] );
   
    new INI:File = INI_Open( user_ini_file( playerid ) );
    INI_SetTag( File, "position" );
    INI_WriteFloat( File, "PositionX", PosX[ playerid ] );
    INI_WriteFloat( File, "PositionY", PosY[ playerid ] );
    INI_WriteFloat( File, "PositionZ", PosZ[ playerid ] );
    INI_WriteFloat( File, "Angle", Angle[ playerid ] );
    INI_WriteInt( File, "Interior", GetPlayerInterior( playerid ) );
    INI_WriteInt( File, "VirtualWorld", GetPlayerVirtualWorld( playerid ) );
    INI_Close( File );
    return ( 1 );
}

public OnPlayerConnect( playerid )
{
    PosX[ playerid ] = 0;
    PosY[ playerid ] = 0;
    PosZ[ playerid ] = 0;
    Angle[ playerid ] = 0;
    Interior[ playerid ] = 0;
    VirtualWorld[ playerid ] = 0;
   
    INI_ParseFile( user_ini_file( playerid ), "load_user_%s", .bExtra = true, .extra = playerid );
    return ( 1 );
}


public OnPlayerSpawn( playerid )
{
    if ( PosX[ playerid ] != 0 && PosY[ playerid ] != 0 && PosZ[ playerid ] != 0 )
    {
        SetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
        SetPlayerFacingAngle( playerid, Angle[ playerid ] );
        SetPlayerInterior( playerid, Interior[ playerid ] );
        SetPlayerVirtualWorld( playerid, VirtualWorld[ playerid ] );
        SendClientMessage( playerid, -1, "welcome to your last position" );
    }
    return ( 1 );
}
Reply
#2

Try to use this debug, post the result please.

PHP код:
@load_user_positionplayeridname[], value[] )
{
    
INI_Float"PositionX"PosXplayerid ] );
    
INI_Float"PositionY"PosYplayerid ] );
    
INI_Float"PositionZ"PosZplayerid ] );
    
INI_Float"Angle"Angleplayerid ] );
    
INI_Int"Interior"Interiorplayerid ] );
    
INI_Int"VirtualWorld"VirtualWorldplayerid ] );
    
printf(" X; %f | Y;%f | Z;%f"PosXplayerid ], PosYplayerid ], PosZplayerid ])
    return ( 
);

Reply
#3

Mate, i it still doesn't working.
Reply
#4

Show us the result, there should be a line in the samp-server.exe
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)