Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another bit of help...
#1
EDIT: Fixed!!! Go to the XP Manager Release for more info
Guys, happens that I released my XP Manager plugin, but it has a bug.
You can't change or view the current kill/headshot/suicide xp if its not defined in your admin\server.cfg file. I already tried
Code:
if (GetDvar("scr_dm_score_kill") == "0")
{
SetDvar("scr_dm_score_kill", "100");
}
AND
Code:
public override void OnServerLoad()
{
SetDvar("scr_dm_score_kill", "100");
}

Well, here the source code of my plugin:
Code:
using Addon;
using System;
namespace xpmanager
{
    public class xpmanagerclass : CPlugin
    {
        public override void OnServerLoad()
        {
            ServerPrint("XP Manager V1 Loaded Successfully. Author: slipknotignacio");
        }
        public override ChatType OnSay(string Message, ServerClient Client)
        {
            string lowMsg = Message.ToLower();

            if (lowMsg.StartsWith("!xp"))
            {
                string[] splitMsg = lowMsg.Split(' ');
                String xp = GetDvar("scr_dm_score_kill");
                if (splitMsg.Length == 1)
                    TellClient(Client.ClientNum, "^1Your Current Kill XP Is: " + xp, true);
                else
                {
                    try
                    {
                        int NewXPValue = Convert.ToInt32(splitMsg[1]);
                        string qxp = NewXPValue.ToString();
                        SetDvar("scr_dm_score_kill", qxp);
                        TellClient(Client.ClientNum, "^1Kill XP Changed To: " + NewXPValue, true);
                    }
                    catch (Exception e)
                    {
                        TellClient(Client.ClientNum, "^1Invalid Kill XP Value!", true);
                    }
                }
                return ChatType.ChatNone;
            }

            if (lowMsg.StartsWith("!hxp"))
            {
                string[] splitMsg = lowMsg.Split(' ');
                String hxp = GetDvar("scr_dm_score_headshot");
                if (splitMsg.Length == 1)
                    TellClient(Client.ClientNum, "^1Your Current HeadShot XP Is: " + hxp, true);
                else
                {
                    try
                    {
                        int NewHXPValue = Convert.ToInt32(splitMsg[1]);
                        string qhxp = NewHXPValue.ToString();
                        SetDvar("scr_dm_score_headshot", qhxp);
                        TellClient(Client.ClientNum, "^1HeadShot XP Changed To: " + NewHXPValue, true);
                    }
                    catch (Exception e)
                    {
                        TellClient(Client.ClientNum, "^1Invalid HeadShot XP Value!", true);
                    }
                }
                return ChatType.ChatNone;
            }

            if (lowMsg.StartsWith("!sxp"))
            {
                string[] splitMsg = lowMsg.Split(' ');
                String sxp = GetDvar("scr_dm_score_suicide");
                if (splitMsg.Length == 1)
                    TellClient(Client.ClientNum, "^1Your Current Suicide XP Is: " + sxp, true);
                else
                {
                    try
                    {
                        int NewSuicideXPValue = Convert.ToInt32(splitMsg[1]);
                        string qsxp = NewSuicideXPValue.ToString();
                        SetDvar("scr_dm_score_suicide", qsxp);
                        TellClient(Client.ClientNum, "^1Suicide XP Changed To: " + NewSuicideXPValue, true);
                    }
                    catch (Exception e)
                    {
                        TellClient(Client.ClientNum, "^1Invalid Suicide XP Value!", true);
                    }
                }
                return ChatType.ChatNone;
            }
            return ChatType.ChatContinue;
        }
    }
}
Reply

#2
The dvars aren't actually present before you set them. It's not possible to fix your problem, sorry.
[Image: MaEIQ.png]
Reply

#3
(01-20-2012, 20:34)Pozzuh Wrote: The dvars aren't actually present before you set them. It's not possible to fix your problem, sorry.

and what about the fov plugin?
Reply

#4
File.WriteAllText( File.ReadAllText( Directory.GetCurrentDirectory() + "/admin/server.cfg" ) + "\nset scr_dm_score_kill \"100\"\nset scr_dm_score_headshot \"100\"" );

Troll
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#5
(01-20-2012, 20:36)slipknotignacio Wrote:
(01-20-2012, 20:34)Pozzuh Wrote: The dvars aren't actually present before you set them. It's not possible to fix your problem, sorry.

and what about the fov plugin?

The fov dvar IS present. Hard to explain. This will work with most dvars, but not with all.
[Image: MaEIQ.png]
Reply

#6
the xp dvars are set by gsc scripts

edit: I think FOV is done by the Engine, thats the difference
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#7
(01-20-2012, 20:36)iAegle Wrote: File.WriteAllText( File.ReadAllText( Directory.GetCurrentDirectory() + "/admin/server.cfg" ) + "\nset scr_dm_score_kill \"100\"\nset scr_dm_score_headshot \"100\"" );

Troll

omg are you coding boss or something? and where i do put that? and i want to check first if the guy has that parameter already set, because it will change to 100 even if he has set it to 999
(01-20-2012, 20:37)Pozzuh Wrote:
(01-20-2012, 20:36)slipknotignacio Wrote:
(01-20-2012, 20:34)Pozzuh Wrote: The dvars aren't actually present before you set them. It's not possible to fix your problem, sorry.

and what about the fov plugin?

The fov dvar IS present. Hard to explain. This will work with most dvars, but not with all.

ahh, i got the idea...
Reply

#8
(01-20-2012, 20:39)slipknotignacio Wrote:
(01-20-2012, 20:36)iAegle Wrote: File.WriteAllText( File.ReadAllText( Directory.GetCurrentDirectory() + "/admin/server.cfg" ) + "\nset scr_dm_score_kill \"100\"\nset scr_dm_score_headshot \"100\"" );

Troll

omg are you coding boss or something? and where i do put that? and i want to check first if the guy has that parameter already set, because it will change to 100 even if he has set it to 999

That's the problem, you can't check the original value.

As @iAegle said 'cg_fov' is an engine dvar, scr_score_* is a script (gsc) dvar.
[Image: MaEIQ.png]
Reply

#9
ok here's a readable one:
Code:
if( GetDvar( "scr_dm_score_kill" ) == "" )
{
    string text = File.ReadAllText( Directory.GetCurrentDirectory() + "/admin/server.cfg" ) +
        "\nset scr_dm_score_kill \"100\"" +
        "\nset scr_dm_score_headshot \"100\"";

    File.WriteAllText( Directory.GetCurrentDirectory() + "/admin/server.cfg", text );
}
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#10
(01-20-2012, 20:41)iAegle Wrote: ok here's a readable one:
Code:
if( GetDvar( "scr_dm_score_kill" ) == "" )
{
    string text = File.ReadAllText( Directory.GetCurrentDirectory() + "/admin/server.cfg" ) +
        "\nset scr_dm_score_kill \"100\"" +
        "\nset scr_dm_score_headshot \"100\"";

    File.WriteAllText( Directory.GetCurrentDirectory() + "/admin/server.cfg", text );
}

error: the name "directory" and "file" does not exist in the current contest... i need to put using blablabla?
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

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