Release ServerAd
#21
Yes
Reply

#22
(07-13-2012, 09:32)zxz0O0 Wrote: This is a plugin to display some advertisement in your server and also intended to provide an example on how to use the HudElem type.

Requires @Nukem's Server Addon 1.410+

sv_config.ini entries:
Code:
[ServerAd] //Text to be displayed Text=Visit ^1ItsMods.com ^7for great mods. //FontScale FontSize=1.6

Example how it will look like:
[Image: 56D9DDDAA20C9F14557CD920B33C4CAF7542D86A]

I have added comments to the source code so it's easier to understand. If you still have any questions feel free to ask.
Code:
using System; using System.Collections.Generic; using System.Text; using Addon; namespace ServerAd { public class Class1 : CPlugin { string AdText = string.Empty; int Counter = -1; float ServerAdSize = 1.6f; public override void OnServerLoad() { ServerPrint("\n ServerAd Plugin loaded \n Author: zxz0O0 \n Thanks to Nukem, Jariz, Pozzuh and Makavel\n"); ServerPrint(" www.youtube.com/zxz0O0 \n www.itsmods.com\n"); AdText = GetServerCFG("ServerAd", "Text", string.Empty); if (string.IsNullOrEmpty(AdText)) AdText = "Visit ^1ItsMods.com ^7for great mods."; ServerAdSize = float.Parse(GetServerCFG("ServerAd","FontSize","1.6"), System.Globalization.CultureInfo.InvariantCulture.NumberFormat); } //Before we create the HudElement we wait 1second so the server is 'ready' public override void OnAddonFrame() { if (Counter >= 0) { Counter++; //Calculation: AddonFrameInterval holds the interval of the thread in milliseconds (currently 250ms) so we do 1000ms/current interval and we get the number of frames per second (currently 4) if (Counter == (1000 / AddonFrameInterval)) { CreateServerAd(); Counter = -1; } } } /*HudElements get deleted on restart*/ public override void OnFastRestart() { Counter = 0; } public override void OnMapChange() { Counter = 0; } private void CreateServerAd() { //Create a simply 'empty' HudElement HudElem MyAd = CreateNewHudElem(); //Make the HudElement Text MyAd.Type = HudElementTypes.Text; //Show the HudElement to everyone MyAd.ShowToEnt = Entity_World; //HudElement hides when player is in menu MyAd.HideInMenu = true; //Set font and fontscale, default is the best looking in my opinion MyAd.Font = HudElementFonts.Default; MyAd.FontScale = ServerAdSize; ServerPrint("New Hud: " + MyAd.HudElementNum); /* The origin is relative from this point. I did not find out yet how the point type works correctly * Just try a bit yourself and find the perfect point * You can also let this value 0 then the 'start point' will be right to the radar */ MyAd.PointType = 82; //Set the relative origin MyAd.OriginY = 160f; MyAd.OriginX = 5f; //Set the text to the HudElement MyAd.SetString(AdText); //We just want the text to be white so we don't modify the Color struct } } }

Server Ad plugin loaded but not working. Plz tell me how to fix.

   

   
Reply

#23
ServerAd still works on my server
Reply

#24
this plug CSHARP Code is old?

or different

i going to compiling the code but is not working on server
Reply

#25
the plugin works withour errors or crashes.
the "old" code you say works, i have edited Little for my server, and that works too. nothing is wrong
Reply

#26
(07-23-2013, 08:25)sylvester123 Wrote:
(07-13-2012, 09:32)zxz0O0 Wrote: This is a plugin to display some advertisement in your server and also intended to provide an example on how to use the HudElem type.

Requires @Nukem's Server Addon 1.410+

sv_config.ini entries:
Code:
[ServerAd] //Text to be displayed Text=Visit ^1ItsMods.com ^7for great mods. //FontScale FontSize=1.6

Example how it will look like:
[Image: 56D9DDDAA20C9F14557CD920B33C4CAF7542D86A]

I have added comments to the source code so it's easier to understand. If you still have any questions feel free to ask.
Code:
using System; using System.Collections.Generic; using System.Text; using Addon; namespace ServerAd { public class Class1 : CPlugin { string AdText = string.Empty; int Counter = -1; float ServerAdSize = 1.6f; public override void OnServerLoad() { ServerPrint("\n ServerAd Plugin loaded \n Author: zxz0O0 \n Thanks to Nukem, Jariz, Pozzuh and Makavel\n"); ServerPrint(" www.youtube.com/zxz0O0 \n www.itsmods.com\n"); AdText = GetServerCFG("ServerAd", "Text", string.Empty); if (string.IsNullOrEmpty(AdText)) AdText = "Visit ^1ItsMods.com ^7for great mods."; ServerAdSize = float.Parse(GetServerCFG("ServerAd","FontSize","1.6"), System.Globalization.CultureInfo.InvariantCulture.NumberFormat); } //Before we create the HudElement we wait 1second so the server is 'ready' public override void OnAddonFrame() { if (Counter >= 0) { Counter++; //Calculation: AddonFrameInterval holds the interval of the thread in milliseconds (currently 250ms) so we do 1000ms/current interval and we get the number of frames per second (currently 4) if (Counter == (1000 / AddonFrameInterval)) { CreateServerAd(); Counter = -1; } } } /*HudElements get deleted on restart*/ public override void OnFastRestart() { Counter = 0; } public override void OnMapChange() { Counter = 0; } private void CreateServerAd() { //Create a simply 'empty' HudElement HudElem MyAd = CreateNewHudElem(); //Make the HudElement Text MyAd.Type = HudElementTypes.Text; //Show the HudElement to everyone MyAd.ShowToEnt = Entity_World; //HudElement hides when player is in menu MyAd.HideInMenu = true; //Set font and fontscale, default is the best looking in my opinion MyAd.Font = HudElementFonts.Default; MyAd.FontScale = ServerAdSize; ServerPrint("New Hud: " + MyAd.HudElementNum); /* The origin is relative from this point. I did not find out yet how the point type works correctly * Just try a bit yourself and find the perfect point * You can also let this value 0 then the 'start point' will be right to the radar */ MyAd.PointType = 82; //Set the relative origin MyAd.OriginY = 160f; MyAd.OriginX = 5f; //Set the text to the HudElement MyAd.SetString(AdText); //We just want the text to be white so we don't modify the Color struct } } }

Server Ad plugin loaded but not working. Plz tell me how to fix.

It wont work for older versions of addon like 1.204. Use latest one

Sent from my E16i using Tapatalk 2
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  ServerAd kpoviv 1 2,482 07-21-2012, 01:32
Last Post: JariZ

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2026 Melroy van den Berg.