SA-MP Forums Archive
anti 2 spawns - 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: anti 2 spawns (/showthread.php?tid=549338)



anti 2 spawns - _Application_ - 06.12.2014

There is a chance, more than one player, teleports to the same place:
I want to block it, and allow each player to teleport one

( sorry my bad english )

PHP код:
new Float:Mini_Spawns[][] ={
    {
2504.04032752.658410.8203277.4510},
    {
2501.92412786.630110.8203280.2944},
    {
2502.42292823.024910.8203271.8576},
    {
2530.31352825.276110.8203343.9250},
    {
2542.36992842.705814.2559233.0039},
    {
2566.89672845.739714.2559168.4566},
    {
2615.51882848.589410.8203165.5162},
    {
2613.98052807.553010.820335.2887},
    {
2575.25782838.754919.9922180.8019},
    {
2556.95092813.404319.9922276.6828},
    {
2589.87262806.318619.992233.1235},
    {
2608.66192824.738519.992266.7710},
    {
2576.06012696.953928.1406291.5832},
    {
2579.11742712.568128.1953266.1107},
    {
2616.18582717.827436.5386264.6547},
    {
2625.75292735.057936.1918346.7751},
    {
2618.92972748.126026.7127340.5084},
    {
2637.22242769.240725.8222186.6836}
}; 
PHP код:
    for(new iCountiCount MAX_PLAYERSiCount++) if(IsPlayerConnected(iCount) && pInActivity[iCount])
                        {
                            new 
rand random(sizeof(Mini_Spawns));
                            
SetPlayerPos(iCountMini_Spawns[rand][0], Mini_Spawns[rand][1], Mini_Spawns[rand][2]);
                            
SetPlayerFacingAngle(iCountMini_Spawns[rand][3]);




Re: anti 2 spawns - Raweresh - 06.12.2014

Declare global variable:
Код:
new LastSpawn = -1;
And do something like that, should works.
Код:
loop_start:
new rand = random(sizeof(Mini_Spawns));
if(LastSpawn == rand) goto loop_start;
SetPlayerPos(iCount, Mini_Spawns[rand][0], Mini_Spawns[rand][1], Mini_Spawns[rand][2]);
SetPlayerFacingAngle(iCount, Mini_Spawns[rand][3]);



Re: anti 2 spawns - _Application_ - 06.12.2014

Quote:
Originally Posted by Raweresh
Посмотреть сообщение
Declare global variable:
Код:
new LastSpawn = -1;
And do something like that, should works.
Код:
loop_start:
new rand = random(sizeof(Mini_Spawns));
if(LastSpawn == rand) goto loop_start;
SetPlayerPos(iCount, Mini_Spawns[rand][0], Mini_Spawns[rand][1], Mini_Spawns[rand][2]);
SetPlayerFacingAngle(iCount, Mini_Spawns[rand][3]);
I do not know how to fix what you did here

Please send me a working code


Do you think it will work?
->>

PHP код:
    for(new iCountiCount MAX_PLAYERSiCount++) if(IsPlayerConnected(iCount) && pInActivity[iCount])
                        {
                            
loop_start:
                            new 
rand random(sizeof(Mini_Spawns));
                            if(
LastSpawn == rand) goto loop_start;
                            
LastSpawn rand;
                            
SetPlayerPos(iCountMini_Spawns[rand][0], Mini_Spawns[rand][1], Mini_Spawns[rand][2]);
                            
SetPlayerFacingAngle(iCountMini_Spawns[rand][3]);
                        } 



Re: anti 2 spawns - Raweresh - 06.12.2014

Yes, just try it.


Re: anti 2 spawns - _Application_ - 06.12.2014

Quote:
Originally Posted by Raweresh
Посмотреть сообщение
Yes, just try it.
I want to be sure


Re: anti 2 spawns - Raweresh - 06.12.2014

I'm sure it's if-goto loop, read about it at wiki.
https://sampwiki.blast.hk/wiki/Control_Structures#if-goto


Re: anti 2 spawns - _Application_ - 06.12.2014

Quote:
Originally Posted by Raweresh
Посмотреть сообщение
I'm sure it's if-goto loop, read about it at wiki.
https://sampwiki.blast.hk/wiki/Control_Structures#if-goto
PHP код:
    for(new iCountiCount MAX_PLAYERSiCount++) if(IsPlayerConnected(iCount) && pInActivity[iCount]) 
                        { 
                            
loop_start
                            new 
rand random(sizeof(Mini_Spawns)); 
                            if(
LastSpawn == rand) goto loop_start
                            
LastSpawn rand
                            
SetPlayerPos(iCountMini_Spawns[rand][0], Mini_Spawns[rand][1], Mini_Spawns[rand][2]); 
                            
SetPlayerFacingAngle(iCountMini_Spawns[rand][3]); 
                        } 
Note that I did it in the loop

It works this way?


Re: anti 2 spawns - Raweresh - 06.12.2014

Yes, it will work.