Pickup/teleport array not working
#1

This is a code to place pickups for every 24/7, ammunition and clothes shop in east LV (along with CH,PD,Hospital,Airport).

My problem is that when I enter any of the pickups, I am teleported to the last set of co ordinates in the array (lveastzipOUT) instead of the co ordinates which correspond to the pickup (to the 'inside' of the stores)

Can anybody figure out why this isn't working? I've been trying to figure it out for days, tried every method I can think of using to list the pickups/teleports and ive re-created the code using just about every tutorial I can find on the forums with no luck

(I am aware that I have not set the interiors and virtual worlds in the array, but the problem persists even with the correct interiors/virtualworlds added)

Код:
// includes
#include <a_samp> 
#include <streamer> 
#include <sscanf2>

// defines
#define MAX_PICKUP 40
#define INVALID_PICKUP_ID	-1

new EnterPickup[5] = {INVALID_PICKUP_ID, ...}; // value of this array is {-1, ...}


enum ePickup
{
    pObj,
    Float: Pos[3],
    Float: tPos[3], 
    Interior,
    VirtualWorld,
    Label[40], 
};
new const gPickup[MAX_PICKUP][ePickup] =  
{
    {19198, {2413.1326,1123.7681,10.8203},{382.5162,173.8144,1008.3828}, 3, 1, "City Hall"}, // lvchIN
    {19198, {389.6851,173.7902,1008.3828},{2417.8792,1123.6888,10.8203}, 0, 0, "Exit"}, // lvchOUT
    {19198, {238.6472,138.7112,1003.0234},{382.5162,173.8144,1008.3828}, 0, 0, "Police Department"}, // LVPDIN
    {19198, {2287.0774,2432.1848,10.8203},{2286.9553,2428.7073,10.8203}, 0, 0, "Exit"}, // LVPDOUT
    {19198, {0,0,0}, {0,0,0}, 0, 0, "Airport"}, // LVaIN /// add map
    {19198, {1672.8890,1447.8660,10.7871},{1678.4150,1447.0847,10.7751}, 0, 0, "Exit"}, // LVaOUT
    {19198, {02018.9423,1017.8262,996.8750},{2014.4329,1017.8450,996.2214}, 0, 0, "Four Dragons Casino"}, // fourdIN
    {19198, {2019.7300,1007.7938,10.8203},{2024.7816,1007.7968,10.8203}, 0, 0, "Exit"}, // fourdOUT
    {19198, {2233.9539,1714.5076,1012.3828},{2234.2778,1710.7727,1011.3120}, 0, 0, "Calligulas Casino"}, // calgIN
    {19198, {2196.6274,1677.1100,12.3672}, {2192.7361,1677.5398,12.3672}, 0, 0, "Exit"}, // calgOUT
    {19198, {0,0,0},{2417.8792,1123.6888,10.8203}, 0, 0, "Pirate Casino"}, /////MAP NEEDED // piratIN
    {19198, {1965.0487,1623.2053,12.8621},{1971.3026,1623.0610,12.8631}, 0, 0, "Exit"}, // piratOUT
    {19198, {1133.1388,-15.4690,1000.6797},{2417.8792,1123.6888,10.8203}, 0, 0, "Redsands Casino"}, // rseIN
    {19198, {1672.8890,1447.8660,10.7871},{382.5162,173.8144,1008.3828}, 0, 0, "Exit"}, // rseOUT
    {19198, {296.8087,-112.0694,1001.5156},{2417.8792,1123.6888,10.8203}, 0, 0, "Ammunation"}, // nelvamIN
    {19198, {2539.5422,2083.9460,10.8203},{2417.8792,1123.6888,10.8203}, 0, 0, "Exit"}, // 1nelvamOUT
    {19198, {296.8087,-112.0694,1001.5156},{382.5162,173.8144,1008.3828}, 0, 0, "Ammunation"}, // selvamIN
    {19198, {2155.0784,944.8185,10.8203},{2635.6113,1126.7527,11.1759}, 0, 0, "Exit"}, // selvamOUT
    {19198, {-27.3612,-58.2661,1003.5469}, {-26.8388,-56.6087,1003.5469}, 0, 0, "24/7"}, // selv24IN
    {19198, {2117.4941,896.7758,11.179}, {2635.6113,1126.7527,11.1759}, 0, 0, "Exit"}, // selv24OUT
    {19198, {-27.3612,-58.2661,1003.5469}, {-26.8388,-56.6087,1003.5469}, 0, 0, "24/7"}, // strip24IN
    {19198, {22194.9412,1991.0132,12.2969}, {2191.9456,1991.6254,12.0646}, 0, 0, "Exit"}, // strip24OUT
    {19198, {-27.3612,-58.2661,1003.5469}, {-26.8388,-56.6087,1003.5469}, 0, 0, "24/7"}, // roca24IN
    {19198, {2247.6245,2396.1694,10.8203}, {2248.3381,2398.9131,10.8203}, 0, 0, "Exit"}, // roca24OUT
    {19198, {-27.3612,-58.2661,1003.5469}, {-26.8388,-56.6087,1003.5469}, 0, 0, "24/7"}, // roca24xIN
    {19198, {2187.7112,2469.6611,11.2422}, {2190.2107,2468.5369,11.2422}, 0, 0, "Exit"}, // roca24xOUT
    {19198, {-27.3612,-58.2661,1003.5469}, {-26.8388,-56.6087,1003.5469}, 0, 0, "24/7"}, // 1rseast24IN
    {19198, {1937.8263,2307.2637,10.8203}, {1935.3301,2307.0039,10.8203}, 0, 0, "sExit"}, // rseast24OUT
    {19198, {-27.3612,-58.2661,1003.5469}, {-26.8388,-56.6087,1003.5469}, 0, 0, "24/7"}, // eastlv24IN
    {19198, {2546.5208,1972.6559,10.8203}, {2542.3298,1970.0658,10.8203}, 0, 0, "Exit"}, // eastlv24OUT
    {19198, {0,0,0}, {2417.8792,1123.6888,10.8203}, 0, 0, "Hospital"}, /////add map/// lvhospIN
    {19198, {1607.3708,1815.6986,10.8203}, {1607.4255,1821.0288,10.8280}, 0, 0, "Exit"}, // lvhospOUT
    {19198, {207.6413,-111.2668,1005.1328}, {382.5162,173.8144,1008.3828}, 0, 0, "Binco"}, // stripbincIN
    {19198, {2101.8923,2257.4243,11.0234}, {2104.2490,2257.2930,11.0234}, 0, 0, "Exit"}, // stripbincOUT
    {19198, {161.3928,-97.1082,1001.8047}, {161.4176,-93.1467,1001.8047}, 0, 0, "ZIP"}, // stripzipIN
    {19198, {2090.4836,2224.6982,11.0234}, {2083.5105,2222.1904,10.8203}, 0, 0, "Exit"}, // stripzipOUT
    {19198, {207.6413,-111.2668,1005.1328}, {382.5162,173.8144,1008.3828}, 0, 0, "Binco"}, // airpbincoIN
    {19198, {1657.0372,1733.3311,10.8281}, {1654.2834,1733.2018,10.8203}, 0, 0, "Exit"}, // airpbincoOUT
    {19198, {161.3928,-97.1082,1001.8047}, {161.4176,-93.1467,1001.8047}, 0, 0, "ZIP"}, // lveastzipIN
    {19198, {2572.0786,1904.9449,11.0234}, {2571.4175,1902.0344,11.0234}, 0, 0, "Exit"}, // lveastzipOUT

};


