The online racing simulator
Connection Time Problem
Hello. I record the distances traveled by the players on the server, and when they leave the server, I wanted it to be sent to the discord channel as a log. But it didn't work. This code works in the onleaverace function but not in the ondisconnect section.

When I tried it in Lapper, I got an error like this. What should I do in this situation.


5/8/2024 3:23:52 PM -> Syntax error: in file ".\default\LFSLapper.lpr" at line #1099
You can't use GetCurrentPlayerVar in this context, not a player event
Function 'ondisconnect' script aborted


CatchEvent OnDisConnect( $userName, $reason ) # Player event

$Message = " " .$userName. " ** Sunucudan ayrılmadan önce ki bağlantı süresi >> ** (". GetCurrentPlayerVar("ConnectedTime")." )"; $DiscordChannel = "1237545908024119297"; sendmessagetodiscord($DiscordChannel,$Message);

EndCatchEvent

Finally. I tried to send users their times in a txt file, but I failed. Is it possible to send this on discord?
(".GetPlayerVar( $username,"ConnectedTime")." )

I tried something like this. I receive messages on Discord, but it does not show my connection time.
** Best answer **
Replace $username with $userName.
Thanks, I missed that.
Finally, how can I send the connection times of the usernames in the txt file to Discord when they leave the server? I tried several ways but failed. Is this possible?
I've seen this. What I want to do is to transfer the connection times of the players in the txt file to Discord.

Here's the example.
$Message = " " .$userName. " ** Sunucudan ayrılmadan önce ki bağlantı süresi >> ** (". GetCurrentPlayerVar("ConnectedTime")." )"; $DiscordChannel = "1237545908024119297"; sendmessagetodiscord($DiscordChannel,$Message);

This code is simple right now, but I don't know where to start.

But no matter what method I tried, it didn't work. Either all players receive messages or none at all.
This thread is closed

FGED GREDG RDFGDR GSFDG