19.07.2018, 05:18
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:
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.
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 , 250, 680},
{"Burger King", "Los Santos", 1214.8322, -884.7917 , 43.5170, 150, 490}
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(playerid, COLOR_RED, "[ ERRO ] Vocк й um desempregado.");
SendClientMessage(playerid, COLOR_RED, "[ ERRO ] Vб na prefeitura e escolha um emprego na agкncia de empregos");
}
case 1:
{
if(!IsPlayerinVeiculoTrabalho_C(playerid))
return SendClientMessage(playerid, COLOR_RED,"[ ERRO ] Vocк nгo estб no seu veнculo de trabalho");
if(!IsTrailerTrabalhoAttached_C(playerid))
return SendClientMessage(playerid, COLOR_RED,"[ ERRO ] Vocк nгo estб conectado com o seu trailer");
if(Player[playerid][pProfissaoID] != 1)
return SendClientMessage(playerid, COLOR_RED, "[ ERRO ] Esse veнculo nгo pertece a sua profissгo");
if(PlayerWorking[playerid] == true)
return SendClientMessage(playerid, COLOR_RED, "[ ERRO ] Vocк jб estб trabalhando");
CPCarregar[playerid] = CreateDynamicCP(-172.6250, -210.3235 , 1.0028, 5.0, -1, -1, playerid , STREAMER_CP_SD, -1, 0);
SendClientMessage(playerid, COLOR_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(playerid, checkpointid)
{
new string[150];
if(checkpointid == CPCarregar[playerid])
{
DestroyDynamicCP(CPCarregar[playerid]);
switch(Player[playerid][pProfissaoID])
{
case 0: SendClientMessage(playerid, COLOR_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(string, sizeof(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(playerid, COLOR_YELLOW, string);
SetPVarInt(playerid, "DinheiroEntrega_C", pay);
CPDescarregar[playerid] = CreateDynamicCP(ALocVAR_C[index][ALOCX], ALocVAR_C[index][ALOCY] , ALocVAR_C[index][ALOCZ], 5.0, -1, -1, playerid , STREAMER_CP_SD, -1, 0);
}
}
}
if(checkpointid == CPDescarregar[playerid])
{
switch(Player[playerid][pProfissaoID])
{
case 0: SendClientMessage(playerid, COLOR_RED, "??????????????????");
case 1:
{
new pay = GetPVarInt(playerid, "DinheiroEntrega_C");
DestroyDynamicCP(CPDescarregar[playerid]);
SendClientMessage(playerid, COLOR_YELLOW, "[ Fleish Berg ] Vocк entregou os produtos ao seu destino");
format(string, sizeof(string), "[ Fleish Berg ] Vocк ganhou {15FF00}$%d {FDFF00}como pagamento.", pay);
SendClientMessage(playerid, COLOR_YELLOW, string);
PlayerWorking[playerid] = false;
GivePlayerMoney(playerid, pay);
DeletePVar(playerid, "DinheiroEntrega_C");
}
}
}
return 1;
}
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.