Area Types?
#1

Is it possible to set area types using incognitos streamer plugin?

Like...

Business Areas

Item Areas

etc..
Reply
#2

Yes you can do with the following section:
Quote:

Data Manipulation:

Код:
native Streamer_GetFloatData(type, STREAMER_ALL_TAGS id, data, &Float:result);
native Streamer_SetFloatData(type, STREAMER_ALL_TAGS id, data, Float:value);
native Streamer_GetIntData(type, STREAMER_ALL_TAGS id, data);
native Streamer_SetIntData(type, STREAMER_ALL_TAGS id, data, value);
native Streamer_GetArrayData(type, STREAMER_ALL_TAGS id, data, dest[], maxdest = sizeof dest);
native Streamer_SetArrayData(type, STREAMER_ALL_TAGS id, data, const src[], maxsrc = sizeof src);
native Streamer_IsInArrayData(type, STREAMER_ALL_TAGS id, data, value);
native Streamer_AppendArrayData(type, STREAMER_ALL_TAGS id, data, value);
native Streamer_RemoveArrayData(type, STREAMER_ALL_TAGS id, data, value);
native Streamer_GetUpperBound(type);
Example:
pawn Код:
#define AREA_TYPE_BUSINESS (0)

Streamer_SetIntData(STREAMER_TYPE_AREA, area_id, E_STREAMER_EXTRA_ID, AREA_TYPE_BUSINESS);

if (Streamer_GetIntData(STREAMER_TYPE_AREA, area_id, E_STREAMER_EXTRA_ID) == AREA_TYPE_BUSINESS )
{
    // its business area
}
Reply
#3

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Yes you can do with the following section:


Example:
pawn Код:
#define AREA_TYPE_BUSINESS (0)

Streamer_SetIntData(STREAMER_TYPE_AREA, area_id, E_STREAMER_EXTRA_ID, AREA_TYPE_BUSINESS);

if (Streamer_GetIntData(STREAMER_TYPE_AREA, area_id, E_STREAMER_EXTRA_ID) == AREA_TYPE_BUSINESS )
{
    // its business area
}
Ah ok I see how this is working. So upon creating an area just after I'll need to use the Streamer_SetIntData to store some extra information into the area and then Streamer_GetIntData to receive it using the areaid supplied by OnPlayerEnterDynamicArea - Thanks buddy that's brilliant and also brilliant of incognito to make it work like this. Genius!

I was thinking of ways I could store information using the areaid upon creation of it but it's already done haha! +Repped you
Reply
#4

Would this work in the following way? Am I able to use it like this?

pawn Код:
BusinessInfo[b][bLandlineArea] = CreateDynamicArea(areaid); <--- EXAMPLE (I know it's not the correct format)
Streamer_SetInt(STREAMER_TYPE_AREA, BusinessInfo[b][bLandlineArea], E_STREAMER_TYPE, BUSINESS_LANDLINE_AREA);
Streamer_SetInt(STREAMER_TYPE_AREA, BusinessInfo[b][bLandlineArea], E_STREAMER_EXTRA_ID, b);

public OnPlayerEnterDynamicArea(playerid, areaid)
{
    if(Streamer_GetInt(STREAMER_TYPE_AREA, areaid, E_STREAMER_TYPE) == BUSINESS_LANDLINE_AREA)
    {
        new b = Streamer_GetInt(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID);
       
        LandlineInteraction[playerid] = 1;
        LandlineNo[playerid] = BusinessInfo[b][bLandlineNo];
        LandlineCode[playerid] = BusinessInfo[b][bLandlineCode];
       
        //THE PLAYER CAN NOW USE HOTKEY TO INTERACT WITH LANDLINE
    }
}
Reply
#5

Check this out:

Код:
#define AREA_TYPE_BUSINESS 1;
#define AREA_TYPE_BLAHBLAH 2;

enum areas_info {
    Type,
    AreaID
}

new Areas[MAX_AREAS][areas_info];

AreasInt()
{
     Areas[0][Type] = AREA_TYPE_BUSINESS;
     Areas[0][AreaID] = CreateDynamicRectangle(...);

     Areas[1][Type] = AREA_TYPE_BUSINESS;
     Areas[1][AreaID] = CreateDynamicRectangle(...);

     Areas[2][Type] = AREAY_TYPE_BLAHBLAH;
     Areas[2][AreaID] = CreateDynamicRectangle(...);
}

IsBusinessArea(areaid)
{
    // If is business
    if (Areas[10][Type] == AREA_TYPE_BUSINESS)
        return true;

    // If not
    return false;
}
Reply
#6

Quote:
Originally Posted by amirm3hdi
Посмотреть сообщение
Check this out:

Код:
#define AREA_TYPE_BUSINESS 1;
#define AREA_TYPE_BLAHBLAH 2;

enum areas_info {
    Type,
    AreaID
}

new Areas[MAX_AREAS][areas_info];

AreasInt()
{
     Areas[0][Type] = AREA_TYPE_BUSINESS;
     Areas[0][AreaID] = CreateDynamicRectangle(...);

     Areas[1][Type] = AREA_TYPE_BUSINESS;
     Areas[1][AreaID] = CreateDynamicRectangle(...);

     Areas[2][Type] = AREAY_TYPE_BLAHBLAH;
     Areas[2][AreaID] = CreateDynamicRectangle(...);
}

IsBusinessArea(areaid)
{
    // If is business
    if (Areas[10][Type] == AREA_TYPE_BUSINESS)
        return true;

    // If not
    return false;
}
Sorry I think you're missing the point. I appreciate you trying to help but I'm trying to AVOID looping as much as possible. This will just end up with the same result of looping and checking things where as I can just pass key variables and use them with the areaid as shown above by Gammix. I was just rather blind when looking through what I could actually achieve with incognitos streamer.
Reply
#7

Quote:
Originally Posted by FarTooBaked
Посмотреть сообщение
Would this work in the following way? Am I able to use it like this?

pawn Код:
BusinessInfo[b][bLandlineArea] = CreateDynamicArea(areaid); <--- EXAMPLE (I know it's not the correct format)
Streamer_SetInt(STREAMER_TYPE_AREA, BusinessInfo[b][bLandlineArea], E_STREAMER_TYPE, BUSINESS_LANDLINE_AREA);
Streamer_SetInt(STREAMER_TYPE_AREA, BusinessInfo[b][bLandlineArea], E_STREAMER_EXTRA_ID, b);

public OnPlayerEnterDynamicArea(playerid, areaid)
{
    if(Streamer_GetInt(STREAMER_TYPE_AREA, areaid, E_STREAMER_TYPE) == BUSINESS_LANDLINE_AREA)
    {
        new b = Streamer_GetInt(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID);
       
        LandlineInteraction[playerid] = 1;
        LandlineNo[playerid] = BusinessInfo[b][bLandlineNo];
        LandlineCode[playerid] = BusinessInfo[b][bLandlineCode];
       
        //THE PLAYER CAN NOW USE HOTKEY TO INTERACT WITH LANDLINE
    }
}
You can only add extra data to E_STREAMER_EXTRA_ID, the other elements or parts of enum are used by streamer plugin (though you can change them but in your case, no).

If you want to store multiple data for a specific area, you should look for the array function (Streamer_SetArrayData).
Reply
#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


Forum Jump:


Users browsing this thread: 2 Guest(s)