How can i avoid these dynamic areas mixing with eacother ?
#1

Alright i have been playing around with dynamic areas...pickups ..checkpoints ..spheres..cubes.piramids or whatever there is more ARRHH ( sorry for that last part..to much emotion.. ).

After building up a nice piece of script like shown here i ALWAYS seem to be able to mix up the areas.
In this case here i made areas for Items and i wanted to add different areas (dynamic spheres) to vehicles (attached).

pawn Код:
public OnPlayerEnterDynamicArea(playerid, areaid)
{
    if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT || GetTickCount() - LastEnexStamp[playerid] < 1000) return 1;

    new id = Streamer_GetIntData(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID);
    if(id >= 0 && id < MAX_ITEMS)
    {
        if(Item[id][picked])
        {
            LastEnter[playerid] = id;
            LastEnexStamp[playerid] = GetTickCount();
            PlayerTextDrawShow(playerid,TDpickup[playerid]);
            PlayerTextDrawShow(playerid,TDdrop[playerid]);
            PlayerTextDrawShow(playerid,TDaction[playerid]);
            new ins[56];
            format(ins,sizeof(ins),"~w~~k~~CONVERSATION_YES~ ~y~~y~%s",Item[id][ItemName]);
            PlayerTextDrawSetString(playerid,TDpickup[playerid],ins);
        }
        return 1;
    }

//  new varea = Streamer_GetIntData(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID);
    for(new c = 0; c < MAX_VEHICLES; c++)
    if(areaid == vehaura[c])
    {
        SendClientMessage(playerid,COLOR_LIGHTBLUE,"should work..but i dont even see this message..just the textdraw from the items");
        return 1;
    }
   
    return 1;
}
When i walk to a vehicle..the script thinks i am walking next to an Item instead.
(thats what i meant with mixing areas up)

I tried to both return 1 at the last bracket because that made sence to me...unfortunatly it didnt help.

Please teach me once and for all HOW to stop this ' mixing up ' for happening again in other scripts i tend to make.
Reply
#2

You got the extra id (which shadows the array index), but then you did not check if it even matches your item area id, so if not walking into a item area, it will assume it's the item with the id of the extra id:

pawn Код:
public OnPlayerEnterDynamicArea(playerid, areaid)
{
    if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT || GetTickCount() - LastEnexStamp[playerid] < 1000) return 1;

    new id = Streamer_GetIntData(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID);
    if(id >= 0 && id < MAX_ITEMS)
    {
        if(Item[id][picked] && Item[id][itemarea] == areaid) // <<<<<
        {
            LastEnter[playerid] = id;
            LastEnexStamp[playerid] = GetTickCount();
            PlayerTextDrawShow(playerid,TDpickup[playerid]);
            PlayerTextDrawShow(playerid,TDdrop[playerid]);
            PlayerTextDrawShow(playerid,TDaction[playerid]);
            new ins[56];
            format(ins,sizeof(ins),"~w~~k~~CONVERSATION_YES~ ~y~~y~%s",Item[id][ItemName]);
            PlayerTextDrawSetString(playerid,TDpickup[playerid],ins);
 return 1; // <<< the return must be here
        }
       
    }

//  new varea = Streamer_GetIntData(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID);
    for(new c = 0; c < MAX_VEHICLES; c++)
    if(areaid == vehaura[c])
    {
        SendClientMessage(playerid,COLOR_LIGHTBLUE,"should work..but i dont even see this message..just the textdraw from the items");
        return 1;
    }
   
    return 1;
}
If it works, you can do the same thing for the vehicle areas
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)