Quantcast

Jump to content

» «
Photo

How to delete last created object in c# ?

2 replies to this topic
Amey.Banaye
  • Amey.Banaye

    BlackDragon

  • Members
  • Joined: 30 Dec 2013
  • India

#1

Posted 31 December 2013 - 04:57 PM

And how to bind console commands ?

 

My code :-

 

BindConsoleCommand("Spawn Cop Car",new ConsoleCommandDelegate(consoleHandle);

 

public void consoleHandle()
        {
            //get position on street near player
            Vector3 vehPos = World.GetNextPositionOnStreet(Player.Character.Position.Around(10.0f));
            //create vehicle
            World.CreateVehicle(new Model("POLICE"), vehPos);
        }
 
error I get :-
Error 2 No overload for 'consoleHandle' matches delegate 'GTA.ConsoleCommandDelegate' D:\GTA IV MODS\MY SCRIPTS\myfirstmod\myfirstmod\Class1.cs 23 46 myfirstmod
 

 


AgentWD40
  • AgentWD40

    GLITCHED

  • Members
  • Joined: 02 May 2009
  • Philippines

#2

Posted 01 January 2014 - 01:33 AM Edited by hardsty1e, 02 January 2014 - 04:35 AM.

could be

Vehicle[] spawnedCar;

public void consoleHandle(ParameterCollection args)
    {
        //get position on street near player
        Vector3 vehPos = World.GetNextPositionOnStreet(Player.Character.Position.Around(10.0f));
        //create vehicle
        spawnedCar[1] = World.CreateVehicle(new Model("POLICE"), vehPos);
    }
public Main()
{
     if (isKeyPressed(Settings.GetValueKey("Key", Keys.P)))
        {
            for (int i = 0; i < spawnedCar.Length; i++)
            {
                if (Game.Exists(spawnedCar[1]) && spawnedCar[1] != null)
                {
                    spawnedCar[1].Delete();
                }
            }
        }
}

Donny78
  • Donny78

    Zombie

  • Members
  • Joined: 18 Jul 2008

#3

Posted 04 January 2014 - 03:51 PM

There is no closing brace for your bind method.

 

Also why create the 'vehPos' variable if you only use it a single time and in the line below it, makes no sense to me (I'm no expert though), may aswell just supply the position directly.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users