Author Topic: How about... C# ?  (Read 10277 times)

0 Members and 1 Guest are viewing this topic.

Offline LORD KILLA

  • Camper
  • ***
  • Posts: 254
  • Happie
How about... C# ?
« on: May 21, 2010, 03:34:31 am »
Hi all.  ::)
I've been working on a programm, wich allows you 'scripting' your server in C# using the MS Visual C# Express editor. I know, it's windows only so far and it needs .net framework, but I'll start working on a C++ portable version next days (this better then nothing, not?). The programm communicates with the server over local network (remoting also possible... but not recommended).

How it works: Event packs are sent by a small script over local network to the app, wich processes the data and calls the events. The app only sends the server what it has to do, so all the data structures/functions/other stuff is managed by the app, not by the script.

I dont have yet made all Event senders, nor cmd.* functions. So far only the most needed. (comming soon )

You can:
-> Use OOP (classes, structs, etc.)
-> Real C#
-> The server wont go 'boom' at crash, only the app.
-> Compile the app, and disallow others modifing (only give blabla.exe)
-> idk...

You cant:
-> Run this on linux systems (but soon... ;D )

To start you'd have to do:
-> Replace the main code file with Program.cs
-> Install a very small script wich sends events/recives todos
-> Modify the class 'script'
    - in the class 'cmd' are commands listed, wich you may use
    - over the class 'Events' you can apply wich functions should be called when a events pack is recived


I know, you'll say "but it still uses a script!": The script is small. It really doesnt do much. It's also better then having the complete 'script' in scriptcore... not?

Well, a question before I release it: Would you use this ?

« Last Edit: May 22, 2010, 12:53:57 pm by LORD KILLA »

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: How about... C# ?
« Reply #1 on: May 21, 2010, 09:01:45 am »
how stable is it? How big scripts have you tested with it? Why dont you just release it and see how people react?

Offline LORD KILLA

  • Camper
  • ***
  • Posts: 254
  • Happie
Re: How about... C# ?
« Reply #2 on: May 21, 2010, 09:06:42 am »
This C# version will be more stable then the script core of course, but the C++ version will be way more better for sure.

I'd like more people to know if they'd use such a thingy. I also havent done yet all events/commands...

Offline dnmr

  • Camper
  • ***
  • Posts: 315
  • emotionally handicapped
Re: How about... C# ?
« Reply #3 on: May 21, 2010, 09:10:51 am »
examples, darling., We need examples of the code and such

Offline LORD KILLA

  • Camper
  • ***
  • Posts: 254
  • Happie
Re: How about... C# ?
« Reply #4 on: May 21, 2010, 09:15:16 am »
The class 'Accounts' doesnt belong to the app, its for my zombie serv...

Code: [Select]
        public static void OnPlayerKill(object[] args)
        {
            Networks.SmartRefresh();
            int shooter = (int)args[0];
            int victim = (int)args[1];
            IsBot(shooter);
            if (victim != shooter)
            {
                Zombies.Type Zombie = Zombies.ZombieTypeByName(Networks.stats.PlayerName[shooter]);
                if (Zombie != Zombies.Type.None)
                {
                    Accounts.Upgrade(shooter, Zombie);
                    if (Accounts.acc[shooter].exp >= Accounts.acc[shooter].maxexp)
                    {
                        Thread.Sleep(400);
                        cmd.DrawText(shooter,
                            "New level: " + Convert.ToString(Accounts.LevelUp(shooter)),
                            360, 1.2, 30, 200, 200, 200, 128);
                    }
                }
            }
        }

DarkCrusade

  • Guest
Re: How about... C# ?
« Reply #5 on: May 21, 2010, 01:29:29 pm »
Looks fine, I'd use it. Keep on it man

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: How about... C# ?
« Reply #6 on: May 21, 2010, 03:32:32 pm »
This ain't gonna work.
How are you going to "send packets over the local network"?
It requires using socket funcitons which means also threading which is not stable.
If you somehow get that working (you won't but still), such solution will be slower and less efficient than using just a normal crapcore script to do the same job.
Also about events, you will not be able to return results in funcitons such as OnCommand, OnPlayerDamage etc

Offline LORD KILLA

  • Camper
  • ***
  • Posts: 254
  • Happie
Re: How about... C# ?
« Reply #7 on: May 22, 2010, 03:52:21 am »
This works already. And i use TcpAdminPM to send the event packs, and OnAdminMessage to recive Todos, and prefixes to identify 'this is a event/todo, not anything random'.
For event returns, you just send the event packed, and disable the return data (so that nothing happens..). Now when the app recives the event, it sends back what to do (eg OnPlayerDamage and DoDamage).
You may think this is slow, but sending/reciving 300 packs a second with a ~8% cpu load on a weak processor(one core, 1.4 Ghz) is kinda good... not ? (6 bots with chinsaw ;D ).
« Last Edit: May 22, 2010, 03:59:17 am by LORD KILLA »

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: How about... C# ?
« Reply #8 on: May 22, 2010, 11:52:37 am »
Then you're spamming adminport with 300 packets per second? Right, you can hide outcoming connections using TCPAdminPM, but you can't hide the incoming ones which will be sent to all connected admins causing a nice spam and blocking the server's connection.

Offline jrgp

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 5037
Re: How about... C# ?
« Reply #9 on: May 22, 2010, 12:02:01 pm »
Yes, there are people here who'd use it, but you're not going to be able to get any solid feedback until you actually release it.. :P
There are other worlds than these

Offline LORD KILLA

  • Camper
  • ***
  • Posts: 254
  • Happie
Re: How about... C# ?
« Reply #10 on: May 22, 2010, 12:51:20 pm »
Then you're spamming adminport with 300 packets per second? Right, you can hide outcoming connections using TCPAdminPM, but you can't hide the incoming ones which will be sent to all connected admins causing a nice spam and blocking the server's connection.
I know :( So the only part you'd do in soldat scripts is the damage calculation then... (you can choose if enable/disable sending OnDamage event packets)

jrgp: I worry others will say 'its crap!' cuz I dont have yet time to implement the missing functions... :(

Offline pavliko

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 397
  • >‿‿◕
    • Offical TTW Community
Re: How about... C# ?
« Reply #11 on: May 22, 2010, 01:07:31 pm »
Lord Killa please take this to the developers.
I know that they are too lazy/busy for this kind of a feature but until you wont release something "pro made" and working 100%, no one is even going to bother reading or helping....
« Last Edit: May 22, 2010, 01:11:29 pm by pavliko »
The safest thing to do is jumping out of a plane!

Offline jrgp

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 5037
Re: How about... C# ?
« Reply #12 on: May 22, 2010, 02:32:00 pm »
jrgp: I worry others will say 'its crap!' cuz I dont have yet time to implement the missing functions... :(

People will only say `it's crap' if, well, it is very low quality and unreliable. I don't think it missing certain functions counts as that.
There are other worlds than these

Offline LORD KILLA

  • Camper
  • ***
  • Posts: 254
  • Happie
Re: How about... C# ?
« Reply #13 on: July 27, 2011, 03:55:50 pm »
Nothing similar yet released ::)  ?