ItsMods

Full Version: Visit Plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I don't know if anyone has made this, anyway. Big Grin

[attachment=2715]

[attachment=2714]

CSHARP Code
  1. using System.Text;
  2. using Addon;
  3. using System.IO;
  4.  
  5. namespace visitplug
  6. {
  7. public class visitplug : CPlugin
  8. {
  9. public override void OnServerLoad()
  10. {
  11. try
  12. {
  13. Directory.CreateDirectory(@"Visits");
  14. ServerPrint("Visit Plugin V1.0 Loaded -- SShattered");
  15. }
  16. catch (Exception ex)
  17. {
  18. ServerPrint("Visit Plugin V1.0 Loaded -- SShattered");
  19. }
  20. }
  21.  
  22. public override void OnPlayerConnect(ServerClient Client)
  23. {
  24. if (File.Exists(@"Visits\" + Client.XUID + ".txt"))
  25. {
  26. string counts = File.ReadAllText(@"Visits\" + Client.XUID + ".txt");
  27. double count = Convert.ToDouble(counts);
  28. double newcc = count + 1;
  29. string newcount = Convert.ToString(newcc);
  30. File.WriteAllText(@"Visits\" + Client.XUID + ".txt", newcount);
  31. ServerSay("Welcome Player ^2" + Client.Name + " ^7to the Server", true);
  32. ServerSay("He has played ^1" + counts + " ^7times", true);
  33. }
  34. else
  35. {
  36. File.WriteAllText(@"Visits\" + Client.XUID + ".txt", "1");
  37. ServerSay("Welcome Player ^2" + Client.Name + " ^7to the Server", true);
  38. }
  39. }
  40. }
  41. }
So wait you write a new text file for each new player that joins?
Why are you converting it to double?

Thanks Barata...
Wow, that's can cause a server crash..Making file is bad, use mysql.
Ummm.... After all its a fail Confused
@barata
Then how could i plus strings? I tried it before, but it out put 1+1=11
Any other way? Im just a beginner.

@sailormoon
Dont know about handling dbs yet

Sent from my E16i using Tapatalk 2
(07-26-2013, 16:38)Bandarigoda123 Wrote: [ -> ]Ummm.... After all its a fail Confused
@barata
Then how could i plus strings? I tried it before, but it out put 1+1=11
Any other way? Im just a beginner.

You could use an integer directly, not a problem tough.

Thanks Barata...