The online racing simulator
C# LFS_External Function
(5 posts, started )
C# LFS_External Function
I want to make a function that will combine these 2 things.

1.Connections[GetConnIdx(MSO.UCID)].IsAdmin
which means Admin with server password

and this

2.Connections[GetConnIdx(MSO.UCID)].CanBeAdmin
which means Admin based on admins.txt file.

How can i do something like IsPlayerAdmin(Connections[GetConnIdx(MSO.UCID)])
which will have

Connections[GetConnIdx(MSO.UCID)].IsAdmin == 1 || Connections[GetConnIdx(MSO.UCID)].CanBeAdmin == 1

I am new to C#, so i dont know how to make it. Could you give me an example please?
Logically it looks okay, but I'm not sure C# will let you test a boolean against an integer like that. You could try
== true // or false

instead of
== 1

-
(MariusMM) DELETED by MariusMM
Quote from MariusMM :I might of misunderstood the question but something like this maybe;

I do not want to use every time in my code
if(Connections[GetConnIdx(MSO.UCID)].IsAdmin == 1 || Connections[GetConnIdx(MSO.UCID)].CanBeAdmin == 1)

I want to type this instead

if(IsPlayerAdmin(Connections[GetConnIdx(MSO.UCID)] == 1)

But how can i make this? ^^
Just to have smaller code.
-
(MariusMM) DELETED by MariusMM
Thanks, nice idea. This will work too
After 1 month of learning C# and Insim usage i managed to do it myself Here it is what i wanted to do


private bool IsConnectionAdmin(clsConnection ID)
{
if (ID.CanBeAdmin == 1 || ID.IsAdmin == 1) return true;
return false;
}

Usage,

if (IsConnectionAdmin(Connections[GetConnIdx(MSO.UCID)]))
{
//the rest of the code


C# LFS_External Function
(5 posts, started )
FGED GREDG RDFGDR GSFDG