PDA

View Full Version : Save in cruise tutorial


Kordan59
7th May 2008, 22:01
Hello

Could you help me for insim save all acount in real time

because if my insim crash my player lost all cash and car
for save him disconect and come bacj

Me want if possible insim save after 5min

Look :

Player come on server at 00:00:00
him drive drive drive ...
and at 00:05:00 all player is saved
and drive drive drive
and at 00:10:00 all player is saved

Thx

mcgas001
7th May 2008, 22:04
http://www.lfsforum.net/showthread.php?p=736783#post736783

Kordan59
7th May 2008, 22:37
Its corect ?
// Form load
private void Form1_Load(object sender, EventArgs e)
{
try
{
PayUser.Enabled = true;
PayUser.Elapsed += new System.Timers.ElapsedEventHandler(PayUser_Elapsed) ;
if (System.IO.Directory.Exists(UserInfo) == false) System.IO.Directory.CreateDirectory(UserInfo);
// Connect to InSim
cfg = new ConnectionSettings("127.0.0.1", 29999, 0, Flags.InSimFlags.ISF_MCI, '!', 1000, "*****", "^3French Cruise");
InSim = new InSimInterface(cfg);
InSim.Connect();BackUp.Enabled = true;
BackUp.Elapsed += new System.Timers.ElapsedEventHandler(BackUp_Elapsed);

But where add that ?
System.Timers.Timer BackUp = new System.Timers.Timer(300000);

void BackUp_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
foreach (clsConnection C in Connections)
FileInfo.UpdateUserLeave(C.Username, C.Cash, C.Cars);
}

Robbo01
7th May 2008, 22:45
Its corect ?
// Form load
private void Form1_Load(object sender, EventArgs e)
{
try
{
PayUser.Enabled = true;
PayUser.Elapsed += new System.Timers.ElapsedEventHandler(PayUser_Elapsed) ;
if (System.IO.Directory.Exists(UserInfo) == false) System.IO.Directory.CreateDirectory(UserInfo);
// Connect to InSim
cfg = new ConnectionSettings("127.0.0.1", 29999, 0, Flags.InSimFlags.ISF_MCI, '!', 1000, "*****", "^3French Cruise");
InSim = new InSimInterface(cfg);
InSim.Connect();BackUp.Enabled = true;
BackUp.Elapsed += new System.Timers.ElapsedEventHandler(BackUp_Elapsed); But where add that ?
System.Timers.Timer BackUp = new System.Timers.Timer(300000);

void BackUp_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
foreach (clsConnection C in Connections)
FileInfo.UpdateUserLeave(C.Username, C.Cash, C.Cars);
}


just put it anywhere but not in a method like at the bottom of the code..

Kordan59
7th May 2008, 22:51
ok thx

Kordan59
7th May 2008, 22:55
if i add after that its ok ?
private void MCI(Packets.IS_MCI MCI)
{
for (int i = 0; i < Players.Count; i++)
{
decimal Speed = (decimal)((MCI.Info[i].Speed * (100f / 32768f)) * 3.6f);
decimal ConvSpeed = (decimal)(Speed * 25 / 1000);
Players[GetPlyIdx(MCI.Info[i].PLID)].Payout += ConvSpeed;
}
}
}
}

Why acount of player reset at 0cash 0 car

dougie-lampkin
8th May 2008, 01:04
Put it just before any of the "private void" things. They are the start of a method. You must put it outside a method...

Kordan59
8th May 2008, 07:14
sorry i dont have understand all i am french :p

here ?
// Form load

System.Timers.Timer BackUp = new System.Timers.Timer(1);

void BackUp_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
foreach (clsConnection C in Connections)
FileInfo.UpdateUserLeave(C.Username, C.Cash, C.Cars);
}

Robbo01
8th May 2008, 16:10
private void MCI(Packets.IS_MCI MCI)
{
for (int i = 0; i < Players.Count; i++)
{
decimal Speed = (decimal)((MCI.Info[i].Speed * (100f / 32768f)) * 3.6f);
decimal ConvSpeed = (decimal)(Speed * 25 / 1000);
Players[GetPlyIdx(MCI.Info[i].PLID)].Payout += ConvSpeed;
}
}
System.Timers.Timer BackUp = new System.Timers.Timer(300000);

void BackUp_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
foreach (clsConnection C in Connections)
FileInfo.UpdateUserLeave(C.Username, C.Cash, C.Cars);
}
}
}

like that i think that might work