Log in to reply

I made a script, it wont work, pls help me.

  • Anyone have any idea why this wont work???0_1476234118226_Capture.PNG

  • @bur587 Yes, everything you write should be within the namespace {} brackets (after namespace [name] of course) but only lines 13 to 17 are.

    You can't have a namespace that has spaces in the name. HookerSpawner would be valid Hooker spawner is not.

    You have no constructor, which lines 15 & 16 should be inside.

    Your key checking is outside the OnKeyDown function, so it never gets checked. Lines 30 to 34 should be at line 27

    You also have a missing parenthesis on the end of line 30

    Your parentheses are generally all over the place.

    All those red lines under things are faults... start at the top and work your way down. But more importantly read up on the basics of C# class construction, because if you can't get the basics in order first, nothing will ever work.

  • // change namespacename and classname to your choice
    namespace namespacename // No spaces in the namespacename
    	public class classname : Script // No spaces in the classname
    		// This is the constructor
    		public classname()
    			this.Tick += OnTick;
    			this.KeyDown += OnKeyDown;
    			Interval = 0; // This will make things happen every frame
    		private void OnTick(object sender, EventArgs e)
    			// Do stuff here
    		private void OnKeyDown(object sender, KeyEventArgs e)
    			// Check keys here

  • If any of that is wrong (or my first post sounds snarky, which it probably does), my defence is that it's 3:42am and I'm tired, no offence is/was intended. :(

  • @LeeC2202 Thanks, Ill try to fix it :)

  • @bur587 Use the skeleton code in my post as a basis, that should give you a working base to start from. It's a text post so you can just copy and paste it.

  • @LeeC2202 Ok :) Thanks

  • @LeeC2202 I am still getting errors?


  • @bur587 You haven't added the using GTA; etc... lines

    using System;
    using System.Windows.Forms;
    using GTA;
    using GTA.Math;
    using GTA.Native;

Log in to reply

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.