Delivery System.
#1

I was trying to make a delivery system with trucks for my server, but it is not working properly.

How it would work in theory:

The player executes the command to load the truck, shows on his map a checkpoint to load.

When he enters this checkpoint, the checkpoint used to load should disappear and after that one is created to unload the truck.

But it does not work, at the checkpoint to load the truck it already runs as if it were to unload the truck.

All code below:

PHP код:

//Top of the gamemode.
enum ALocations_C {
    
ALOC_NAME[24],
    
ALOC_CITY[24],
    
Float:ALOCX,
    
Float:ALOCY,
    
Float:ALOCZ,
    
ALOC_MIN,
    
ALOC_MAX
}
new 
ALocVAR_C[][ALocations_C] = {
    {
"Exportacao""BlueBerry"51.8294 , -284.4816 ,1.2638 135 395},
    {
"Loja de conveniencia""Los Santos"986.7144 ,-920.6162 ,42.7584 250680},
    {
"Burger King""Los Santos"1214.8322, -884.7917 43.5170150490}
new 
CPCarregar[MAX_PLAYERS];
new 
CPDescarregar[MAX_PLAYERS]; 
PHP код:

// The command to load the truck.
CMD:trabalhar(playerid)
{
    switch(
Player[playerid][pProfissaoID])
    {
        case 
0:
        {
            
SendClientMessage(playeridCOLOR_RED"[ ERRO ] Vocк й um desempregado.");
            
SendClientMessage(playeridCOLOR_RED"[ ERRO ] Vб na prefeitura e escolha um emprego na agкncia de empregos");
        }
        case 
1:
        {
            if(!
IsPlayerinVeiculoTrabalho_C(playerid))
                return 
SendClientMessage(playeridCOLOR_RED,"[ ERRO ] Vocк nгo estб no seu veнculo de trabalho");
            if(!
IsTrailerTrabalhoAttached_C(playerid))
                return 
SendClientMessage(playeridCOLOR_RED,"[ ERRO ] Vocк nгo estб conectado com o seu trailer");
            if(
Player[playerid][pProfissaoID] != 1)
                return 
SendClientMessage(playeridCOLOR_RED"[ ERRO ] Esse veнculo nгo pertece a sua profissгo");
            if(
PlayerWorking[playerid] == true)
                return 
SendClientMessage(playeridCOLOR_RED"[ ERRO ] Vocк jб estб trabalhando");
            
CPCarregar[playerid] = CreateDynamicCP(-172.6250, -210.3235 1.00285.0,  -1, -1playerid STREAMER_CP_SD, -1,  0);
            
SendClientMessage(playeridCOLOR_YELLOW"[ Fleish Berg ] Carregue os produtos na HQ para comeзar a sua entrega.");
            
PlayerWorking[playerid] = true;
        }
    }
    return 
1;
}
alias:trabalhar("t"); 
PHP код:

// OnPlayerEnterDynamicCP
public OnPlayerEnterDynamicCP(playeridcheckpointid)
{
    new 
string[150];
    if(
checkpointid == CPCarregar[playerid])
    {
        
DestroyDynamicCP(CPCarregar[playerid]);
        switch(
Player[playerid][pProfissaoID])
        {
            case 
0SendClientMessage(playeridCOLOR_RED"??????????????????");
            case 
1:
            {
                
DestroyDynamicCP(CPCarregar[playerid]);
                new 
index random(sizeof(ALocVAR_C));
                new 
pay RandomPay(ALocVAR_C[index][ALOC_MIN], ALocVAR_C[index][ALOC_MAX]);
                
format(stringsizeof(string), "[ Fleish Berg ] Leve os produtos a {FFFFFF}%s {FDFF00}localizado em {FFFFFF}%s {FDFF00}para completar a entrega."ALocVAR_C[index][ALOC_NAME], ALocVAR_C[index][ALOC_CITY]);
                
SendClientMessage(playeridCOLOR_YELLOWstring);
                
SetPVarInt(playerid"DinheiroEntrega_C"pay);
                
CPDescarregar[playerid] = CreateDynamicCP(ALocVAR_C[index][ALOCX], ALocVAR_C[index][ALOCY] , ALocVAR_C[index][ALOCZ], 5.0,  -1, -1playerid STREAMER_CP_SD, -1,  0);
            }
        }
    }
    if(
checkpointid == CPDescarregar[playerid])
    {
        switch(
Player[playerid][pProfissaoID])
        {
            case 
0SendClientMessage(playeridCOLOR_RED"??????????????????");
            case 
1:
            {
                new 
pay GetPVarInt(playerid"DinheiroEntrega_C");
                
DestroyDynamicCP(CPDescarregar[playerid]);
                
SendClientMessage(playeridCOLOR_YELLOW"[ Fleish Berg ] Vocк entregou os produtos ao seu destino");
                
format(stringsizeof(string), "[ Fleish Berg ] Vocк ganhou {15FF00}$%d {FDFF00}como pagamento."pay);
                
SendClientMessage(playeridCOLOR_YELLOWstring);
                
PlayerWorking[playerid] = false;
                
GivePlayerMoney(playeridpay);
                
DeletePVar(playerid"DinheiroEntrega_C");
            }
        }
    }
    return 
1;

First of all, thanks for helping

Sorry for my English, I'm using ****** translator to ask for help on this board, since no one helped me.

If you do not understand something, please tell me so I can explain it better.
Reply
#2

Switch case should have break, otherwise it will fall through
Reply
#3

Ok so i get what the code is subposed to do but can you please re-explain the problem that your getting?
Reply
#4

This system should create a checkpoint for loading, after you entered it to create another checkpoint, but it does not work, at the first checkpoint it finishes everything, without creating the second checkpoint.


Sorry for my English, I'm using translator
Reply
#5

I honestly don't see anything wrong with your code
Reply
#6

Did you used Break as above suggested? Show th new code. Logically its correct.
Reply
#7

Quote:
Originally Posted by GTLS
Посмотреть сообщение
Did you used Break as above suggested? Show th new code. Logically its correct.
How do I do this?

I managed to make it work up to a part, now it does not finish delivery at the checkpoint, it just does not create the second checkpoint. I have already debugged and the values return correct.

New Code:


PHP код:

public OnPlayerEnterDynamicCP(playeridcheckpointid)
{
    new 
string[150];
    if(
checkpointid == CPCarregar[playerid])
    {
        
DestroyDynamicCP(CPCarregar[playerid]);
        switch(
Player[playerid][pProfissaoID])
        {
            case 
0SendClientMessage(playeridCOLOR_RED"??????????????????");
            case 
1:
            {
                
DestroyDynamicCP(CPCarregar[playerid]);
                new 
index random(sizeof(ALocVAR_C));
                new 
pay RandomPay(ALocVAR_C[index][ALOC_MIN], ALocVAR_C[index][ALOC_MAX]);
                
format(stringsizeof(string), "[ Fleish Berg ] Leve os produtos a {FFFFFF}%s {FDFF00}localizado em {FFFFFF}%s {FDFF00}para completar a entrega."ALocVAR_C[index][ALOC_NAME], ALocVAR_C[index][ALOC_CITY]);
                
SendClientMessage(playeridCOLOR_YELLOWstring);
                
SetPVarInt(playerid"DinheiroEntrega_C"pay);
                
CPDescarregar[playerid] = CreateDynamicCP(ALocVAR_C[index][ALOCX], ALocVAR_C[index][ALOCY] , ALocVAR_C[index][ALOCZ], 5.0,  -1, -1playerid STREAMER_CP_SD, -1,  0);
                
printf("%f, %f, %f, %d "ALocVAR_C[index][ALOCX], ALocVAR_C[index][ALOCY] , ALocVAR_C[index][ALOCZ],CPDescarregar[playerid]);
            }
        }
    }
    else if(
checkpointid == CPDescarregar[playerid])
    {
        switch(
Player[playerid][pProfissaoID])
        {
            case 
0SendClientMessage(playeridCOLOR_RED"??????????????????");
            case 
1:
            {
                new 
pay GetPVarInt(playerid"DinheiroEntrega_C");
                
DestroyDynamicCP(CPDescarregar[playerid]);
                
SendClientMessage(playeridCOLOR_YELLOW"[ Fleish Berg ] Vocк entregou os produtos ao seu destino");
                
format(stringsizeof(string), "[ Fleish Berg ] Vocк ganhou {15FF00}$%d {FDFF00}como pagamento."pay);
                
SendClientMessage(playeridCOLOR_YELLOWstring);
                
PlayerWorking[playerid] = false;
                
GivePlayerMoney(playeridpay);
                
DeletePVar(playerid"DinheiroEntrega_C");
            }
        }
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)