Area Types?
#8

Use the id returned by CreateDynamicRectangle as the index of the array to store the areatype:
PHP код:
#define AREA_TYPE_BUSINESS 1;
#define AREA_TYPE_BLAHBLAH 2;
new AreaTypes[MAX_AREAS];
AreasInt()
{
    new 
areaid;
     
areaid CreateDynamicRectangle(...);
     
AreaTypes[areaid] = AREA_TYPE_BUSINESS;
     
areaid CreateDynamicRectangle(...);
     
AreaTypes[areaid] = AREA_TYPE_BUSINESS;
     
areaid CreateDynamicRectangle(...);
     
AreaTypes[areaid] = AREAY_TYPE_BLAHBLAH;
}
OnPlayerEnterDynamicArea(playeridareaid);
{
    If (
AreaTypes[areaid] == AREA_TYPE_BUSINESS)
    {
        
// Do something
    
}

This way, you don't have to loop anything, because the streamer callbacks already provide you with the areaid, which is used directly as index of the array to access the data.
And no need to use the set&get functions of the streamer to access the data about your areas.
Default arrays are easier to use and probably faster too.

You can use the same idea for objects (streamer) and vehicles as well (default samp functions): use the id returned by Create... functions as index of an array and have immediate access to your data.

PHP код:
enum vData
{
    
Fuel,
    
Color1,
    
Color2,
    
Float:x,
    
Float:y,
    
Float:z
}
new 
VehicleData[MAX_VEHICLES][vData];
InitVehicles()
{
    new 
vehicleid;
    
vehicleid CreateVehicle(...);
    
VehicleData[vehicleid][Fuel] = 20;
    
VehicleData[vehicleid][Color1] = 1;
    
VehicleData[vehicleid][Color2] = 5;
    
VehicleData[vehicleid][x] = 100.0;
    
VehicleData[vehicleid][y] = 1750.0;
    
VehicleData[vehicleid][z] = 5.9;
}
public 
OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    if (
VehicleData[vehicleid][Fuel] == 0)
        
// Turn off engine and inform player (or whatever)
    
return 1;

You also won't risk overwriting some data, because those Create... functions are designed to use unique id's.
So each vehicle, object, area, pickup, etc, only points to one unique index of the array.
Reply


Messages In This Thread
Area Types? - by FarTooBaked - 05.02.2016, 13:05
Re: Area Types? - by Gammix - 05.02.2016, 13:23
Re: Area Types? - by FarTooBaked - 05.02.2016, 15:06
Re: Area Types? - by FarTooBaked - 05.02.2016, 15:27
Re: Area Types? - by amirm3hdi - 05.02.2016, 15:51
Re: Area Types? - by FarTooBaked - 05.02.2016, 17:21
Re: Area Types? - by Gammix - 05.02.2016, 22:24
Re: Area Types? - by AmigaBlizzard - 05.02.2016, 23:21

Forum Jump:


Users browsing this thread: 2 Guest(s)