Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // After a truckdriver entered a checkpoint, a timer is created. This function is called when the timer runs out
- public Trucker_LoadUnload(playerid)
- {
- if (APlayerData[playerid][InConvoy] == true)
- {
- if (APlayerData[playerid][JobStep] == 1)
- {
- PlayerTextDrawSetString(playerid, MissionText[playerid], " ");
- APlayerData[playerid][JobStep] = 2;
- PlayerTextDrawSetString(playerid, MissionText[playerid], TXT_WaitingMembersToLoadCargo);
- APlayerData[playerid][Carregando] = true;
- PlayerInfo[playerid][Carregou] = true;
- }
- if (APlayerData[playerid][JobStep] == 3)
- {
- PlayerTextDrawSetString(playerid, MissionText[playerid], " ");
- APlayerData[playerid][JobStep] = 4;
- PlayerTextDrawSetString(playerid, MissionText[playerid], TXT_WaitingMembersToUnLoadCargo);
- APlayerData[playerid][Carregando] = false;
- PlayerInfo[playerid][Carregou] = false;
- }
- DisablePlayerCheckpoint(playerid);
- TogglePlayerControllable(playerid, 1);
- return 1;
- }
- switch (APlayerData[playerid][JobStep])
- {
- case 1: // Player must load his goods
- {
- // Setup local variables
- new StartLoc[50], EndLoc[50], Load[50], RouteText[255], Float:x, Float:y, Float:z, UnloadMsg[100];
- // Set JobStep to 2 (unloading goods)
- APlayerData[playerid][JobStep] = 2;
- // Delete the loading-checkpoint
- DisablePlayerCheckpoint(playerid);
- // Get the startlocation, endlocation and the load texts
- format(StartLoc, 50, ALocations[APlayerData[playerid][JobLoc1]][LocationName]);
- format(EndLoc, 50, ALocations[APlayerData[playerid][JobLoc2]][LocationName]);
- format(Load, 50, ALoads[APlayerData[playerid][LoadID]][LoadName]);
- APlayerData[playerid][StartTime] = GetTickCount();
- // Randomly set the load as overloaded (15% chance the load is overloaded)
- Trucker_SetRandomOverloaded(playerid);
- PlayerTextDrawSetString(playerid, MissionText[playerid], " ");
- // Pre-format the missiontext (there may be some parts appended when overloaded/mafiaload
- format(RouteText, 255, TXT_TransportingFromToDeliver, Load, StartLoc, EndLoc);
- // Check if the player is overloaded
- if (APlayerData[playerid][Overloaded] == true)
- {
- // Add "(OL)" to the missiontext to let the player know he's been overloaded
- format(RouteText, 255, "%s%s", RouteText, " ~r~(SC)~w~");
- // Send a message to the player to let him know he's been overloaded
- SCM(playerid, 0xFFFFFFFF, "{FF8000}Você esta sobrecarregado. Evite a policia rodoviária!");
- }
- // Check if the player is carrying a mafia-load
- if (ALoads[APlayerData[playerid][LoadID]][Mafia] == true)
- {
- // Add "(ML)" to the missiontext to let the player know his load is wanted by the mafia
- format(RouteText, 255, "%s%s", RouteText, " ~r~(MI)~w~");
- // If the player is carrying a mafia-load, inform him about it
- GameTextForPlayer(playerid, TXT_TruckerMafiaInterested, 6000, 4);
- // Also set the data for the player to indicate he's carrying a mafiaload
- APlayerData[playerid][MafiaLoad] = true;
- // Also set the player's trailer ID (or the vehicle itself) as Mafia-load in the array "AVehicleMafiaLoad"
- if (APlayerData[playerid][TrailerID] == 0)
- AVehicleData[APlayerData[playerid][VehicleID]][MafiaLoad] = true; // The player has no trailer, so set his main vehicle as wanted by the mafia
- else
- AVehicleData[APlayerData[playerid][TrailerID]][MafiaLoad] = true; // The player has a trailer, so set his trailer as wanted by the mafia
- }
- PlayerTextDrawSetString(playerid, MissionText[playerid], " ");
- // Set the TextDraw so the player can see it
- PlayerTextDrawSetString(playerid, MissionText[playerid], RouteText);
- // Grab the x, y, z positions for the second location (to unload the goods)
- x = ALocations[APlayerData[playerid][JobLoc2]][LocX];
- y = ALocations[APlayerData[playerid][JobLoc2]][LocY];
- z = ALocations[APlayerData[playerid][JobLoc2]][LocZ];
- // Create a checkpoint where the player should unload the goods
- SetPlayerCheckpoint(playerid, x, y, z, 15);
- // Inform the player that he must unload his goods
- format(UnloadMsg, 100, TXT_DeliverCargoTo, Load, EndLoc);
- SCM(playerid, 0xFFFFFFFF, UnloadMsg);
- //if mission bonus has started and if it isn't finished yet
- if(!RandomBonusMission[MissionFinished] || RandomBonusMission[RandomLoad] != 0)
- {
- if(APlayerData[playerid][JobLoc2] == RandomBonusMission[RandomEndLoc])
- {
- SCM(playerid, 0xFFFFCC, "Você agora está participando da missão bônus!");
- PlayerOnBonusMission[playerid] = true;
- }
- }
- }
- case 2: // Player is delivering his goods
- {
- // Setup local variables
- new StartLoc[50], EndLoc[50], Load[50], Msg1[128], Msg2[128], Name[24], BonusMsg[128];
- // Get the player name
- GetPlayerName(playerid, Name, sizeof(Name));
- // Get the startlocation, endlocation and the load texts
- format(StartLoc, 50, ALocations[APlayerData[playerid][JobLoc1]][LocationName]);
- format(EndLoc, 50, ALocations[APlayerData[playerid][JobLoc2]][LocationName]);
- format(Load, 50, ALoads[APlayerData[playerid][LoadID]][LoadName]);
- new TotalTime = (GetTickCount() - APlayerData[playerid][StartTime]) / 1000;
- new Mins = TotalTime / 60;
- new Secs = TotalTime - (Mins * 60);
- if(Secs < 24 && Mins < 1) return Kick(playerid);
- // Construct the message sent to all players that this player completed a trucking mission
- if (APlayerData[playerid][Sexo] == 0 || APlayerData[playerid][Sexo] == 1) {
- format(Msg1, 200, "{FF8000}O Caminhoneiro {FFFFFF}%s{FF8000} transportou {FFFFFF}%s{FF8000} com sucesso.", Name, Load);
- format(Msg2, 128, "{FF8000}de: {FFFFFF}%s{FF8000} para: {FFFFFF}%s{FF8000} em %02i min(s) - %02i seg(s).", StartLoc, EndLoc, Mins, Secs);
- SCMA(0xFFFFFFFF, Msg1);
- SCMA(0xFFFFFFFF, Msg2); }
- if (APlayerData[playerid][Sexo] == 2) {
- format(Msg1, 200, "{FF8000}A Caminhoneira {FFFFFF}%s{FF8000} transportou {FFFFFF}%s{FF8000} com sucesso.", Name, Load);
- format(Msg2, 128, "{FF8000}de: {FFFFFF}%s{FF8000} para: {FFFFFF}%s{FF8000} em %02i min(s) - %02i seg(s).", StartLoc, EndLoc, Mins, Secs);
- SCMA(0xFFFFFFFF, Msg1);
- SCMA(0xFFFFFFFF, Msg2); }
- // Setup local variables
- new Float:x1, Float:y1, Float:x2, Float:y2, Float:Distance, Message[128], Payment, Bonus, array[200];
- // Grab the x, y, z positions for the first location (to load the goods)
- x1 = ALocations[APlayerData[playerid][JobLoc1]][LocX];
- y1 = ALocations[APlayerData[playerid][JobLoc1]][LocY];
- // Grab the x, y, z positions for the second location (to unload the goods)
- x2 = ALocations[APlayerData[playerid][JobLoc2]][LocX];
- y2 = ALocations[APlayerData[playerid][JobLoc2]][LocY];
- // Calculate the distance between both points
- Distance = floatsqroot(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));
- // Calculate the payment for the player
- Payment = floatround((Distance * ALoads[APlayerData[playerid][LoadID]][PayPerUnit]), floatround_floor);
- Passou[playerid] = false;
- // Check if the player has done the bonus mission
- if (RandomBonusMission[MissionFinished] == false)
- {
- // Check all paramters (load, startlocation and end-location)
- if (RandomBonusMission[RandomLoad] == APlayerData[playerid][LoadID])
- if (RandomBonusMission[RandomStartLoc] == APlayerData[playerid][JobLoc1])
- if (RandomBonusMission[RandomEndLoc] == APlayerData[playerid][JobLoc2])
- {
- for(new i; i < GetPlayerPoolSize(); i++)
- if(IsPlayerConnected(i)) PlayerOnBonusMission[i] = false;
- Payment = Payment * 12; // Double the payment is the player was the first to do the bonus mission
- RandomBonusMission[MissionFinished] = true; // Only one player can do the bonus mission, a new one is chosen next
- format(BonusMsg, 128, "{1E90FF}Caminhoneiro {FFFFFF}%s{1E90FF} transportou a carga bônus com sucesso.", Name);
- SCMA(0xFFFFFFFF, BonusMsg);
- Passou[playerid] = false;
- }
- }
- new file[40];
- format(file, sizeof(file), BankFile, Name);
- if (fexist(file))
- {
- new Var[300];
- format(Var, sizeof Var,"{FF8C00}Você transportou {FFFFFF}%s{FF8C00} com sucesso de {FFFFFF}%s{FF8C00} para {FFFFFF}%s\n{FF8C00}Você recebeu {80FF00}R${FFFFFF}%d{FF8C00} pelo seu trabalho.\n\nDeseja depositar no banco?\n\n\nCaso você ganhe bônus, não será incluido nesta mensagem.", Load, StartLoc, EndLoc, Payment);
- ShowPlayerDialog(playerid, DialogTermino, DIALOG_STYLE_MSGBOX, "{FF0000}#{FFFFFF} Trabalho", Var, "Sim", "Não");
- Valor[playerid] = Payment;
- } else Ganhos(playerid, Payment, 0);
- format(Message, 128, "{FF8000}Você finalizou seu trabalho e ganhou {00FF00}R${FFFFFF}%i", Payment);
- SCM(playerid, 0xFFFFFFFF, Message);
- format(Message, 128, "{FF8000}Você ganhou {FFFFFF}1 Gold!{FF8000} Troque com o NPC em {FFFFFF}Fleischberg", Payment);
- SCM(playerid, 0xFFFFFFFF, Message);
- GameTextForPlayer(playerid, "~w~Trabalho~n~~g~Finalizado", 5000, 0);
- Gold[playerid]++;
- // Add 25% bonus if the player has been overloaded
- if (APlayerData[playerid][Overloaded] == true)
- {
- // Calculate the bonus
- Bonus = (Payment * 25) / 100;
- // Pay the bonus to the player
- Ganhos(playerid, Bonus, 0);
- // Send a message to let the player know he was overloaded and got paid
- format(Message, 128, "{FF8000}Você ganhou um bônus por estar sobrecarregado: {00FF00}R${FFFFFF}%i", Bonus);
- SCM(playerid, 0xFFFFFFFF, Message);
- }
- if (APlayerData[playerid][MafiaLoad] == true)
- {
- Bonus = (Payment * 50) / 100;
- Ganhos(playerid, Bonus, 0);
- format(Message, 128, "{FF8000}Você ganhou um bônus por carregar uma carga de interesse da máfia: {00FF00}R${FFFFFF}%i", Bonus);
- SCM(playerid, 0xFFFFFFFF, Message);
- }
- if (AVehicleData[APlayerData[playerid][VehicleID]][Owned] == true)
- {
- Bonus = (Payment * 10) / 100;
- Ganhos(playerid, Bonus, 0);
- format(Message, 128, "{FF8000}Você ganhou um bônus por entregar com o seu próprio caminhão: {00FF00}R${FFFFFF}%i", Bonus);
- SCM(playerid, 0xFFFFFFFF, Message);
- }
- if (IsPlayerVIP(playerid))
- {
- Bonus = (Payment * 20) / 100;
- Ganhos(playerid, Bonus, 0);
- format(Message, 128, "{FF8000}Você ganhou um bônus por ser VIP: {00FF00}R${FFFFFF}%i", Bonus);
- SCM(playerid, 0xFFFFFFFF, Message);
- }
- if(APlayerData[playerid][StatsTruckerJobs] == 999)
- {
- if (APlayerData[playerid][Sexo] == 2)
- {
- format(array, 200, "{FF8000}A Caminhoneira {FFFFFF}%s{FF8000} subiu para o nível {FFFFFF}insana.", rNome(playerid));
- SendClientMessageToAll(-1, array);
- }
- else if(APlayerData[playerid][Sexo] == 0 || APlayerData[playerid][Sexo] == 1)
- {
- format(array, 200, "{FF8000}O Caminhoneiro {FFFFFF}%s{FF8000} subiu para o nível {FFFFFF}insano.", rNome(playerid));
- SendClientMessageToAll(-1, array);
- }
- }
- if(APlayerData[playerid][StatsTruckerJobs] == 499)
- {
- if (APlayerData[playerid][Sexo] == 2)
- {
- format(array, 200, "{FF8000}A Caminhoneira {FFFFFF}%s{FF8000} subiu para o nível {FFFFFF}moderada.", rNome(playerid));
- SendClientMessageToAll(-1, array);
- }
- else if(APlayerData[playerid][Sexo] == 0 || APlayerData[playerid][Sexo] == 1 )
- {
- format(array, 200, "{FF8000}O Caminhoneiro {FFFFFF}%s{FF8000} subiu para o nível {FFFFFF}moderado.", rNome(playerid));
- SendClientMessageToAll(-1, array);
- }
- }
- if(APlayerData[playerid][StatsTruckerJobs] == 99)
- {
- if (APlayerData[playerid][Sexo] == 2)
- {
- format(array, 200, "{FF8000}A Caminhoneira {FFFFFF}%s{FF8000} subiu para o nível {FFFFFF}intermediária.", rNome(playerid));
- SendClientMessageToAll(-1, array);
- }
- else if(APlayerData[playerid][Sexo] == 0 || APlayerData[playerid][Sexo] == 1)
- {
- format(array, 200, "{FF8000}O Caminhoneiro {FFFFFF}%s{FF8000} subiu para o nível {FFFFFF}intermediário.", rNome(playerid));
- SendClientMessageToAll(-1, array);
- }
- }
- if (Distance > 3000.0)
- Ganhos(playerid, 0, 3);
- else
- Ganhos(playerid, 0, 2);
- APlayerData[playerid][StatsTruckerJobs]++;
- PlayerFile_Save(playerid);
- Trucker_EndJob(playerid);
- }
- }
- // Enable the player again (he can move again)
- TogglePlayerControllable(playerid, 1);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment