The online racing simulator
Window won't open
(12 posts, started )
#1 - kdo
Window won't open
Hello, i made an windows who open if player position is at
X-30
or
X-30
and
Y -19
or
Y -21

But the windows won't open!

Here is the code , where is the error ?

if (((MCI.Info[i].X / 196608) >= -31) && ((MCI.Info[i].X / 196608) <= -30) && ((MCI.Info[i].Y / 196608) >= -19) && ((MCI.Info[i].Y / 196608) <= -21) && ((MCI.Info[i].Speed / 147) <= 3))
{
if (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouse == 0 && Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouseOverride == 0)
{
InSim.Send_BTN_CreateButton("^7Stock:", Flags.ButtonStyles.ISB_LEFT | Flags.ButtonStyles.ISB_DARK, 7, 10, 50, 90, 200, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID, 40, true);
InSim.Send_BTN_CreateButton("^7" + Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].OwnedGoods, Flags.ButtonStyles.ISB_C1 | Flags.ButtonStyles.ISB_DARK, 7, 5, 50, 100, 201, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID, 40, true);
InSim.Send_BTN_CreateButton("^2" + Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].BuyingGoods, Flags.ButtonStyles.ISB_C1 | Flags.ButtonStyles.ISB_DARK, 7, 5, 50, 105, 202, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID, 40, true);
InSim.Send_BTN_CreateButton("^7+", Flags.ButtonStyles.ISB_C1 | Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_CLICK, 7, 5, 43, 105, 203, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID, 40, true);
InSim.Send_BTN_CreateButton("^7-", Flags.ButtonStyles.ISB_C1 | Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_CLICK, 7, 5, 57, 105, 204, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID, 40, true);
InSim.Send_BTN_CreateButton("^7Cost: ^1€0", Flags.ButtonStyles.ISB_LEFT | Flags.ButtonStyles.ISB_DARK, 7, 12, 60, 90, 205, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID, 40, true);
InSim.Send_BTN_CreateButton("^2Buy", Flags.ButtonStyles.ISB_LEFT | Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_CLICK, 7, 7, 72, 90, 206, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID, 40, true);
InSim.Send_BTN_CreateButton("^1Exit", Flags.ButtonStyles.ISB_LEFT | Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_CLICK, 7, 7, 79, 90, 207, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID, 40, true);
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouse = 1;
}
}
else
{
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouse = 0;
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouseOverride = 0;
}

I think you got the comparators backwards in this statement
[FONT=monospace]
[/FONT](MCI.Info[i].Y / 196608) >= -19) && ((MCI.Info[i].Y / 196608) <= -21)

You do want those buttons to appear when player is within an area X€<-31;-30> and Y€<-21;-19>, right?
#3 - kdo
I wan't , if the player is at this placement, got a windows with buttons

But nothing appear.
I would
- Fix the comparators
- Check if the X,Y coordinates I use are correct
- Print some chat message when a car enters or leaves the area to make sure the app is actually evaluating the "if" statement (and that it does that correctly)
- Send those buttons to all connections just to be sure a wrong UCID is not used for some reason

Once you get this fixed, you can restore the original behavior.

Also I would modify the "else" scope to something like this

else if ((Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouse == 0) &&
(Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouseOverride == 0))
{
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouse = 0;
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouseOverride = 0;
}

That way you won't be setting these two variables to 0 all the time except when the player is in the warehouse.
#5 - kdo
hello,

i do it

if (((MCI.Info[i].X / 196608) >= -31) && ((MCI.Info[i].X / 196608) <= -30) && ((MCI.Info[i].Y / 196608) >= -19) && ((MCI.Info[i].Y / 196608) <= -21) && ((MCI.Info[i].Speed / 147) <= 3))
{
if (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouse == 0 && Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouseOverride == 0)
{
InSim.Send_MST_Message("/msg ^1hello");
InSim.Send_BTN_CreateButton("^7Stock:", Flags.ButtonStyles.ISB_LEFT | Flags.ButtonStyles.ISB_DARK, 7, 10, 50, 90, 200, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID, 40, true);
InSim.Send_BTN_CreateButton("^7" + Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].OwnedGoods, Flags.ButtonStyles.ISB_C1 | Flags.ButtonStyles.ISB_DARK, 7, 5, 50, 100, 201, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID, 40, true);
InSim.Send_BTN_CreateButton("^2" + Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].BuyingGoods, Flags.ButtonStyles.ISB_C1 | Flags.ButtonStyles.ISB_DARK, 7, 5, 50, 105, 202, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID, 40, true);
InSim.Send_BTN_CreateButton("^7+", Flags.ButtonStyles.ISB_C1 | Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_CLICK, 7, 5, 43, 105, 203, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID, 40, true);
InSim.Send_BTN_CreateButton("^7-", Flags.ButtonStyles.ISB_C1 | Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_CLICK, 7, 5, 57, 105, 204, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID, 40, true);
InSim.Send_BTN_CreateButton("^7Cost: ^1€0", Flags.ButtonStyles.ISB_LEFT | Flags.ButtonStyles.ISB_DARK, 7, 12, 60, 90, 205, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID, 40, true);
InSim.Send_BTN_CreateButton("^2Buy", Flags.ButtonStyles.ISB_LEFT | Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_CLICK, 7, 7, 72, 90, 206, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID, 40, true);
InSim.Send_BTN_CreateButton("^1Exit", Flags.ButtonStyles.ISB_LEFT | Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_CLICK, 7, 7, 79, 90, 207, Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].UniqueID, 40, true);
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouse = 1;
}
}
else if ((Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouse == 0) &&
(Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouseOverride == 0))
{
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouse = 0;
Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouseOverride = 0;
}

i add a message if the player is on the aera, but nothing, the Xs Ys are good...
Does the message get sent if you put it right after the first it?
#7 - kdo
if i good understand what you say, the message is not send :/
I'm sorry, my mistake, what I meant was does this work?

if (((MCI.Info[i].X / 196608) >= -31) && ((MCI.Info[i].X / 196608) <= -30) && ((MCI.Info[i].Y / 196608) <= -19) && ((MCI.Info[i].Y / 196608) >= -21) && ((MCI.Info[i].Speed / 147) <= 3)) {
InSim.Send_MST_Message("/msg ^1hello");
if (Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouse == 0 && Connections[GetConnIdx(Players[GetPlyIdx(MCI.Info[i].PLID)].UniqueID)].IsInWarehouseOverride == 0) {
...

#9 - kdo
nothing work :/
#10 - kdo
anyone ?
Are you sure you fixed the comparators?

if (((MCI.Info[i].X / 196608) >= -31) && ((MCI.Info[i].X / 196608) <= -30) && ((MCI.Info[i].Y / 196608) >= -19) && ((MCI.Info[i].Y / 196608) <= -21) && ((MCI.Info[i].Speed / 147) <= 3))

If I'm reading it right this statement is true if a car is within X from -31 to -30 and _any_ Y except -20.

Are you sure that your app really gets to this whole "is in the warehouse?" block? Perhaps there are some conditions before that are not met or your put it in a wrong place?
#12 - kdo
problem solved, unknow what was the error

Window won't open
(12 posts, started )
FGED GREDG RDFGDR GSFDG