SA-MP Forums Archive
[Ajuda] ajudem com spawn random / salvamento - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] ajudem com spawn random / salvamento (/showthread.php?tid=587312)



ajudem com spawn random / salvamento - DKDarkking - 29.08.2015

gente eu estou criando uma gamemode e ela tem sistema de spawn aleatorio e salvar posiзгo ex : quando o player morrer ele vai nascer em uma nova posiзгo porem quando o player morre ao invez de ir pra outro spawn ele vai pra mesma posiзгo que ele spawno antes.

spawns
PHP код:

new Float:RandomSpawns[35][4] =
{
    {
2939.3958,-606.1293,5.5778,94.7880},
    {-
77.6464,-1629.3710,3.7343,280.4382},
    {
206.3472,154.2905,2.3358,181.0434},
    {-
2817.3206,2727.3481,236.7029,262.8847},
    {-
2542.0942,1406.4088,5.9139,191.8668},
    {-
2917.7283,-889.0153,3.1419,316.8505},
    {-
2723.7112,-2428.6316,4.4273,288.1584},
    {
260.2506,2905.0747,7.1563,175.3873},
    {
2781.4458,604.3503,9.4818,20.5249},
    {
2153.9929,-112.0651,2.3084,13.7600},
    {-
339.2062,-444.5681,4.0358,102.4640},
    {
258.0997,2939.1514,1.7661,178.4244},
    {
1688.2180,-2731.7292,9.4693,180.6178},
    {
1688.2180,-2731.7292,9.4693,180.6178},
    {
129.5016,-1763.0736,5.4249,312.5323},
    {
220.3669,-233.3869,1.7786,42.7497},
    {
633.1784,-598.7915,16.3359,273.9685},
    {-
343.2381,1538.3112,80.4266,180.6176},
    {
1666.1603,1474.2776,10.7755,269.3152},
    {
2785.0378,710.2653,10.8912,115.5138},
    {-
1459.0962,2699.2815,55.8359,195.7046},
    {-
2387.5447,2215.6553,4.9844,88.8569},
    {-
2106.0325,167.3820,35.0691,321.0158},
    {-
2946.0522,974.2535,13.9277,258.6619},
    {-
2229.3057,-1743.5945,480.8813,222.0331},
    {-
2610.8232,-2729.7227,6.5595,289.7137},
    {-
955.2931,-2357.0247,60.9880,101.1086},
    {-
201.6451,-2263.7766,29.3455,311.3806},
    {
1125.8311,-2036.9128,69.8801,272.8402},
    {
2903.2417,-1930.4924,2.2940,89.2251},
    {
2918.8140,-726.6842,9.9818,87.4152},
    {-
1568.6575,-2729.0886,48.7435,63.0969},
    {-
71.0752,-1574.0936,2.6172,191.1192},
    {-
2053.7346,-2544.4180,31.0668,148.1078},
    {
2069.9150,-411.8249,110.5751,61.2491}
}; 
onplayerspawn
PHP код:

    
if(SpwRnd[playerid] == true)
    {
    new 
Random random(sizeof(SpwRnd));
    
SetPlayerPos(playeridRandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
    
SpwRnd[playerid] = false;
    } 
o sistema que salva a posiзгo e quando o player da spawn e teleportado
PHP код:
     SetPlayerSkin(playeridPlayerInfo[playerid][pSkin]);//Seta a Skin do player
     
SetPlayerPos(playeridPlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ]);
    
SetPlayerAttachedObject(playerid0ObjetoMochila_Pouch10.241894, -0.1609180.1814630900111); 



Re: ajudem com spawn random / salvamento - Nixtren - 29.08.2015

Tenta colocar o seguinte em OnPlayerDeath:
Код:
SpwRnd[playerid] = true; // Irб marcar o jogador para spawnar aleatуriamente



Re: ajudem com spawn random / salvamento - DKDarkking - 30.08.2015

Quote:
Originally Posted by Nixtren
Посмотреть сообщение
Tenta colocar o seguinte em OnPlayerDeath:
Код:
SpwRnd[playerid] = true; // Irб marcar o jogador para spawnar aleatуriamente
jб tб


Re: ajudem com spawn random / salvamento - Whoo - 30.08.2015

Vc coloco false dps de spawnar entao na proxima verificaзгo vai estar falso ai nao vai spawnar para uma posiзгo aleatуria


Re: ajudem com spawn random / salvamento - DKDarkking - 30.08.2015

Quote:
Originally Posted by Whoo
Посмотреть сообщение
Vc coloco false dps de spawnar entao na proxima verificaзгo vai estar falso ai nao vai spawnar para uma posiзгo aleatуria
jб arrumei isso :v


Re: ajudem com spawn random / salvamento - [BOPE]Seu._.Madruga - 30.08.2015

