The online racing simulator
#1 - heawy
[SOLVED]InSim dont save status.
Hi.
Im looking for help in code.

I want to add the rank "supporter" (works but not how I want). Problem is with saving rank in .txt file. Command add rank to player but when play leave host this back to Supporter = 0

command:
[Command("addsupp", "addsupp <username>")]
public void addsupp(string Msg, string[] StrMsg, Packets.IS_MSO MSO)
{
clsConnection Conn = Connections[GetConnIdx(MSO.UCID)];

if (StrMsg.Length > 1)
{
if (Conn.IsAdmin == 1 || Conn.IsSuperAdmin == 1 || Conn.IsModerator == 1)
{
foreach (clsConnection l in Connections)
{
if (l.Username == StrMsg[1] && StrMsg[1].Length > 1)
{
MsgAll("^6»^7 " + l.PlayerName + " ^7Added as ^6Supporter");
MsgAll("^6»^7 By: " + Conn.PlayerName);
l.IsSupporter = 1;
}
}
}
}
else
{
InSim.Send_MTC_MessageToConnection("^7Invalid command or Not autorized!", MSO.UCID, 0);
}

}

When it did not work i just copy all from Moderator rank, because Mod works and its sam thing but still nothing.

It is in NewConn section and in FileInfo same like Moderator rank but still same problem.
No idea what i do wrong when there is no difference between ranks.

Other:
public byte IsSupporter;

NewCruiser:
Sr.WriteLine("Support = 0");

SaveUser:
Sw.WriteLine("Support = " + C.IsSupporter);

SaveOffline
Sw.WriteLine("Support = " + IsSupporter);

public static byte IsSupporter(string Username)
{
StreamReader Sr = new StreamReader(Database + "\\" + Username + ".txt");

string line = null;
while ((line = Sr.ReadLine()) != null)
{
if (line.Substring(0, 6) == "Support")
{
string[] Msg = line.Split('=');
Sr.Close();
return byte.Parse(Msg[1].Trim());
}
}
Sr.Close();
return 0;
}

Any ideas?
-
(kagus) DELETED by kagus : ..
#2 - heawy
I already have this, forget to show


NewConn.IsSupporter = FileInfo.IsSupporter(NCN.UName);

You don't show the actual saving/storing bit, you use

Sr.writeline for support=0 and Sw.writeline for the other two options. Maybe something wrong with Sw?
#4 - heawy
I have no idea, every other options works good except this so i make fail somewhere.

Here code from FileInfo.cs u will see for member, cadet, officer is same thing.
http://pastebin.com/wbRyJPnH

Need to show something more?
No.. This doesn't look wrong to me. It almost looks like the new compile fails and you use an old executable as a result.

What I always do when I get these kind of problems is generating a print/echo message to the screen somewhere in the function so I am sure I run the latest code and that the function is being activated to begin with.
#6 - heawy
Im really begginer so i dont understand
if (line.Substring(0, 6) == "Support")

"Support" is 7 characters, not 6.
#8 - heawy
AAAAAAAAAAaaaaaaaahahhahaa i dont belive, missed little thing, IT WORKS
Thanks guys really
-
(kagus) DELETED by kagus : kkk

FGED GREDG RDFGDR GSFDG