using array for enter/exits etc
#1

They're mixing up and I don't know how to fix it really, I got tired of using a zillion lines so I gave this a try -_-

The script doesn't know which is which so I end up getting teleported to the wrong X,Y,Z etc
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>
#include <streamer>
enum TLocation
{
    ID,
    LocationName[50], // The name of the location
    AreaName[25], // Area name, 'Market' for example.
    // THE ENTER CHECKPOINT, FACING ANGLE FOR EXIT POS IS SET HERE
    Float:EntX, // The X-position of the Entrance
    Float:EntY, // The Y-position of the Entrance
    Float:EntZ, // The Z-position of the Entrance
    Float:EntF, // The Facing Angle once exitted
   
    // THE EXIT CHECKPOINT, FACING ANGLE FOR ENTER POS IS SET HERE
    Float:ExiX, // The X-position of the Exit
    Float:ExiY, // The Y-position of the Exit
    Float:ExiZ, // The Z-position of the Exit
    Float:ExiF, // The Facing Angle once Entered
    //OTHER SETTINGS
    Float:robX, // Robbery/Store checkpoint
    Float:robY,
    Float:robZ,
    RobMin, // Minimum money from robbbery
    RobMax, // maximum money from robbery
    Vw, // interior virtualworld
    Interior // interior id
}

// Setup an array that holds all location-data (except taxi and busdriver classes, these have their own locations)
new ALocations[][TLocation] =
{   //ID  Loc   Area        X           Y           Z       F           X2      Y2      Z2          F2      robX    robY        robZ
    {0, "Gym", "Ganton", 2229.5847, -1721.5706, 13.5642, 180.5844, 772.2877, -5.3067, 1000.7286, 319.2422, 766.7114, 9.7772, 1000.7092, 10000, 25000, 1, 5},
    {1, "Ammunation", "Market", 1368.2839, -1279.7400, 13.5469, 00.000, 315.7189, -143.4224, 999.6016, 00.000, 314.0695,-133.5970,999.6016, 10000, 25000, 2, 7}
},
    accessPoints[][3];
new entertime[MAX_PLAYERS];
stock Pickups()
{
    for(new i; i < sizeof(ALocations); i++)
    {
        accessPoints[i][0] = CreateDynamicPickup(19198, 1, ALocations[i][EntX], ALocations[i][EntY], ALocations[i][EntZ], 0, 0, -1, 200.0); // enter
        accessPoints[i][1] = CreateDynamicPickup(19198, 1, ALocations[i][ExiX], ALocations[i][ExiY], ALocations[i][ExiZ], ALocations[i][Vw], ALocations[i][Interior], -1, 200.0); //exit
    }
}

stock Checkpoints()
{
    for(new i; i < sizeof(ALocations); i++)
    {
        accessPoints[i][2] = CreateDynamicCP(ALocations[i][robX], ALocations[i][robY], ALocations[i][robZ], 2, ALocations[i][Vw], ALocations[i][Interior], -1, 100.0);
    }
}


stock ShopDialog(playerid)
{
    for(new i; i < sizeof(ALocations); i++)
    {
            new string[256];
            format(string,sizeof(string), "You're in %s", ALocations[i][LocationName]);
            SendClientMessage(playerid, -1, string);
    }
}
public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    Checkpoints();
    Pickups();
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}


public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    if(entertime[playerid] <= gettime())
    {
        for(new i; i < sizeof(ALocations); i++)
        {
            if(pickupid == accessPoints[i][0])
            {
                SetPlayerPos(playerid, ALocations[i][ExiX], ALocations[i][ExiY], ALocations[i][ExiZ]);
                SetPlayerFacingAngle(playerid, ALocations[i][ExiF]);
                SetPlayerInterior(playerid, ALocations[i][Interior]);
                SetPlayerVirtualWorld(playerid, ALocations[i][Vw]);
                entertime[playerid] = gettime() + 5;
            }
            if(pickupid == accessPoints[i][1])
            {
                SetPlayerPos(playerid, ALocations[i][EntX], ALocations[i][EntY], ALocations[i][EntZ]);
                SetPlayerFacingAngle(playerid, ALocations[i][EntF]);
                SetPlayerInterior(playerid, 0);
                SetPlayerVirtualWorld(playerid, 0);
                entertime[playerid] = gettime() + 5;
            }
        }
        return 1;
    }
    return 1;
}

public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    for(new i; i < sizeof(ALocations); i++)
    {
        if(checkpointid == accessPoints[i][2])
        {
            ShopDialog(playerid);
        }
    }
    return 1;
}
Reply
#2

pawn Код:
for(new i; i < sizeof(ALocations); i++)
        {
            if(pickupid == accessPoints[i][0])
            {
                SetPlayerPos(playerid, ALocations[i][ExiX], ALocations[i][ExiY], ALocations[i][ExiZ]);
                SetPlayerFacingAngle(playerid, ALocations[i][ExiF]);
                SetPlayerInterior(playerid, ALocations[i][Interior]);
                SetPlayerVirtualWorld(playerid, ALocations[i][Vw]);
                entertime[playerid] = gettime() + 5;
            }
            if(pickupid == accessPoints[i][1])
            {
                SetPlayerPos(playerid, ALocations[i][EntX], ALocations[i][EntY], ALocations[i][EntZ]);
                SetPlayerFacingAngle(playerid, ALocations[i][EntF]);
                SetPlayerInterior(playerid, 0);
                SetPlayerVirtualWorld(playerid, 0);
                entertime[playerid] = gettime() + 5;
            }
I think the error lies in here. It looks like the same script is used for both cases.
Reply
#3

Quite possibly because you set the spawn location to the exact location of the pickup. This results in the player picking it up and the code to be executed again. You may want to use a function to slightly offset the spawn position. A variation of GetXYInFrontOfPlayer should work.
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
Quite possibly because you set the spawn location to the exact location of the pickup. This results in the player picking it up and the code to be executed again. You may want to use a function to slightly offset the spawn position. A variation of GetXYInFrontOfPlayer should work.
I'm using gettime to prevent them from being sent out again, this is not the issue if I understood you correctly =P


Quote:
Originally Posted by Aerotactics
Посмотреть сообщение
pawn Код:
for(new i; i < sizeof(ALocations); i++)
        {
            if(pickupid == accessPoints[i][0])
            {
                SetPlayerPos(playerid, ALocations[i][ExiX], ALocations[i][ExiY], ALocations[i][ExiZ]);
                SetPlayerFacingAngle(playerid, ALocations[i][ExiF]);
                SetPlayerInterior(playerid, ALocations[i][Interior]);
                SetPlayerVirtualWorld(playerid, ALocations[i][Vw]);
                entertime[playerid] = gettime() + 5;
            }
            if(pickupid == accessPoints[i][1])
            {
                SetPlayerPos(playerid, ALocations[i][EntX], ALocations[i][EntY], ALocations[i][EntZ]);
                SetPlayerFacingAngle(playerid, ALocations[i][EntF]);
                SetPlayerInterior(playerid, 0);
                SetPlayerVirtualWorld(playerid, 0);
                entertime[playerid] = gettime() + 5;
            }
I think the error lies in here. It looks like the same script is used for both cases.
It's different, notice EntX, EntY, EntZ and above is ExiX, ExiY & ExiZ
Reply
#5

So to me it feels like it's changing the value of accessPoints[i][] everytime and I have to restart the filterscript in order to get the right value or something?


Last location in the array is the only one that works too..
I'm clueless

Код:
printf("Entered pickupid: %d", pickupid);
Gives me pickupid 3 on enter and id 4 on exit..?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)