The online racing simulator
Spanish Cruise AntiRadar Problem
Hi!, I´m finishing a Cruise, and I have a little problem with the part of the code which Radar detects the police.

Basicaly, the Radar-Detector only must appears when someone buy it, and of course it works... but, when some one buy the Radar-Detector, everyone has the Radar-Detector in his screen, although you haven't buy it.

I need some help to finish it, and finally release it in the LFS.

Thanks... and waiting your help.
#2 - amp88
Quote from LFS/docs/InSim.txt :struct IS_BFN // Button FunctioN - delete buttons / receive button requests
{
byte Size; // 8
byte Type; // ISP_BFN
byte ReqI; // 0
byte SubT; // subtype, from BFN_ enumeration (see below)

byte UCID; // connection to send to or from (0 = local / 255 = all)
byte ClickID; // ID of button to delete (if SubT is BFN_DEL_BTN)
byte Inst; // used internally by InSim
byte Sp3;
};

It sounds like the UCID field in the button request is set to the wrong value. It should be only to the connection of the person who has bought the radar detector, not to everyone.
This is my code... something is wrong and I don't know what...

Quote :
foreach (clsConnection C in Connections)
{

if (TrapDistance <= 200) //"^7••• ^2••• ^3••• ^1•••"
{
if (TrapDistance > 150 && C.Cars.Contains("RADAR")){
InSim.Send_BTN_CreateButton("^7 ••• ••• ^2••• SEGURO ••• ^7••• ••• ", Flags.ButtonStyles.ISB_LEFT | Flags.ButtonStyles.ISB_DARK, 5, 45, 26, 78, 231, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[Speeder].PLID)].UniqueID)].UniqueID, 40, false);
//InSim.Send_BFN_DeleteButton(0, 231, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID);
}
if (TrapDistance <= 150)
{
if (TrapDistance > 100 && C.Cars.Contains("RADAR")){
InSim.Send_BTN_CreateButton("^7 ••• ^3••• ••• CUIDADO ••• ••• ^7••• ", Flags.ButtonStyles.ISB_LEFT | Flags.ButtonStyles.ISB_DARK, 5, 45, 26, 78, 231, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[Speeder].PLID)].UniqueID)].UniqueID, 40, false);
//InSim.Send_BFN_DeleteButton(0, 231, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID);

}
else if (C.Cars.Contains("RADAR")){
InSim.Send_BTN_CreateButton("^1 ••• ••• ••• DESPACIO ••• ••• •••", Flags.ButtonStyles.ISB_LEFT | Flags.ButtonStyles.ISB_DARK, 5, 45, 26, 78, 231, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[Speeder].PLID)].UniqueID)].UniqueID, 40, false);
InSim.Send_BFN_DeleteButton(0, 231, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID);
}
if (TrapDistance <= 50)
{
if (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[Speeder].PLID)].UniqueID)].InTrap == 0 && Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[Speeder].PLID)].UniqueID)].IsOfficerORCadet == 0 && Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[Speeder].PLID)].UniqueID)].IsBeingChased == 0)
{
if (Convert.ToInt32((MCI.Info[Speeder].Speed * (100f / 32768f)) * 3.6f) > Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].TrapSpeed)
{
int multa = 50 + (Convert.ToInt32((MCI.Info[Speeder].Speed * (100f / 32768f)) * 3.6f) - Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].TrapSpeed) * 10;
InSim.Send_MST_Message("/msg ^6|^7 EXCESO DE VELOCIDAD: " + Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[Speeder].PLID)].UniqueID)].Username);
InSim.Send_MST_Message("/msg ^6|^7 " + Convert.ToInt32((MCI.Info[Speeder].Speed * (100f / 32768f)) * 3.6f) + "km/h (" + Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[Speeder].PLID)].UniqueID)].CurrentCar + ")");
InSim.Send_MST_Message("/msg ^6|^7 RADAR: " + Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].PlayerName);
InSim.Send_MST_Message("/msg ^6|^7 MULTA: ^1€" + multa);
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[Speeder].PLID)].UniqueID)].Cash -= multa;
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].Cash += multa;
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[Speeder].PLID)].UniqueID)].InTrap = 1;
}
}
}
else
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[Speeder].PLID)].UniqueID)].InTrap = 0;
}
}

else if (C.Cars.Contains("RADAR")){
InSim.Send_BTN_CreateButton("^7 ••• ••• ••• DESPEJADO ••• ••• ••• ", Flags.ButtonStyles.ISB_LEFT | Flags.ButtonStyles.ISB_DARK, 5, 45, 26, 78, 231, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[Speeder].PLID)].UniqueID)].UniqueID, 40, false);
//InSim.Send_BFN_DeleteButton(0, 231, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID);
}

if (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].EstadoRadar == 0 && C.Cars.Contains("RADAR")){
InSim.Send_BTN_CreateButton("^7 ••• ••• ••• DESPEJADO ••• ••• ••• ", Flags.ButtonStyles.ISB_LEFT | Flags.ButtonStyles.ISB_DARK, 5, 45, 26, 78, 231, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[Speeder].PLID)].UniqueID)].UniqueID, 40, false);
InSim.Send_BFN_DeleteButton(0, 231, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID);
}


}

I have a new question...

When I create a new button....

InSim.Send_BTN_CreateButton("^7Hoy: ^2€^7 " + (C.Cash - C.InitialCash), Flags.ButtonStyles.ISB_DARK, 5, 25, 6, 90, 139, C.UniqueID, 2, false);

Every field means....

"****" --> What I want to visualize on my screen.
5 ---> High of the button
25 ---> Width of the button
6 ---> Coordinate X
90 ---> Coordinate Y
139 --->Number of instance
C.UniqueID ---> Everyone who displays the button
2 ---> ????????? What means this?
false ---> ??????? What means this Bool?

Thanks...
Quote from Dalmako :I have a new question...

When I create a new button....

InSim.Send_BTN_CreateButton("^7Hoy: ^2€^7 " + (C.Cash - C.InitialCash), Flags.ButtonStyles.ISB_DARK, 5, 25, 6, 90, 139, C.UniqueID, 2, false);

Every field means....

"****" --> What I want to visualize on my screen.
5 ---> High of the button
25 ---> Width of the button
6 ---> Coordinate X
90 ---> Coordinate Y
139 --->Number of instance
C.UniqueID ---> Everyone who displays the button
2 ---> ????????? What means this?
false ---> ??????? What means this Bool?

Thanks...

2 - Request ID.
false - Wether the button should stay on the screen when the user is in the pits or not. true - Button will still stay on the screen if the user is in the setup screen/chosing cars. false - It will disappear(hide) on these places.

About request id there's some information:
Quote from dougie-lampkin :[...] RequestID is sent in IS_BTC. It's usually used if you have two buttons with the same ClickID that are sent in different "areas" (so they don't show at the same time, because they can't), so that when the BTC is sent, you can see which "area" it was sent from. That's a terrible explaination I know, but I'm terrible at explaining things in general

For example, if you have a menu system, with different tabs. Each tab has 5 buttons, each with the same ClickID. But they all have different RequestIDs. So when one button is clicked, you can look at the RequestID in IS_BTC and see which tab is was sent from, to decide what to do with it. Any better? [...]


FGED GREDG RDFGDR GSFDG