Espero ter ajudado.
PHP код:
new Float:RealPosition[MAX_PLAYERS][3]; 
PHP код:
public OnPlayerSpawn(playerid)
{
    if(
SpwRnd[playerid] == true)
    {
        new 
Random random(sizeof(SpwRnd));
        
SetPlayerPos(playeridRandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
        
RealPosition[playerid][0] = RandomSpawns[Random][0];
        
RealPosition[playerid][1] = RandomSpawns[Random][1];
        
RealPosition[playerid][2] = RandomSpawns[Random][2];
        
SpwRnd[playerid] = false;
    }
    return 
1;

PHP код:
SetPlayerSkin(playeridPlayerInfo[playerid][pSkin]);//Seta a Skin do player
SetPlayerPos(playeridRealPosition[playerid][0], RealPosition[playerid][0], RealPosition[playerid][0]);
SetPlayerAttachedObject(playerid0ObjetoMochila_Pouch10.241894, -0.1609180.1814630900111); 



Re: ajudem com spawn random / salvamento - MultiKill - 30.08.2015

Quote:
Originally Posted by [BOPE]Seu._.Madruga
Посмотреть сообщение
PHP код:
public OnPlayerSpawn(playerid)
{
    if(
SpwRnd[playerid] == true)
    {
        new 
Random random(sizeof(SpwRnd));
        
SetPlayerPos(playeridRandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
        
RealPosition[playerid][0] = RandomSpawns[Random][0];
        
RealPosition[playerid][1] = RandomSpawns[Random][1];
        
RealPosition[playerid][2] = RandomSpawns[Random][2];
        
SpwRnd[playerid] = false;
    }
    return 
1;

A coordenadas que ele vai ser teleportado quando SpwRnd for igual a true, nгo vai ser a mesma que vai ser amazenado no RealPosition depois que ele for teleportado.

Cуdigo corrigido:
PHP код:
public OnPlayerSpawn(playerid)
{
    if(
SpwRnd[playerid] == true)
    {
        new 
Random random(sizeof(SpwRnd));
        
RealPosition[playerid][0] = RandomSpawns[Random][0];
        
RealPosition[playerid][1] = RandomSpawns[Random][1];
        
RealPosition[playerid][2] = RandomSpawns[Random][2];
        
SetPlayerPos(playeridRealPosition[playerid][0], RealPosition[playerid][1], RealPosition[playerid][Random][2]);
        
SpwRnd[playerid] = false;
    }
    return 
1;




Re: ajudem com spawn random / salvamento - DKDarkking - 30.08.2015

Quote:
Originally Posted by MultiKill
Посмотреть сообщение
A coordenadas que ele vai ser teleportado quando SpwRnd for igual a true, nгo vai ser a mesma que vai ser amazenado no RealPosition depois que ele for teleportado.

Cуdigo corrigido:
PHP код:
public OnPlayerSpawn(playerid)
{
    if(
SpwRnd[playerid] == true)
    {
        new 
Random random(sizeof(SpwRnd));
        
RealPosition[playerid][0] = RandomSpawns[Random][0];
        
RealPosition[playerid][1] = RandomSpawns[Random][1];
        
RealPosition[playerid][2] = RandomSpawns[Random][2];
        
SetPlayerPos(playeridRealPosition[playerid][0], RealPosition[playerid][1], RealPosition[playerid][Random][2]);
        
SpwRnd[playerid] = false;
    }
    return 
1;

PHP код:
C:\Users\Jefferson\Desktop\******.pwn(345) : error 001expected token","but found "["
C:\Users\Jefferson\Desktop\******.pwn(345) : error 029invalid expressionassumed zero
C
:\Users\Jefferson\Desktop\******.pwn(345) : warning 215expression has no effect
C
:\Users\Jefferson\Desktop\******.pwn(345) : error 001expected token";"but found "]"
C:\Users\Jefferson\Desktop\******.pwn(345) : fatal error 107too many error messages on one line
Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
4 Errors

linha : SetPlayerPos(playerid, RealPosition[playerid][0], RealPosition[playerid][1], RealPosition[playerid][Random][2])


Re: ajudem com spawn random / salvamento - MultiKill - 30.08.2015

Quote:
Originally Posted by DKDarkking
Посмотреть сообщение
PHP код:
C:\Users\Jefferson\Desktop\******.pwn(345) : error 001expected token","but found "["
C:\Users\Jefferson\Desktop\******.pwn(345) : error 029invalid expressionassumed zero
C
:\Users\Jefferson\Desktop\******.pwn(345) : warning 215expression has no effect
C
:\Users\Jefferson\Desktop\******.pwn(345) : error 001expected token";"but found "]"
C:\Users\Jefferson\Desktop\******.pwn(345) : fatal error 107too many error messages on one line
Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
4 Errors

linha : SetPlayerPos(playerid, RealPosition[playerid][0], RealPosition[playerid][1], RealPosition[playerid][Random][2])
Esqueci do [Random]:


PHP код:
SetPlayerPos(playeridRealPosition[playerid][0], RealPosition[playerid][1], RealPosition[playerid][2]);