The online racing simulator
MSG on connect (all connections)
I am codig an aplication, I want when an user connects, the insim write a message using the /msg command to all conections, How I do it?
ISP_CNN

thats the new connection packet (I think).

whenever that packet is received, send a MST with the data "/msg $username has connected."
Thanks for the answer, but i dind't know to use that, can you explain me how to use that, please?

Thanks in advance
Quote from revolucio :Thanks for the answer, but i dind't know to use that, can you explain me how to use that, please?

I guess we need a bit more info on how you are writing this app. What language are you writing it in, are you using any kind of insim library?

Also, the connection packet you are looking for is IS_NCN. Your insim application connected to a server will receive this when a new user connects to the server (not joins the game, btw).

Right now, there is a message the server sends to all connections notifying them that user 'x' connected. You want to send more information of that kind to everyone?
the app that I am doing is with C# language.

I dind't want to send more information of that.

Thanks in advance
There are plenty of examples of C# apps already around. Check out the LFSLib.NET posts as sdether has already posted a bunch of example applications.

Quote from revolucio :the app that I am doing is with C# language.

I dind't want to send more information of that.

Thanks in advance

Here is an app, its based off of a different insim app I made. It's python, and has a few bugs, so just ignore the console output.


from socket import *
import struct
import string
import threading
import time
import math
import winsound
import random
import array

global s
global data
global msgs
msgs = []
global conntry
conntry = 0
s = socket()
insim_admin = ""
insim_ip = "127.0.0.1"
insim_port = 7776
insim_name = "MsgApp"

class InSimRecv(threading.Thread):

def kill(self):
self.killed = True

def run(self):
while 1:
InSimData = s.recv(4096)
InSimHeader = InSimData[0:3]
if InSimData:
if int(struct.unpack("B", InSimData[1])[0]) == 3:
s.send(struct.pack("BBBB", 4, 3, 0, 0)) #Send ACK
if struct.unpack("B", InSimData[1])[0] == 18:
s.send(struct.pack("BBBBBBBB63sB", 72, 14, 0, 0, int(struct.unpack("B", InSimData[3])[0]), 0, 0, 0, "Welcome to the server, connection #" + str(int(struct.unpack("B", InSimData[3])[0])) + " !", 0))

class keepalive(threading.Thread):
def run(self):
#s.send(struct.pack("BBBB", 4, 3, 0, 0)) #Send ACK
time.sleep(15)

def kill(self):
self.killed = True

class InSimConnect(threading.Thread):
def run(self):
conntry = 0
while conntry < 5:
try:
conntry=conntry+1
print "Connecting to " + insim_ip + " on port " + str(insim_port) + "(" + str(conntry) + "/5)"
s.connect( ("127.0.0.1", 777) )

except:
print "Connection Failed!"
pass

time.sleep(1)

try:
s.send(struct.pack("BBBBhhBsh16s16s", 44, 1, 0, 0, 0, 32, 0, "!", 10, insim_admin, insim_name))
s.send(data)

time.sleep(1)

InSimRecv().start()
InSimMsgRotate().start()
keepalive().start()
conntry = 999
s.send(struct.pack("BBBB64s", 68, 13, 0, 0, "/msg ^5wheel4hummer\'s message app started."))

except:
print "Unknown Error"
pass

if conntry < 999:
print "All connection attempts failed!"

InSimConnect().start()


FGED GREDG RDFGDR GSFDG