ItsMods

Full Version: Attachment problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Using !shop i want players to be able to buy attachments but code below doesn't work?
PHP Code:
//Attachments
                
if (Message == "!41")
                {
                    
int attachCost2 Convert.ToInt32(attachCost);
                    if ((int)
Points[Client.XUID] < attachCost2)
                    {
                        
iPrintLnBold("^1Not enough points!"Client);
                    }
                    else
                    {

                        
int Current Client.Other.CurrentWeapon;
                        
int WepID GetWeapon(Current "_reflex");
                        
Client.Other.PrimaryWeapon WepID;
                        
Client.Other.PrimaryWeapon WepID;
                        
Points[Client.XUID] = ((int)Points[Client.XUID]) - attachCost2
Try doing the opposite instead
Code:
if ((int)Points[Client.XUID] > attachCost2)
{
                        int Current = Client.Other.CurrentWeapon;
                        int WepID = GetWeapon(Current + "_reflex");
                        Client.Other.PrimaryWeapon = WepID;
                        Client.Other.PrimaryWeapon = WepID;
                        Points[Client.XUID] = ((int)Points[Client.XUID]) - attachCost2;
}
else
iPrintLnBold("^1Not enough points!", Client);

Also try adding a iprintln at each line (to debug where it goes lost so yeah, make sure to use different texts :>)
int WepID = GetWeapon(Current + "_reflex");

I think it's this line that won't work because _reflex will probably return 0 because it isn't a weapon, not sure though.
Also for smg's you have to use smgreflex as far as I know.
Dam tried it so many ways my head hurts

Off top but is there a database i can use to remember points etc when the server is rebooted i rent mine so have to have one that will do it that way? I thought i did see one posted somewhere but can't find it.
Try looking at our QCZM code for attachment giving (even though this portion is more @NTAuthority 's code)
Code:
public static string[] GetDesiredAttachments()
        {
            var attachmentTypes = new[]
            {
                "none",
                "sight",
                "sight",
                "sight",
                "sight",
                "sight",
                "other",
                "other",
                "other",
                "final"
            };

            switch (attachmentTypes[_rng.Next(0, attachmentTypes.Length)])
            {
                case "none":
                    return new string[0];
                case "sight":
                    return new[]
                    {
                        "acog",
                        "reflex",
                        "hamrhybrid",
                        "hybrid",
                        "zoomscope",
                        "eotech",
                        "vzscope"
                    };
                case "other":
                    return new[]
                    {
                        "silencer",
                        "silencer02",
                        "silencer03",
                        "grip",
                        "gl",
                        "gp25",
                        "m320",
                        "shotgun"
                    };
                case "final":
                    return new[]
                    {
                        "thermal",
                        "heartbeat"
                    };
            }

            return new string[0];
        }
(02-22-2013, 03:13)hillbilly Wrote: [ -> ]Dam tried it so many ways my head hurts

Off top but is there a database i can use to remember points etc when the server is rebooted i rent mine so have to have one that will do it that way? I thought i did see one posted somewhere but can't find it.

You mean database from @8q4s8 or @archit?
I thought it was in the Shop system for Infected gametype topc.
Link :
mysql
http://pastebin.com/FJHqh8a8 (archit)(mysql)

From @8q4s8 (text files)
(12-27-2012, 13:08)8q4s8 Wrote: [ -> ]In OnPlayerDamaged:
CSHARP Code
  1. try
  2. {
  3. Points[Attacker.XUID] = (((int)Points[Attacker.XUID]) + 100);
  4.  
  5. StreamWriter writer = new StreamWriter("C:\\Mw3\\shop\\" + Attacker.XUID + ".txt");
  6.  
  7. int points = (int)Points[Attacker.XUID];
  8.  
  9. writer.WriteLine(Attacker.XUID + "=" + points.ToString());
  10. writer.Dispose();
  11. writer.Close();
  12. }

In OnPlayerConnect
CSHARP Code
  1. try
  2. {
  3. StreamReader reader = new StreamReader("C:\\Mw3\\shop\\" + Client.XUID + ".txt");
  4.  
  5. string read = reader.ReadLine();
  6. string read2 = read;
  7.  
  8. string[] readArray = read2.Split('=');
  9. Points[Client.XUID] = int.Parse(readArray[1]);
  10. }


I think I release the code because many people want the point saving stuff. This will create a .txt file for every player who got points and it's updating it every kill. It will read the file OnPlayerConnect and add the points. It isn't as good as a SQL database but it's working pretty good.
tried that Rock just keep getting this error

System.ArgumentException: URI formats are not supported.
(02-22-2013, 14:23)hillbilly Wrote: [ -> ]tried that Rock just keep getting this error

System.ArgumentException: URI formats are not supported.

Lol I will take a look on teamviewer if you allow me to Smile I send pm
thanks Rock