open.mp forum
[Pawn] Help with enter and exiting an interior - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] Help with enter and exiting an interior (/showthread.php?tid=2143)



Help with enter and exiting an interior - XDK6 - 2021-06-28

Hello Burgershot Community,



I have a problem with my 3dtext label and exiting a property on my script. Whenever I exit the property it tp me to the first 24/7 store that I created instead of the new one.



here is the code I use on creating a property system with printing the ids on 3d text label



variables and enums:



Code:
#define MAX_STORES 500



enum sInfo

{

sID,

sType,

Text3D:sLabel,

sName[50],

sMapIcon,

sPickup,

Float:sX,

Float:sY,

Float:sZ,

sInt,

sVirt,

Float:intsX,

Float:intsY,

Float:intsZ,

sintInt,

sintVirt,

bool:sIDUsed

};



new storeinfo[MAX_STORES][sInfo];

new TotalStores;



Code for creating the store

Code:
createstore(storeid, type, Float:X, Float:Y, Float:Z, Float:IntX, Float:IntY, Float:IntZ, intInt, intVirt)

{

TotalStores;

storeinfo[storeid][sID] = storeid;

storeinfo[storeid][sX] = X;

storeinfo[storeid][sY] = Y;

storeinfo[storeid][sZ] = Z;

storeinfo[storeid][sInt] = 0;

storeinfo[storeid][sVirt] = 0;

storeinfo[storeid][intsX] = IntX;

storeinfo[storeid][intsY] = IntY;

storeinfo[storeid][intsZ] = IntZ;

storeinfo[storeid][sintInt] = intInt;

storeinfo[storeid][sintVirt] = intVirt;

intVirt = storeinfo[storeid][sID];

storeinfo[storeid][sIDUsed] = true;



storeinfo[storeid][sPickup] = CreateDynamicPickup(1272, 1, storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 0);



storeinfo[storeid][sType] = type;

new string2[128];

if(storeinfo[storeid][sType] == 1)

{

format(string2, sizeof(string2), "24/7 (ID:%d)", storeinfo[storeid][sName], storeinfo[storeid][sID]);

? ? ? ? storeinfo[storeid][sLabel] = Create3DTextLabel(string2, -1, storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 30.0, storeinfo[storeid][sVirt]);

for(new i = 0; i < MAX_PLAYERS; i)

? ? {

storeinfo[storeid][sMapIcon] = CreateDynamicMapIcon(storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 17, 1, 0, 0, i, 300, MAPICON_LOCAL);

}

}

if(storeinfo[storeid][sType] == 2)

{

format(string2, sizeof(string2), "Burgershot (ID:%d)", storeinfo[storeid][sName], storeinfo[storeid][sID]);

? ? ? ? storeinfo[storeid][sLabel] = Create3DTextLabel(string2, -1, storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 30.0, storeinfo[storeid][sVirt]);

for(new i = 0; i < MAX_PLAYERS; i)

? ? {

storeinfo[storeid][sMapIcon] = CreateDynamicMapIcon(storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 10, 1, 0, 0, i, 300, MAPICON_LOCAL);

}

}

if(storeinfo[storeid][sType] == 3)

{

format(string2, sizeof(string2), "Cluckin Bell (ID:%d)", storeinfo[storeid][sName], storeinfo[storeid][sID]);

? ? ? ? storeinfo[storeid][sLabel] = Create3DTextLabel(string2, -1, storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 30.0, storeinfo[storeid][sVirt]);

for(new i = 0; i < MAX_PLAYERS; i)

? ? {

storeinfo[storeid][sMapIcon] = CreateDynamicMapIcon(storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 14, 1, 0, 0, i, 300, MAPICON_LOCAL);

}

}

if(storeinfo[storeid][sType] == 4)

{

format(string2, sizeof(string2), "Well Stacked Pizza Co. (ID:%d)", storeinfo[storeid][sName], storeinfo[storeid][sID]);

? ? ? ? storeinfo[storeid][sLabel] = Create3DTextLabel(string2, -1, storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 30.0, storeinfo[storeid][sVirt]);

for(new i = 0; i < MAX_PLAYERS; i)

? ? {

storeinfo[storeid][sMapIcon] = CreateDynamicMapIcon(storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 29, 1, 0, 0, i, 300, MAPICON_LOCAL);

}

}

if(storeinfo[storeid][sType] == 5)

{

format(string2, sizeof(string2), "Binco (ID:%d)", storeinfo[storeid][sName], storeinfo[storeid][sID]);

? ? ? ? storeinfo[storeid][sLabel] = Create3DTextLabel(string2, -1, storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 30.0, storeinfo[storeid][sVirt]);

for(new i = 0; i < MAX_PLAYERS; i)

? ? {

storeinfo[storeid][sMapIcon] = CreateDynamicMapIcon(storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 45, 1, 0, 0, i, 300, MAPICON_LOCAL);

}

}

if(storeinfo[storeid][sType] == 6)

{

format(string2, sizeof(string2), "Zip (ID:%d)", storeinfo[storeid][sName], storeinfo[storeid][sID]);

? ? ? ? storeinfo[storeid][sLabel] = Create3DTextLabel(string2, -1, storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 30.0, storeinfo[storeid][sVirt]);

for(new i = 0; i < MAX_PLAYERS; i)

? ? {

storeinfo[storeid][sMapIcon] = CreateDynamicMapIcon(storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 45, 1, 0, 0, i, 300, MAPICON_LOCAL);

}

}

if(storeinfo[storeid][sType] == 7)

{

format(string2, sizeof(string2), "Pro-Laps (ID:%d)", storeinfo[storeid][sName], storeinfo[storeid][sID]);

storeinfo[storeid][sLabel] = Create3DTextLabel(string2, -1, storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 30.0, storeinfo[storeid][sVirt]);

for(new i = 0; i < MAX_PLAYERS; i)

? ? {

storeinfo[storeid][sMapIcon] = CreateDynamicMapIcon(storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 45, 1, 0, 0, i, 300, MAPICON_LOCAL);

}

}

if(storeinfo[storeid][sType] == 8)

{

format(string2, sizeof(string2), "Suburban (ID:%d)", storeinfo[storeid][sName], storeinfo[storeid][sID]);

storeinfo[storeid][sLabel] = Create3DTextLabel(string2, -1, storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 30.0, storeinfo[storeid][sVirt]);

for(new i = 0; i < MAX_PLAYERS; i)

? ? {

storeinfo[storeid][sMapIcon] = CreateDynamicMapIcon(storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 45, 1, 0, 0, i, 300, MAPICON_LOCAL);

}

}

if(storeinfo[storeid][sType] == 9)

{

format(string2, sizeof(string2), "Didier Sachs (ID:%d)", storeinfo[storeid][sName], storeinfo[storeid][sID]);

? ? ? ? storeinfo[storeid][sLabel] = Create3DTextLabel(string2, -1, storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 30.0, storeinfo[storeid][sVirt]);

for(new i = 0; i < MAX_PLAYERS; i)

? ? {

storeinfo[storeid][sMapIcon] = CreateDynamicMapIcon(storeinfo[storeid][sX], storeinfo[storeid][sY], storeinfo[storeid][sZ], 45, 1, 0, 0, i, 300, MAPICON_LOCAL);

}

}

new string[128];

format(string, sizeof(string), "Store ID: %d has been created. Total Stores: %d", storeid, TotalStores);

printf(string);

}



Enter and Exit code:



Code:
stock SendPlayerInsideStore(playerid, storeid)

{

if(storeid == MAX_STORES) return 0;

new Float:X = storeinfo[storeid][intsX], Float:Y = storeinfo[storeid][intsY], Float:Z = storeinfo[storeid][intsZ], Int = storeinfo[storeid][sintInt], Virt = storeinfo[storeid][sID];

SetPlayerPos(playerid, X, Y, Z);

SetPlayerInterior(playerid, Int);

SetPlayerVirtualWorld(playerid, Virt);

return 1;

}



stock SendPlayerOutsideStore(playerid, storeid)

{

if(storeid != MAX_STORES)

{

? ? ? ? new Float:X = storeinfo[storeid][sX], Float:Y = storeinfo[storeid][sY], Float:Z = storeinfo[storeid][sZ], Int = storeinfo[storeid][sInt];

SetPlayerPos(playerid, X, Y, Z);

SetPlayerInterior(playerid, Int);

SetPlayerVirtualWorld(playerid, 0);

}

else return 0;

return 1;

}