motorsport71 Posted February 20, 2011 Share Posted February 20, 2011 I've looked through all the tutorials and the search is down: I've created an extensive mod, and i am having trouble with ped collection. I created a bypass that takes my "nolongerneeded" peds and removes them while offscreen as a tick due to the fact i cannot seem to get the Pedcollections to work properly. I could use help if anyone is available. Inherits Script Private Infected As Boolean = False Private Cop As Boolean = False Private Invi As Boolean = False Private Pedcollection As system.object '**** cannot get to function?????**** Private Const HEALTH_VALUE As Integer = 100Public Sub New() pedcollection.OrderByDistanceTo(Player.Character.Position, 21.0F) '****cannot get to function????**** bindkey(keys.M, AddressOf Infected1) bindkey(keys.H, AddressOf Police) bindkey(keys.J, AddressOf Invincible) bindkey(keys.I, AddressOf FireWeapons) i've also tried the line "pedcollection.OrderByDistanceTo(Player.Character.Position, 21.0F)" in the block creating the targeted peds that is set up on a toggle. It does, as expected, error when activated. The targeted Peds, on the toggle, are set on a tick. I am using Visual Basic, but any example may help. Link to comment https://gtaforums.com/topic/470179-proper-use-of-pedcollection/ Share on other sites More sharing options...
iriedreadlock23 Posted February 21, 2011 Share Posted February 21, 2011 PedCollection is very simple example of System.Collections Namespace, particulary ObjectModel. You can Add, Remove, get IndexOf etc. If you want your own collections of any object (string, integer, vehicle...) use this: Imports System.Collections.ObjectModelPrivate Class MyClassPrivate MyPedCollection as Collection(Of Ped)Private Test_Ped as PedSub New()MyPedCollection = New Collection (Of Ped)Test_Ped = World.CreatePed(Player.Character.Position)MyPedCollection.Add ( Test_Ped) End SubSub Hide_Peds()For Each iPed as Ped in MyPedCollectionIf iPed.isOnScreen = False Then iPed.Visible = FalseNext ForEnd SubEnd Class Link to comment https://gtaforums.com/topic/470179-proper-use-of-pedcollection/#findComment-1060348558 Share on other sites More sharing options...
motorsport71 Posted February 22, 2011 Author Share Posted February 22, 2011 @iriedreadlock23 Thank you for the explaination. I was able to quite easily make my ped collection work without using my workaround, which is quite fantastic. Your help is greatly appreciated. Link to comment https://gtaforums.com/topic/470179-proper-use-of-pedcollection/#findComment-1060348947 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now