The online racing simulator
Detect AI
(21 posts, started )
Detect AI
Hi!
Can you give me a code for detect AI in C# .NET?
I can't found code for this.
Jesus have given us a BRAIN!

just search a bit in the libary u will find it very fast ...

and look into the insim.txt in your lfs folder

Greez Heiko
I don't know C# .NET, but
if(NPL.PType & 2)

wherever you catch NPLs should do.
here it is:

[COLOR=SeaGreen] // A player joins the race. If PLID already exists, then player leaves pit.[/COLOR]
[COLOR=Blue]private void[/COLOR] NPL_PlayerJoinsRace(Packets.IS_NPL NPL)
{
[COLOR=Blue] bool[/COLOR] LeavesPits = AddToPlayersList(NPL); [COLOR=SeaGreen]// Update Players[] list[/COLOR]
[COLOR=Blue]if [/COLOR](NPL.PType.Equals(6))
{
InSim.Send_MST_Message([COLOR=DarkOrange]"/spec "[/COLOR] + NPL.PName);
InSim.Send_MTC_MessageToConnection([COLOR=DarkOrange]"^3#^1 It isnt allowed to add AI drivers"[/COLOR], NPL.UCID, NPL.PLID);
}
[COLOR=SeaGreen] // Your code here[/COLOR]
}

Quote from Heiko1 :here it is:

That's wrong, it will only work on AIs from a remote connection (= a client).
On another note, I'm pretty sure I haven't got my brain from Jesus.
it still works

but what you mean from remote connection?
a dedi host cant add AI driver (not that i know)
Quote from Heiko1 :at me the code works for male AND female driver

Yes I edited that, mixed the PType bits up, but it still only works on remote AIs and the OP asked for a way to detect AIs.
Your solution is sufficient to prevent people from adding AIs though.

€: LOL at our cross-editing
set the cars per player value to 1 ?
Quote from Marco1 :set the cars per player value to 1 ?

You could still add 1 AI if you're spectating.
hä?

how that he means that...?

only to detect an AI? and DONT spec it?
or what he/you mean?
Quote from morpha :You could still add 1 AI if you're spectating.

and then use the code from Heiko1 to spec it xD
Quote from Heiko1 :hä?

how that he means that...?

only to detect an AI? and DONT spec it?
or what he/you mean?

I'm saying your code does not reliably detect whether a player is an AI or not.
It's actually suprising that you say it works on both male and female AIs because it really should not work on females and/or local AIs.
byte PType; // bit 0 : female / bit 1 : AI / bit 2 : remote
  • PType = 1|2|4 // = 7, female remote AI and your code should fail to detect that.
  • PType = 2|4 // = 6, male remote AI, your code works.
  • PType = 1|2 // = 3, female local AI, your code shouldn't work
  • PType = 2 // local AI, your code should fail.
€: As I thought, your code fails on everything but male remote AIs.
So it should be working now what your said:


[COLOR=SeaGreen] // A player joins the race. If PLID already exists, then player leaves pit.[/COLOR]
[COLOR=Blue]private void[/COLOR] NPL_PlayerJoinsRace(Packets.IS_NPL NPL)
{
[COLOR=Blue] bool[/COLOR] LeavesPits = AddToPlayersList(NPL); [COLOR=SeaGreen]// Update Players[] list[/COLOR]
[COLOR=Blue]if [/COLOR]((NPL.PType.Equals(2)) || (NPL.PType.Equals(3)) || (NPL.PType.Equals(6)) || (NPL.PType.Equals(7)))
{
InSim.Send_MST_Message([COLOR=DarkOrange]"/spec "[/COLOR] + NPL.PName);
InSim.Send_MTC_MessageToConnection([COLOR=DarkOrange]"^3#^1 It isnt allowed to add AI drivers"[/COLOR], NPL.UCID, NPL.PLID);
}
[COLOR=SeaGreen] // Your code here[/COLOR]
}

Thanks all for reply. I don't have docs folder in my LFS directory but now I downloaded a fresh LFS "install" and it is there! Sorry for problem.
no problem
where here to help
Quote from Heiko1 :So it should be working now what your said:

No that will spec everyone,
if (NPL.PType & 2)

morpha, Cannot implicitly convert type 'int' to 'bool'
Quote from misiek08 :morpha, Cannot implicitly convert type 'int' to 'bool'

Try
if(NPL.PType & 2 > 0)

or find someone who actually likes and knows C#.
usde the first one it works 100% @ me ...
I did:
if (Convert.ToBoolean(NPL.PType & 2))

It works! Thx for all!
Quote from morpha :Try
if(NPL.PType & 2 > 0)

or find someone who actually likes and knows C#.

if ((npl.PType & 2) == 2)
{
// Pass
}


Detect AI
(21 posts, started )
FGED GREDG RDFGDR GSFDG