Extra Iterators for Foreach[vehicles,objectts...and more] + Some useful Functions -
BroZeus - 07.07.2014
Extra Iterators for foreach
+Some useful functions
Current Version : v1.0
This include provides some very useful extra iterator for foreach which can be found
HERE
The Iterators
The Iterator provided by this include and there description is as below
Vehicles [Contains all vehicle id's create via function CreateVehicle/AddStaticVehicle/AddStaticVehicleEx]
StaticVehicle [Contains all vehicle id's create via function AddStaticVehicle/AddStaticVehicleEx on GameModeInit]
Objects [Contains all objects id's create via function CreateObject]
DynamicObjects [Contains all objects id's create via function CreateDynamicObject]
Example Usage-
here are some example of how to use them
pawn Код:
foreach(new o : Objects)
{
}
pawn Код:
foreach(new v : Vehicles)
{
}
....and so like this for other Iters too
The Functions
This include also provides some useful functions.
The list of function and there description is given below-
GetTotalObjects() -- Returns the total number of objects in server
GetTotalVehicles() -- Return the total number of vehicles in server
GetTotalStaticVehicles() -- Return the total number of static vehicle in server [Note this is same as the number of vehicle models created that appear on server console when server is started]
GetTotalDynamicObjects() -- Returns the total number of Dynamic objects in server
IsStaticVehicle(vehicleid) -- Retruns true if vehicleid was created via function AddStaticVehicle/AddStaticVehicleEx on GameModeInit and false if it was not
NOTES
-->Use it in GM script only DONT use this in an FS
-->If the vehicles/objects are created via a Filter Script the this may not work according to your needs caz this keeps a track of script in which it is use
Recommend Usage! Do not use FS for creating or destroing any objects/vehicles while using this include
-->Do not write "#include streamer" after writing the the include line for this[ will caz bug]
Recommend Usage!Write this include line at last of other include lines
-->If there is any include which creates Objects/Vehicles then the line of that include should be placed after the include of this line and make sure the include that are been placed after the include line of this include shouldn't have "#include <streamer>" in them if they have just simpley remove the line from them.
-->Currently the iter size of Dynamic Object is 20,000 if you have more object in server you can edit its size. Just find the line "#define MAX_DYNAMIC 20000" and edit it
Download The Script
The script can be found here --
http://pastebin.com/WZkEGQdm
Credits
SAMP Team [no credits in samp cant be without them]
****** for foreach
and maybe me too?
Re: Extra Iterators for Foreach[vehicles,objectts...and more] + Some useful Functions -
JonathanW - 07.07.2014
Nice!
Re: Extra Iterators for Foreach[vehicles,objectts...and more] + Some useful Functions -
iFarbod - 07.07.2014
Make Iterators for Pickups, 3DTextLabels, Textdraws, GangZones, ...
BTW, Good Attempt, Nice Job. +REP
Re: Extra Iterators for Foreach[vehicles,objectts...and more] + Some useful Functions -
BroZeus - 07.07.2014
Quote:
Originally Posted by iFarbod
Make Iterators for Pickups, 3DTextLabels, Textdraws, GangZones, ...
BTW, Good Attempt, Nice Job. +REP
|
i was thinking to add it in new version of it
and if u have more suggestion for script fell free to post
Re: Extra Iterators for Foreach[vehicles,objectts...and more] + Some useful Functions -
Rittik - 07.07.2014
I was thinking to make some iterators yesterday. What a co-incidence .
On Topic:Can you give me an example of these iterators,I mean how does your iterator works, actually I wanted to know the purpose of it. Nice work though.
Re: Extra Iterators for Foreach[vehicles,objectts...and more] + Some useful Functions -
BroZeus - 07.07.2014
Quote:
Originally Posted by Rittik
I was thinking to make some iterators yesterday. What a co-incidence .
On Topic:Can you give me an example of these iterators,I mean how does your iterator works, actually I wanted to know the purpose of it. Nice work though.
|
if u mean how to make them then this is how it works-
-hook the create object/vehicle functions
-add the id's in iterator hooked functions
-remove the id's from iterator in destroy objects/vehicle hooked functions
if u mean how to use them then this is for it-
pawn Код:
foreach(new v : Vehicles)
{
//codes
}
Re: Extra Iterators for Foreach[vehicles,objectts...and more] + Some useful Functions -
Rittik - 07.07.2014
Quote:
Originally Posted by BroZeus
if u mean how to make them then this is how it works-
-hook the create object/vehicle functions
-add the id's in iterator hooked functions
-remove the id's from iterator in destroy objects/vehicle hooked functions
if u mean how to use them then this is for it-
pawn Код:
foreach(new v : Vehicles) { //codes }
|
Err, I meant something else, I asked for what kind usage your iterators will be used by scripters.
Re: Extra Iterators for Foreach[vehicles,objectts...and more] + Some useful Functions -
BroZeus - 07.07.2014
Quote:
Originally Posted by Rittik
Err, I meant something else, I asked for what kind usage your iterators will be used by scripters.
|
-the extra functions for getting total amount of objects/vehicles could be used to show in stats
Some scripters wanna show the the toatl number of vehicles object in thier server to there player via a command
-IsStaticVehicle function could be used to for not destroying the static vehicle and only destroying non static vehicle when server fleet is resawpned
-As we know they are iterators so they are much faster than normal "for" loops, and the looping through vehicles/objects are often done to find the vehicle owner, to see if player if player is near a vehicle or not......bla bla bla etc
Re : Extra Iterators for Foreach[vehicles,objectts...and more] + Some useful Functions -
S4t3K - 07.07.2014
I have made a slightly identic work in French part but I doubt you've copied it.
Nice work btw, rep+.
Re: Re : Extra Iterators for Foreach[vehicles,objectts...and more] + Some useful Functions -
BroZeus - 08.07.2014
Quote:
Originally Posted by S4t3K
I have made a slightly identic work in French part but I doubt you've copied it.
Nice work btw, rep+.
|
no i havent
i haven't seen it till yet
Re : Extra Iterators for Foreach[vehicles,objectts...and more] + Some useful Functions -
S4t3K - 08.07.2014
It's here (but in French) :
https://sampforum.blast.hk/showthread.php?tid=520125
A small translation of what's useful in the thread :
This small library provides actually 5 itterators that I've found "useful", for beginners as well as for the lazy men.
The itterators are :
• Vehicle : contains the IDs of all the existing vehicles (created through CreateVehicle/AddStaticVehicle(Ex))
• Pickup : contains the IDs of all existing pickups (created through CreatePickup)
• Object : contains the IDs of all existing static objects (created through CreateObject)
• DObject : contains the IDs of all existing dynamic objects (created through CreateDynamicObject)
• Labels : contains the IDs of all existing static 3D Text labels (created through Create3DTextLabel)
Re: Extra Iterators for Foreach[vehicles,objectts...and more] + Some useful Functions -
HolisticDev - 14.07.2014
I've been wanting someone like this for a long time.
I can't give you rep because of my posts, sorry. You do deserve it though.
Re: Extra Iterators for Foreach[vehicles,objectts...and more] + Some useful Functions -
Battlezone - 15.07.2014
Very useful! Thanks, +rep