SA-MP Forums Archive
[HELP] Random tp to the prison cells - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] Random tp to the prison cells (/showthread.php?tid=525168)



[HELP] Random tp to the prison cells - Roei1998 - 10.07.2014

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?


Re: [HELP] Random tp to the prison cells - Threshold - 10.07.2014

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


Re: [HELP] Random tp to the prison cells - Luca12 - 10.07.2014

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]);



Re: [HELP] Random tp to the prison cells - Threshold - 10.07.2014

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..