Teleport
#1

Hi, I made little derby system and i want to know how to do this:
if players variable "derbyplace" is 1 then teleport player on first coordinates, if derbyplace is 2 then on second...
I don't know how should i use "SetPlayerPos(playerid, d2[0][1],d2[0][2],d2[0][3]);" for the first one?? or what?
Код:
new Float:d2[][] =
{
    {1434.7871,-1765.2822,33.4297,270.7333},
    {1526.8738,-1765.1311,33.4297,86.1782},
    {1547.0848,-1795.5977,33.4243,358.7808},
    {1495.6282,-1816.4321,33.4243,84.9483}
};
Reply
#2

pawn Код:
SetPlayerPos(playerid, d2[0][1],d2[0][2],d2[0][3]); //for the 1
SetPlayerPos(playerid, d2[1][1],d2[1][2],d2[1][3]); // for 2 and so on
Reply
#3

I'd like to point out that the index starts from 0 so it would be: d2[0][0], d2[0][1], d2[0][2]
Index 3 is out of bounds.

You can use another array with the size of d2 so you can know which position is taken and move on:
pawn Код:
new bool: d2_available[sizeof (d2)];
pawn Код:
for (new j; j != sizeof (d2_available); ++j)
{
    if (d2_available[j]) continue;
   
    d2_available[j] = true;
    SetPlayerPos(playerid, d2[j][0],d2[j][1],d2[j][2]);
    break;
}
Reply
#4

Konstantinos this works, but now every player on derby is spawned on x=d2[0][0] y=d2[0][1] z=d2[0][2]
Код:
if(derbycount  > 1)
{
derbyon = 1;
SetTimer("derbystart", 3000, 0);
for(new i=0; i < MAX_PLAYERS; i++)
{
if(derby[i] == 88)
{
for (new j; j != sizeof (derbyspawns3_available); ++j)
{
    if (derbyspawns3_available[j]) continue;
    GameTextForPlayer(i, "3", 1000, 6);
    SetTimerEx("tri", 1000, 0, "i", i);
    derbyspawns3_available[j] = true;
    new veh = CreateVehicle(541,0,0,0, derbyspawns3[0][3],-1,-1,-1);
	SetVehiclePos(veh, derbyspawns3[0][0], derbyspawns3[0][1],derbyspawns3[0][2]);
	SetPlayerVirtualWorld(i, 8888);
	SetVehicleVirtualWorld(veh, 8888);
	PutPlayerInVehicle(i,veh,0);
	TogglePlayerControllable(i, 0);
	derbyfall[i] = 0;
	dsp[i] = 0;
	SetCameraBehindPlayer(i);
	isalive[i] =1;
    break;
}}}
}
Reply
#5

Because you set it for the first index (0):
pawn Код:
SetVehiclePos(veh, derbyspawns3[0][0], derbyspawns3[0][1],derbyspawns3[0][2]);
It should be:
pawn Код:
SetVehiclePos(veh, derbyspawns3[j][0], derbyspawns3[j][1],derbyspawns3[j][2]);
and keep in mind that if the second dimension is 3 in derbyspawns3 array, then the valid indexes are between 0 and 2 so the 3 as angle will be out of bounds unless the size is 4 or none specified.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)