[HELP] Random tp to the prison cells
#1

Hi,
I have a problem with the prison cells.
Код:
new Float:PrisonCells[][0] =
{
    {146.641326,1086.450805,523.917419}, // Cell ID 0
	{143.410385,1086.557373,523.917419}, // Cell ID 1
	{140.075027,1086.834594,523.917419}, // Cell ID 2
	{125.594047,1086.595458,523.917419}, // Cell ID 3
	{122.502304,1086.180175,523.911437}, // Cell ID 4
	{119.788101,1086.267700,523.911437} // Cell ID 5
};
I tried to do this:
Код:
new id = random(sizeof(PrisonCells));
SetPlayerPos(playerid, PrisonCells[id][1],PrisonCells[id][2],PrisonCells[id][3],PrisonCells[id][4],PrisonCells[id][5]);
It didn't work.
What is the correctly syntax of this?
Reply
#2

pawn Код:
new Float:PrisonCells[6][3] =
{
    {146.641326, 1086.450805, 523.917419}// Cell ID 0
    {143.410385, 1086.557373, 523.917419}// Cell ID 1
    {140.075027, 1086.834594, 523.917419}// Cell ID 2
    {125.594047, 1086.595458, 523.917419}// Cell ID 3
    {122.502304, 1086.180175, 523.911437}// Cell ID 4
    {119.788101, 1086.267700, 523.911437}   // Cell ID 5
};

new id = random(sizeof(PrisonCells));
SetPlayerPos(playerid, PrisonCells[id][0], PrisonCells[id][1],PrisonCells[id][2]);
--

This part was wrong:
pawn Код:
new Float:PrisonCells[][0] =
--

I suggest you read a bit more about 'arrays' and how they're structured.
https://sampforum.blast.hk/showthread.php?tid=318212
Reply
#3

this should work fine

pawn Код:
new rand = random(sizeof(PrisonCells));
        SetPlayerPos_H(playerid,PrisonCells[rand][0],PrisonCells[rand][1],PrisonCells[rand][2],PrisonCells[rand][3],PrisonCells[rand][4]);
Reply
#4

Quote:
Originally Posted by Luca12
Посмотреть сообщение
this should work fine

pawn Код:
new rand = random(sizeof(PrisonCells));
        SetPlayerPos_H(playerid,PrisonCells[rand][0],PrisonCells[rand][1],PrisonCells[rand][2],PrisonCells[rand][3],PrisonCells[rand][4]);
No.

Remind me, what is 'SetPlayerPos_H'?
The array does not have a 4th element.
SetPlayerPos only uses 4 parameters, not 5.
Код:
(playerid, Float:x, Float:y, Float:z)
So yeah..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)