Help save timer
#1

Hello, so I set a timer for autosave in "OnGameModeInit"


}

pawn Код:
SetTimer("AutoSave",98000,1); // ******
    UsePlayerPedAnims();
    SetWeather(9);
    EnableStuntBonusForAll(0);
    return 1;

public AutoSave()
{
    SendClientMessageToAll(playerid, COL_WHITE, "WARNING: Saving player accounts...");
    GetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
    GetPlayerFacingAngle( playerid, Angle[ playerid ] );
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Score",PlayerInfo[playerid][pScore]);
    INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
    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;
}
I'm getting the error:
Код:
error 017: undefined symbol "playerid"
I understand why it's saying this, but IDK how to correct it, please help.
Reply
#2

PHP код:
SendClientMessageToAll(-1COL_WHITE"WARNING: Saving player accounts..."); 
Reply
#3

Quote:
Originally Posted by McBan
Посмотреть сообщение
PHP код:
SendClientMessageToAll(-1COL_WHITE"WARNING: Saving player accounts..."); 
Thank you very much, if I could rep I would.


Now I'm getting this error though, the format seems perfectly fine, idk why it is saying that. If you could help I would be very appreciative.
Код:
(168) : error 001: expected token: ",", but found ";"
pawn Код:
INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(player); // This line
    INI_WriteInt(File,"Admin",PlayerInfo[player][pAdmin]);
Reply
#4

Replace player with playerid.
Reply
#5

Quote:
Originally Posted by McBan
Посмотреть сообщение
PHP код:
SendClientMessageToAll(-1COL_WHITE"WARNING: Saving player accounts..."); 
Quote:
Originally Posted by McBan
Посмотреть сообщение
Replace player with playerid.
Once I do that the error stays there but I get the error that I got in my first problem.
Reply
#6

pawn Код:
public AutoSave()
{
    foreach(new i : Player)
    {
        SendClientMessageToAll(COL_WHITE, "WARNING: Saving player accounts...");
        GetPlayerPos( i, PosX[ i ], PosY[ i ], PosZ[ i ] );
        GetPlayerFacingAngle( i, Angle[ i ] );
        new INI:File = INI_Open(UserPath(i));
        INI_SetTag(File,"data");
        INI_WriteInt(File,"Cash",GetPlayerMoney(i));
        INI_WriteInt(File,"Admin",PlayerInfo[i][pAdmin]);
        INI_WriteInt(File,"Score",PlayerInfo[i][pScore]);
        INI_WriteInt(File,"Skin",GetPlayerSkin(i));
        INI_WriteFloat( File, "PositionX", PosX[i] );
        INI_WriteFloat( File, "PositionY", PosY[i] );
        INI_WriteFloat( File, "PositionZ", PosZ[i] );
        INI_WriteFloat( File, "Angle", Angle[ i ] );
        INI_WriteInt( File, "Interior", GetPlayerInterior( i ) );
        INI_WriteInt( File, "VirtualWorld", GetPlayerVirtualWorld( i ) );
        INI_Close(File);
    }
    return 1;
}
You must have the foreach.inc
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)