Timer For Autosave Problem
#1

I have a timer that will save the players stats every few minutes but it will not work.

pawn Код:
forward AutoSave();
When the player logs in...
pawn Код:
SetTimer("AutoSave",10000,true);
pawn Код:
public AutoSave()
{
    if(Logged[playerid] == 1)
      {
    Money[playerid] = GetPlayerMoney(playerid);
        TruckerSkin[playerid] = GetPlayerSkin(playerid);
    TruckType[playerid] = dini_Int(udb_encode(PlayerName), "TruckType");
    JobsDone[playerid] = dini_Int(udb_encode(PlayerName), "JobsDone");
        JobLevel[playerid] = dini_Int(udb_encode(PlayerName), "JobLevel");
       
    dini_IntSet(udb_encode(PlayerName), "Money", Money[playerid]);
    dini_IntSet(udb_encode(PlayerName), "TruckType", TruckType[playerid]);
    dini_IntSet(udb_encode(PlayerName), "JobsDone", JobsDone[playerid]);
    dini_IntSet(udb_encode(PlayerName), "JobLevel", JobLevel[playerid]);
    dini_IntSet(udb_encode(PlayerName), "Skin", TruckerSkin[playerid]);
    SendClientMessage(playerid, COLOUR_YELLOW, "[SERVER] All Registered Accounts Have Been Auto Saved.");
      }
}


Код:
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Trucking2.pwn(352) : error 017: undefined symbol "playerid"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Trucking2.pwn(354) : error 017: undefined symbol "playerid"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Trucking2.pwn(355) : error 017: undefined symbol "playerid"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Trucking2.pwn(356) : error 017: undefined symbol "playerid"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Trucking2.pwn(357) : error 017: undefined symbol "playerid"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Trucking2.pwn(358) : error 017: undefined symbol "playerid"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Trucking2.pwn(360) : error 017: undefined symbol "playerid"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Trucking2.pwn(361) : error 017: undefined symbol "playerid"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Trucking2.pwn(362) : error 017: undefined symbol "playerid"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Trucking2.pwn(363) : error 017: undefined symbol "playerid"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Trucking2.pwn(364) : error 017: undefined symbol "playerid"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Trucking2.pwn(365) : error 017: undefined symbol "playerid"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Trucking2.pwn(369) : warning 203: symbol is never used: "Destination"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Trucking2.pwn(369) : warning 203: symbol is never used: "PosDests"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


12 Errors.
Reply
#2

Autosave()
...
It doesn't have anything with playerid.
Reply
#3

Try this..

Код:
public AutoSave()
{
  for(new i;i<MAX_PLAYERS;i++)
  {
	if(Logged[i] == 1)
	{
       GetPlayerName(i,PlayerName);
  	   Money[i] = GetPlayerMoney(playerid);
 	   TruckerSkin[i] = GetPlayerSkin(playerid);
  	   TruckType[i] = dini_Int(udb_encode(PlayerName), "TruckType");
  	   JobsDone[i] = dini_Int(udb_encode(PlayerName), "JobsDone");
 	   JobLevel[i] = dini_Int(udb_encode(PlayerName), "JobLevel");
        
       dini_IntSet(udb_encode(PlayerName), "Money", Money[i]);
       dini_IntSet(udb_encode(PlayerName), "TruckType", TruckType[i]);
       dini_IntSet(udb_encode(PlayerName), "JobsDone", JobsDone[i]);
       dini_IntSet(udb_encode(PlayerName), "JobLevel", JobLevel[i]);
       dini_IntSet(udb_encode(PlayerName), "Skin", TruckerSkin[i]);
	  }
    }
    SendClientMessage(playerid, COLOUR_YELLOW, "[SERVER] All Registered Accounts Have Been Auto Saved.");
}
Reply
#4

Код:
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Trucking2.pwn(350) : error 025: function heading differs from prototype
After trying phoenix0120 method
Reply
#5

Quote:
Originally Posted by phoenix0120
Try this..

Код:
public AutoSave()
{
  for(new i;i<MAX_PLAYERS;i++)
  {
	if(Logged[i] == 1)
	{
       GetPlayerName(i,PlayerName);
  	   Money[i] = GetPlayerMoney(playerid);
 	   TruckerSkin[i] = GetPlayerSkin(playerid);
  	   TruckType[i] = dini_Int(udb_encode(PlayerName), "TruckType");
  	   JobsDone[i] = dini_Int(udb_encode(PlayerName), "JobsDone");
 	   JobLevel[i] = dini_Int(udb_encode(PlayerName), "JobLevel");
        
       dini_IntSet(udb_encode(PlayerName), "Money", Money[i]);
       dini_IntSet(udb_encode(PlayerName), "TruckType", TruckType[i]);
       dini_IntSet(udb_encode(PlayerName), "JobsDone", JobsDone[i]);
       dini_IntSet(udb_encode(PlayerName), "JobLevel", JobLevel[i]);
       dini_IntSet(udb_encode(PlayerName), "Skin", TruckerSkin[i]);
	  }
    }
    SendClientMessage(playerid, COLOUR_YELLOW, "[SERVER] All Registered Accounts Have Been Auto Saved.");
}
Your code has a mixture of playerid and i. Just use this code:

pawn Код:
public AutoSave()
{
  for(new playerid;playerid<MAX_PLAYERS;playerid++)
  {
        if(IsPlayerConnected(playerid))
        {
            if(Logged[playerid] == 1)
            {
            Money[playerid] = GetPlayerMoney(playerid);
                TruckerSkin[playerid] = GetPlayerSkin(playerid);
            TruckType[playerid] = dini_Int(udb_encode(PlayerName), "TruckType");
            JobsDone[playerid] = dini_Int(udb_encode(PlayerName), "JobsDone");
                JobLevel[playerid] = dini_Int(udb_encode(PlayerName), "JobLevel");

            dini_IntSet(udb_encode(PlayerName), "Money", Money[playerid]);
            dini_IntSet(udb_encode(PlayerName), "TruckType", TruckType[playerid]);
            dini_IntSet(udb_encode(PlayerName), "JobsDone", JobsDone[playerid]);
            dini_IntSet(udb_encode(PlayerName), "JobLevel", JobLevel[playerid]);
            dini_IntSet(udb_encode(PlayerName), "Skin", TruckerSkin[playerid]);
            SendClientMessage(playerid, COLOUR_YELLOW, "[SERVER] All Registered Accounts Have Been Auto Saved.");
            }
        }
    }
}
This way you don't have to change everything to i.
Reply
#6

Код:
forward AutoSave(playerid);
add Playerid To you Forward And that should Fix The Errors
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)