The online racing simulator
Ticket help. Reconnect...
(5 posts, started )
Ticket help. Reconnect...
Hi all!
I have a problem with a ticket:

case "!ticket":
if (Connections[GetConnIdx(MSO.UCID)].InLotto == 1 && Environment.TickCount - Connections[GetConnIdx(MSO.UCID)].LastLotto > 1296000) //3 hours
{
Connections[GetConnIdx(MSO.UCID)].Cash -= 50;
int prize = new Random().Next(0, 2000);
Connections[GetConnIdx(MSO.UCID)].Prize += prize;
Connections[GetConnIdx(MSO.UCID)].Cash += Connections[GetConnIdx(MSO.UCID)].Prize;
InSim.Send_MTC_MessageToConnection("^5>^7You have received ^2€" + Connections[GetConnIdx(MSO.UCID)].Prize + " ^7from Lotto", MSO.UCID, 0);
Connections[GetConnIdx(MSO.UCID)].LastLotto = Environment.TickCount;
}
else if (Environment.TickCount - Connections[GetConnIdx(MSO.UCID)].LastLotto < 1296000)
{
InSim.Send_MTC_MessageToConnection("^6>You have to wait ^73 ^6hours to buy another one!", MSO.UCID, 0);
Connections[GetConnIdx(MSO.UCID)].InLotto = 1;
}
else
{
Connections[GetConnIdx(MSO.UCID)].InLotto = 0;
}
Connections[GetConnIdx(MSO.UCID)].Lotto = 0;
Connections[GetConnIdx(MSO.UCID)].LastLotto = Environment.TickCount;
break;

All is ok, but when I'm Disconnect and Connect I can buy ticket :/
I want to make a 3 hours, with a disconnect and connect work.
Sry for my bad english.
Maybe you delete player info from mod, when he disconnects?
If yes, you should save LastLotto (if you don't save it) info somewhere (e.g. in the same place where is player name, etc) and set the LastLotto when he connects.
#3 - Silox
If a player leaves and connects after a while, he can have another UCID.

You should save the time when someone buys a ticket in a .txt file or in a database or whatever and check that time the next time that player buys a ticket.
You should be using the LFS User name (UName), not anything else.


<?php 
function onTick()
{
    
# Read The Lotto Array & Remove Any Expired Entrys.
    
foreach($lotto as $uname => $timestamp)
    {
        if (
$timestamp 10800)
            unset(
$lotto[$uname]);
    }
}
?>

:/ I don't understand this :/
Plz help.

Ticket help. Reconnect...
(5 posts, started )
FGED GREDG RDFGDR GSFDG