4 jail's random - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: 4 jail's random (
/showthread.php?tid=110483)
4 jail's random -
Mechscape - 26.11.2009
I have 4 jail's player poisition.
Its at SFPD interior and see there's 4 jail's.
But how i do make it takes player to 4 random jail's?
Police ---> /arrest [PLAYER] ---> PLAYER take'n to random (Takes one jail and he jailed in to or what ever)
[1 JAIL] [2 JAIL] [3 JAIL] [4 JAIL]
....^........^..........^..........^
System takes one jail then player will be into jail. Like 4 jail's random.
sorry for bad english.
Re: 4 jail's random -
ExoSanty - 26.11.2009
pretty much explains it:
https://sampwiki.blast.hk/wiki/Random
Re: 4 jail's random -
Mechscape - 26.11.2009
I didn't see, thanks.
Re: 4 jail's random -
Mechscape - 26.11.2009
Sorry, i need learn that random.
Код:
new Float:ArrestJail[4][1] = {
{-2796.9854, 1224.8180, 20.5429},
{-2454.2170, 503.8759, 30.0790},
{-2669.7322, -6.0874, 6.1328},
{345.2434, 23423.324234, 3432.3242}
}
Код:
suxxer = random(sizeof(ArrestJail));
SetPlayerPos(suspect, ArrestJail[suxxer][0], ArrestJail[suxxer][1], ArrestJail[suxxer][2], 0.0);
What mean is:
Код:
ArrestJail[suxxer][0]
Код:
ArrestJail[suxxer][1]
Код:
ArrestJail[suxxer][2]
And what is "[4][1] = {" ?
Код:
new Float:ArrestJail[4][1] = {
Re: 4 jail's random -
ExoSanty - 26.11.2009
you would need:
Код:
new Float:ArrestJail[4][1] = {
first [4] is the number of 'rows' (array's), the second [1] is the kind of numbers of fields per 'row'.
so it could be something like that:
Код:
new Float:ArrestJail[4][3] = {
{-2796.9854, 1224.8180, 20.5429},
{-2454.2170, 503.8759, 30.0790},
{-2669.7322, -6.0874, 6.1328},
{345.2434, 23423.324234, 3432.3242}
};
Код:
new rand = random(sizeof(ArrestJail)); //or suxxer ... ? :p
SetPlayerPos(playerid, ArrestJail[rand][0], ArrestJail[rand][1], ArrestJail[rand][2] ); //you set 'suspect' here instead of playerid, if suspect is defined as the playerid then you can use that, depends on where you calling this
//maybe a facing angle:
SetPlayerFacingAngle(playerid, 250); // you can set facing angle by adding a 4th 'field' in arrestjail... and call ArrestJail[rand][4] instead of 250...
Re: 4 jail's random -
Mechscape - 26.11.2009
Thanks for helping
Re: 4 jail's random -
ExoSanty - 26.11.2009
sorry, corrected it: ArrestJail[rand][3] removed and forgot a ; after the float arrestjail...