[Ajuda] Criar varias plantaзхes
#1

Salve galera, estou criando um sistema de plantaзгo de maconha do 0 e queria fazer uma coisa mas nгo tenho ideia de como fazer. Й tipo assim vai ter vбrios ID's de plantaзгo, ID: 1, ID: 2... e assim por diante. Consegui criar a ID: 1 mas queria criar uma do lado da outra alguйm tem ideia de como faзo isso? Eu queria que ficasse assim: ID: 1 em uma posiзгo, e a ID: 2 do lado dela, e assim por diante. Aqui estгo as prints de como esta no momento: https://imgur.com/a/JL1njN0

PHP код:
if(strcmp("/colher", cmdtext, true, 10) == 0)
    {
        if(
PlayerLeo[playerid][Profissao] != FAZENDEIRO) {
            
SendClientMessage(playerid, COR_ERRO, "| ERRO | Vocк nгo й um fazendeiro.");
            return 
1;
        }
        if(
Colher[playerid] == 1) {
            
SendClientMessage(playerid, COR_ERRO, "| ERRO | A sua maconha ainda nгo esta pronta para colher");
            return 
1;
        }
        if(
Colhido[playerid] == 1) {
            
SendClientMessage(playerid, COR_ERRO, "| ERRO | Vocк jб colheu, plante novamente.");
            return 
1;
        }
        new 
string[128];
        new 
gramas = random(300);
        new 
grana = random(3000 - 1000) + 2000;
        
GivePlayerMoney(playerid, grana);
        
Colhido[playerid] = 1;
        
Plantando[playerid] = 0;
        
DestroyObject(Maconha[1]);
        
Delete3DTextLabel(Text3D:MaconhaL[1]);
        
format(string, sizeof(string), "| INFO | Vocк colheu {FF0000}%d gramas{FFFFFF} de maconha, e recebeu {228B22}R$%d{FFFFFF}.", gramas, grana);
        
SendClientMessage(playerid, -1, string);
        return 
1;
        } 
