ItsMods

Full Version: Helpp
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Anyone delete this thread already fixed Sleepy
You might want to tell people what your problem is.

edit:


SetDvar("scr_dm_score_kill", " + NewXPValue");

should be

SetDvar("scr_dm_score_kill", NewXPValue);
Didnt see the post ^^^ fail was going to say whats wrong with it?
(01-20-2012, 16:48)Pozzuh Wrote: [ -> ]You might want to tell people what your problem is.

edit:


SetDvar("scr_dm_score_kill", " + NewXPValue");

should be

SetDvar("scr_dm_score_kill", NewXPValue);


it gives me 2 errors, im in visual c# 2010

EDIT:
The best overloaded method match for 'Addon.CPlugin.SetDvar(string, string)' has some invalid arguments
AND
Argument 2: cannot convert from 'int' to 'string'
Try this
Code:
using Addon;
using System;
namespace xpmanager
{
    public class xpmanager : CPlugin
    {
        public override void OnServerLoad()
        {
            ServerPrint("XP Manager V1 Loaded Successfully");
        }
        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 Kill XP Is: " + xp, true);
                else
                {
                    try
                    {
                        int NewXPValue = Convert.ToInt32(splitMsg[1]);
                        SetDvar("scr_dm_score_kill", NewXPValue);
                        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 HeadShot XP Is: " + hxp, true);
                else
                {
                    try
                    {
                        int NewHXPValue = Convert.ToInt32(splitMsg[1]);
                        SetDvar("scr_dm_score_headshot", "omg");
                        TellClient(Client.ClientNum, "^1HeadShot XP Changed To: " + NewHXPValue, true);
                    }
                    catch (Exception e)
                    {
                        TellClient(Client.ClientNum, "^1Invalid HeadShot XP Value!", true);
                    }
                }
                return ChatType.ChatNone;
            }
            return ChatType.ChatContinue;
        }

        private void SetDvar(string p, int NewXPValue)
        {
            throw new NotImplementedException();
        }
    }
}

(01-20-2012, 16:48)Pozzuh Wrote: [ -> ]SetDvar("scr_dm_score_kill", " + NewXPValue");

should be

SetDvar("scr_dm_score_kill", NewXPValue);
Used that in the code above ^^^^
try
Code:
SetDvar("scr_dm_score_kill", NewXPValue.ToString());

or just don't convert it to an integer... because the SetDvar function requires 2 strings .