29.01.2016, 12:51
Hello. So I am scripting the trucking server from scratch and I want to script the license for Truckers, so that they could choose the route by themselves, not like when the system automaticly chooses for them.
Here is some preview of the code:
Here is some preview of the code:
PHP код:
enum MisLocationsCargoEnum
{
ID,
LoadName[128],
Float:LoadX,
Float:LoadY,
Float:LoadZ,
Float:UnloadX,
Float:UnloadY,
Float:UnloadZ,
Pay
}
new MisLocationsCargo[][MisLocationsCargoEnum] =
{
{0, "Deliver Candy & Lollipops from Confectionery Factory to Doherty Warehouse", 2661.2075, -1594.9734, 13.0510, -2093.6938, 94.9525, 35.2214, 14530},
{2, "Deliver Caramels & Licorices from Confectionery Factory to Spiny Bed Warehouse", 2661.2075, -1594.9734, 13.0510, 2401.3398, 2751.3496, 10.7232, 14530}
}
stock T_Trucker(playerid)
{
new vID = GetPlayerVehicleID(playerid), string[2000];
if(GetVehicleModel(vID)== 515)
{
printf("Debug line: 1st if statement passed");
if(IsTrailerAttachedToVehicle(vID))
{
printf("Debug line: 2nd if statement passed");
if(GetVehicleModel(GetVehicleTrailer(vID)) == 435 || GetVehicleModel(GetVehicleTrailer(vID)) == 584)
{
if(PlayerInfo[playerid][pConvoy] > 0)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pConvoy] == PlayerInfo[playerid][pConvoy])
{
printf("Debug line: last if statement passed");
MissionStatus[i] = 1;
new MisRand = random(sizeof(MisLocationsCargo));
new LoadText[128], MissionText[128], Float:x, Float:y, Float:z;
x = MisLocationsCargo[MisRand][LoadX];
y = MisLocationsCargo[MisRand][LoadY];
z = MisLocationsCargo[MisRand][LoadZ];
unx[i] = MisLocationsCargo[MisRand][UnloadX];
uny[i] = MisLocationsCargo[MisRand][UnloadY];
unz[i] = MisLocationsCargo[MisRand][UnloadZ];
iPay[i] = MisLocationsCargo[MisRand][Pay];
SetPlayerCheckpoint(playerid, x, y, z, 7);
format(LoadText, 128, "%s", MisLocationsCargo[MisRand][LoadName]);
PlayerInfo[i][pWork] = 1;
format(string, 2000, "{259400}Mission: {FFFFFF}%s", LoadText);
SendClientMessage(i, 0xFFFFFFFF, string);
PlayerTextDrawSetString(i, Mission[playerid], MissionText);
}
}
}
else
{
printf("Debug line: last if statement passed");
MissionStatus[playerid] = 1;
new MisRand = random(sizeof(MisLocationsFluid));
new LoadText[128], MissionText[128], Float:x, Float:y, Float:z;
x = MisLocationsFluid[MisRand][LoadX];
y = MisLocationsFluid[MisRand][LoadY];
z = MisLocationsFluid[MisRand][LoadZ];
unx[playerid] = MisLocationsFluid[MisRand][UnloadX];
uny[playerid] = MisLocationsFluid[MisRand][UnloadY];
unz[playerid] = MisLocationsFluid[MisRand][UnloadZ];
iPay[playerid] = MisLocationsFluid[MisRand][Pay];
SetPlayerCheckpoint(playerid, x, y, z, 7);
format(LoadText, 128, "%s", MisLocationsFluid[MisRand][LoadName]);
format(MissionText, 128, "~w~%s", MisLocationsFluid[MisRand][LoadName]);
PlayerInfo[playerid][pWork] = 1;
format(string, 2000, "{259400}Mission: {FFFFFF}%s", LoadText);
SendClientMessage(playerid, 0xFFFFFFFF, string);
PlayerTextDrawSetString(playerid, Mission[playerid], MissionText);
}
if(GetVehicleModel(vID)== 450) // Cargo Missions
{
printf("Debug line: last if statement passed");
MissionStatus[playerid] = 1;
new MisRand = random(sizeof(MisLocationsOre));
new LoadText[128], MissionText[128], Float:x, Float:y, Float:z;
x = MisLocationsOre[MisRand][LoadX];
y = MisLocationsOre[MisRand][LoadY];
z = MisLocationsOre[MisRand][LoadZ];
unx[playerid] = MisLocationsOre[MisRand][UnloadX];
uny[playerid] = MisLocationsOre[MisRand][UnloadY];
unz[playerid] = MisLocationsOre[MisRand][UnloadZ];
iPay[playerid] = MisLocationsOre[MisRand][Pay];
SetPlayerCheckpoint(playerid, x, y, z, 7);
format(LoadText, 128, "%s", MisLocationsOre[MisRand][LoadName]);
format(MissionText, 128, "~w~%s", MisLocationsOre[MisRand][LoadName]);
PlayerInfo[playerid][pWork] = 1;
format(string, 2000, "{259400}Mission: {FFFFFF}%s", LoadText);
SendClientMessage(playerid, 0xFFFFFFFF, string);
PlayerTextDrawSetString(playerid, Mission[playerid], MissionText);
}
}
else
{
SendClientMessage(playerid, -1, "You are not pulling a correct type of trailer");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "Error: You must attach a trailer to your truck or the trailer attached is not used for job.");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "Error: You must be in a truck to perform this!");
}
return 1;
}
forward Loading(playerid);
public Loading(playerid)
{
DisablePlayerCheckpoint(playerid);
ClearActorAnimations(InjuredBarber);
DestroyActor(InjuredBarber);
SetPlayerCheckpoint(playerid, unx[playerid], uny[playerid], unz[playerid], 7);
SendClientMessage(playerid, COLOR_ORANGE, "You're trailer is now loaded. Be sure to don't loose it.");
TogglePlayerControllable(playerid,1);
MissionStatus[playerid] = 2;
}
forward UnLoading(playerid);
public UnLoading(playerid)
{
new vehicleid = GetPlayerVehicleID(playerid), string[256];
PlayerTextDrawSetString(playerid, Mission[playerid], NonWorkMessage);
DisablePlayerCheckpoint(playerid);
GivePlayerMoney(playerid, iPay[playerid]);
format(string, 256, "Well done! You got 2 points and %d$ as reward.", iPay[playerid]);
SendClientMessage(playerid, COLOR_GREEN, string);
DetachTrailerFromVehicle(vehicleid);
TogglePlayerControllable(playerid,1);
PlayAudioStreamForPlayer(playerid, "http://k002.kiwi6.com/hotlink/idmb12174a/taskfinishet.mp3");
SetPlayerScore(playerid, GetPlayerScore(playerid)+2);
PlayerInfo[playerid][pScore] +=2;
MissionStatus[playerid] = 0;
}