PHP код:
if(strcmp("/plantarmaconha", cmdtext, true, 10) == 0)
    {
        if(
PlayerLeo[playerid][Profissao] != FAZENDEIRO) {
            
SendClientMessage(playerid, COR_ERRO, "| ERRO | Vocк nгo й um fazendeiro");
            return 
1;
        }
        if(
PlayerLeo[playerid][Sementes] <= 2) {
            
SendClientMessage(playerid, COR_ERRO, "| ERRO | Vocк nгo tem sementes o suficiente para plantar maconha (2 Sementes necessбrias)");
            return 
1;
        }
        if(
Plantando[playerid] == 1) {
            
SendClientMessage(playerid, COR_ERRO, "| ERRO | Jб comeзou a plantar espere atй crescer para plantar novamente.");
            return 
1;
        }
        new 
string[128];
        
SendClientMessage(playerid, -1, "| INFO | Vocк comeзou a plantar maconha, espere atй crescer e colha.");
        
ApplyAnimation(playerid,"BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 32000, 1);
        
ApplyAnimation(playerid,"BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 32000, 1);
        
PlayerLeo[playerid][Sementes] -= 2;
        
Plantando[playerid] = 1;
        
Colher[playerid] = 1;
        
Colhido[playerid] = 0;
        
MaconhaL[1] = format(string, sizeof(string), "Plantaзгo ID: 1 de {32CD32}%s", GetPlayerNome(playerid));
        
Create3DTextLabel(string, 0xFFFFFFFF, -1052.03845, -1611.96765, 76.0000, 10.0, 0);
        
SetTimerEx("Plantar1", 30000, false, "i", playerid);
        return 
1;
    } 
PHP код:
public Plantar1(playerid)
{
    
Colher[playerid] = 0;
    
SendClientMessage(playerid, -1, "| INFO | {FF0000}Maconha{FFFFFF} pronta para ser colhida.");
    
Maconha[1] = CreateObject(3409, -1052.03845, -1611.96765, 74.7571,   0.00000, 0.00000, 0.00000);
    return 
1;
} 
Reply
#2

Oque vocк estб tentando fazer? vocк pode usar o foreach e usar para criar Iterators.
Tente ser mais especнfico.
Reply
#3

Nгo expliquei muito bem, me desculpa. Mas acho que pelo desenho da pra entender. Quero criar varias plantaзхes e nгo tenho ideia de como fazer isso.

Desenho ~~> https://imgur.com/a/vqjYKa6
Reply
#4

tem que loops para criar tais plantaзхes.
Reply
#5

PHP код:
#define        MAX_PLANTACOES        2
static const Float:Plantacoes[3][MAX_PLANTACOES] = {
    {
0.0, 0.0, 0.0}, // X, Y, Z
    
{0.0, 0.0, 0.0}
}
public 
OnGameModeInit() {
    new 
string[20];
    for(new 
i = 0; i < MAX_PLANTACOES; ++i) {
        
format(string, 20, "Plantaзгo ID: %d", i);
        
Create3DTextLabel(string, 0xFFFFFFFF, Plantacoes[i][0], Plantacoes[i][1], Plantacoes[i][2], 20.0, 0);
    }
    return 
1;
}
IsPlayerInPlantation(playerid) {
    for(new 
i = 0; i < MAX_PLANTACOES; ++i) {
        if(
IsPlayerInRangeOfPoint(playerid, 5.0, Plantacoes[i][0], Plantacoes[i][1], Plantacoes[i][2]))
            return 
i;
    }
    return -
1;
} 
Criei uma base rapidinho aqui pra vocк. A funзгo IsPlayerInPlantation retornarб -1 se o jogador nгo estiver em nenhuma plantaзгo. Caso o mesmo esteja em uma plantaзгo, retornarб o ID da plantaзгo que ele estiver.

MAX_PLANTACOES vocк informa o nъmero de plantaзхes que terб.

static const Float:Plantacoes[3] vocк vai colocando a posiзгo X, Y e Z de cada plantaзгo. Sу ir no seu servidor, ir dando /save e colocar as posiзхes corretamente nessa variбvel.

Os 3DText sгo carregados no OnGameModeInit, se vocк quiser mudar a cor do texto, colocar viadagens e etc.
Reply
#6

Quote:
Originally Posted by RiqueP
Посмотреть сообщение
PHP код:
#define        MAX_PLANTACOES        2
static const Float:Plantacoes[3][MAX_PLANTACOES] = {
    {
0.0, 0.0, 0.0}, // X, Y, Z
    
{0.0, 0.0, 0.0}
}
public 
OnGameModeInit() {
    new 
string[20];
    for(new 
i = 0; i < MAX_PLANTACOES; ++i) {
        
format(string, 20, "Plantaзгo ID: %d", i);
        
Create3DTextLabel(string, 0xFFFFFFFF, Plantacoes[i][0], Plantacoes[i][1], Plantacoes[i][2], 20.0, 0);
    }
    return 
1;
}
IsPlayerInPlantation(playerid) {
    for(new 
i = 0; i < MAX_PLANTACOES; ++i) {
        if(
IsPlayerInRangeOfPoint(playerid, 5.0, Plantacoes[i][0], Plantacoes[i][1], Plantacoes[i][2]))
            return 
i;
    }
    return -
1;
} 
Criei uma base rapidinho aqui pra vocк. A funзгo IsPlayerInPlantation retornarб -1 se o jogador nгo estiver em nenhuma plantaзгo. Caso o mesmo esteja em uma plantaзгo, retornarб o ID da plantaзгo que ele estiver.

MAX_PLANTACOES vocк informa o nъmero de plantaзхes que terб.

static const Float:Plantacoes[3] vocк vai colocando a posiзгo X, Y e Z de cada plantaзгo. Sу ir no seu servidor, ir dando /save e colocar as posiзхes corretamente nessa variбvel.

Os 3DText sгo carregados no OnGameModeInit, se vocк quiser mudar a cor do texto, colocar viadagens e etc.
Consegui fazer!! Muito obrigado!! Mas agora quando dou o comando no servidor aparece que o comando nгo existe (SERVER: Unknown command.) O comando estб abaixo.

PHP код:
if(strcmp("/plantarmaconha", cmdtext, true, 10) == 0)
    {
        if(
PlayerLeo[playerid][Profissao] != FAZENDEIRO) {
            
SendClientMessage(playerid, COR_ERRO, "| ERRO | Vocк nгo й um fazendeiro");
            return 
1;
        }
        if(
PlayerLeo[playerid][Sementes] <= 2) {
            
SendClientMessage(playerid, COR_ERRO, "| ERRO | Vocк nгo tem sementes o suficiente para plantar maconha (2 Sementes necessбrias)");
            return 
1;
        }
        if(
Plantando[playerid] == 1) {
            
SendClientMessage(playerid, COR_ERRO, "| ERRO | Jб comeзou a plantar espere atй crescer para plantar novamente.");
            return 
1;
        }
        for(new 
i = 0; i < sizeof(PosicaoPlantacao); i ++) 
        {
            if(
IsPlayerInRangeOfPoint(playerid, 1, PosicaoPlantacao[i][posX], PosicaoPlantacao[i][posY], PosicaoPlantacao[i][posZ])) 
            {
                new 
string[128];
                
SendClientMessage(playerid, -1, "| INFO | Vocк comeзou a plantar maconha, espere atй crescer e colha.");
                
ApplyAnimation(playerid,"BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 32000, 1);
                
ApplyAnimation(playerid,"BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 32000, 1);
                
PlayerLeo[playerid][Sementes] -= 2;
                
Plantando[playerid] = 1;
                
Colher[playerid] = 1;
                
Colhido[playerid] = 0;
                
SetTimerEx("Plantar1", 30000, false, "i", playerid);
                return 
1;
            }
        }
    } 
Reply
#7

Imagino que esteja faltando um return 1.
PHP код:
if(strcmp("/plantarmaconha", cmdtext, true, 10) == 0) 
    { 
        if(
PlayerLeo[playerid][Profissao] != FAZENDEIRO) { 
            
SendClientMessage(playerid, COR_ERRO, "| ERRO | Vocк nгo й um fazendeiro"); 
            return 
1; 
        } 
        if(
PlayerLeo[playerid][Sementes] <= 2) { 
            
SendClientMessage(playerid, COR_ERRO, "| ERRO | Vocк nгo tem sementes o suficiente para plantar maconha (2 Sementes necessбrias)"); 
            return 
1; 
        } 
        if(
Plantando[playerid] == 1) { 
            
SendClientMessage(playerid, COR_ERRO, "| ERRO | Jб comeзou a plantar espere atй crescer para plantar novamente."); 
            return 
1; 
        } 
        for(new 
i = 0; i < sizeof(PosicaoPlantacao); i ++)  
        { 
            if(
IsPlayerInRangeOfPoint(playerid, 1, PosicaoPlantacao[i][posX], PosicaoPlantacao[i][posY], PosicaoPlantacao[i][posZ]))  
            { 
                new 
string[128]; 
                
SendClientMessage(playerid, -1, "| INFO | Vocк comeзou a plantar maconha, espere atй crescer e colha."); 
                
ApplyAnimation(playerid,"BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 32000, 1); 
                
ApplyAnimation(playerid,"BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 32000, 1); 
                
PlayerLeo[playerid][Sementes] -= 2; 
                
Plantando[playerid] = 1; 
                
Colher[playerid] = 1; 
                
Colhido[playerid] = 0; 
                
SetTimerEx("Plantar1", 30000, false, "i", playerid); 
                return 
1; 
            } 
        }
        return 
1;
    } 
Reply
#8

Tentei adiciona-lo e agora o comando nгo faz nada, nгo executa ele.
Reply
#9

Resolvido! Muito Obrigado!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)