public OnFilterScriptInit()
{
       for(new i; i < MAX_PICKUP; i ++) 
    {
        gPickup[i][Pickup] = CreateDynamicPickup(gPickup[i][pObj], 1, gPickup[i][Pos][0], gPickup[i][Pos][1], gPickup[i][Pos][2], .streamdistance = 100.0); // creates all the pickup with one line, no need to extra work!
    }
    return 1;
}

public OnFilterScriptExit() 
{    for(new i; i < MAX_PICKUP; i ++) 
    {
        DestroyDynamicPickup(gPickup[i][Pickup]);
    }
    return 1;
}

public OnPlayerPickUpDynamicPickup(playerid, pickupid) {
    for(new i; i < MAX_PICKUP; i ++) // this is a loop
	{
        SetPlayerPos(playerid, gPickup[i][tPos][0], gPickup[i][tPos][1], gPickup[i][tPos][2] + 0.5); // sets player pos
        SetPlayerInterior(playerid, gPickup[i][Interior]);
        SetPlayerVirtualWorld(playerid, gPickup[i][VirtualWorld]);

    }
    return 1;
}
Reply
#2

You must stop the loop, use break; after virtualworld
Reply
#3

I added the break; but now it breaks the loop after the first line/teleport and every pickup is teleporting me to the FIRST set of tele co ords on the list (lvchIN)


Is this what you meant?
Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid){
    for(new i; i < MAX_PICKUP; i++) 
    {
        SetPlayerPos(playerid, gPickup[i][tPos][0], gPickup[i][tPos][1], gPickup[i][tPos][2] + 0.5); // sets player pos
        SetPlayerInterior(playerid, gPickup[i][Interior]);
        SetPlayerVirtualWorld(playerid, gPickup[i][VirtualWorld]);
        break;
    }
    return 1;
Reply
#4

This should work:
Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    for(new i; i < MAX_PICKUP; i ++) // this is a loop
    {
	    if(pickupid == gPickup[i][Pickup])
	    {
	        SetPlayerPos(playerid, gPickup[i][tPos][0], gPickup[i][tPos][1], gPickup[i][tPos][2] + 0.5); // sets player pos
	        SetPlayerInterior(playerid, gPickup[i][Interior]);
	        SetPlayerVirtualWorld(playerid, gPickup[i][VirtualWorld]);
	        break;
     	    }
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Daveosss
Посмотреть сообщение
This should work:
Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    for(new i; i < MAX_PICKUP; i ++) // this is a loop
    {
	    if(pickupid == gPickup[i][Pickup])
	    {
	        SetPlayerPos(playerid, gPickup[i][tPos][0], gPickup[i][tPos][1], gPickup[i][tPos][2] + 0.5); // sets player pos
	        SetPlayerInterior(playerid, gPickup[i][Interior]);
	        SetPlayerVirtualWorld(playerid, gPickup[i][VirtualWorld]);
	        break;
     	    }
    }
    return 1;
}
That did the trick. Completely forgot about putting the if statement

thank you very much!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)