25.07.2013, 23:28
Код:
enum MisLocationsEnum
{
ID,
LoadName[128],
Float:LoadX,
Float:LoadY,
Float:LoadZ,
Float:UnloadX,
Float:UnloadY,
Float:UnloadZ,
Pay
}
new MisLocations[][MisLocationsEnum] =
{
{10, "weapons from ammunition store to main army base", -307.1,836.4,12.2, 135.1,1946.2,19.0},
{11, "beer from LV Brewery to LS McDonalds", 275.1,1355.2,10.3, 1194.7,-880.5,42.7},
{12, "Samsung Galaxy S4 from LS Refinery to LV Market", 2202.2,-2253.4,14.55, 2823.0,2602.7,10.5},
{13, "dildos from SF Refinery to LV Sexshop", -1704.6,13.8,4.5, 1988.1,2073.8,11.8},
{13, "money from SF Bank to LS Casino", -2440.2,514.0,30.9, 1905.2,959.9,11.8},
{14, "fresh steak from SF Farm to LS Cluckin bell", -1459.9,-1456.2,101.4, 2397.2,-1499.7,23.5},
{15, "Medical Marihuana from SF Farm to LV Hospital", -1169.5,-1136.6,128.9, 1630.0,1800.1,10.5},
{16, "rocks from LA Worksite to SF Biggest mountain", 586.4,854.0,-42.7, -2328.4,-1623.0,483.4},
{17, "sport cars from LV Airport to LS Grotti Car Sale", 1633.5,1638.2,11.4, 544.3,-1280.0,16.9}
};
stock T_NewJob(playerid)
{
new vID = GetPlayerVehicleID(playerid); //gets called on the next line
if(T_OnMission[playerid] == 1) return SendClientMessage(playerid, COLOR_RED,"You are already working.");
if(GetVehicleModel(vID)== 403 || GetVehicleModel(vID)== 515 || GetVehicleModel(vID) == 514)//this checks wether the player is in a Roadtrain, Tanker or Linerunner
{
if(IsTrailerAttachedToVehicle(vID))// This checks wether the player has a trailer attached
{
new MisRand = random(sizeof(MisLocations));// this is the line that will call a random mission.
new LoadText[128], Float:x, Float:y, Float:z;// these are where we will store each co-ord and the text for the mission
x = MisLocations[MisRand][LoadX];//this sets one of the above
y = MisLocations[MisRand][LoadY];//this sets one of the above
z = MisLocations[MisRand][LoadZ];//this sets one of the above
unx[playerid] = MisLocations[MisRand][UnloadX];//these set what we made in step 10.
uny[playerid] = MisLocations[MisRand][UnloadY];//these set what we made in step 10.
unz[playerid] = MisLocations[MisRand][UnloadZ];//these set what we made in step 10.
iPay[playerid] = GetDistance(x,y,z,unx[playerid],uny[playerid],unz[playerid]);
SetPlayerCheckpoint(playerid, x, y, z, 7);
format(LoadText, 128, "Deliver %s",MisLocations[MisRand][LoadName]);// this is formatting the text the player will see in the console
SendClientMessage(playerid, 0xFFFFFF, "_____________________");//sends message in console
SendClientMessage(playerid, 0xFFFFFF, "");//sends message in console
SendClientMessage(playerid, 0x33CCFFAA, LoadText);//sends the text we formatted earlier in console
SendClientMessage(playerid, 0xFFFFFF, "_____________________");//sends message in console
T_OnMission[playerid] = 1;
}
else//if the player doesnt have a trailer attached
{
SendClientMessage(playerid, COLOR_WHITE, "You need a trailer!");//sends message in console
}
}
else//if the player isnt in a truck
{
SendClientMessage(playerid, COLOR_WHITE, "You must be in a Truck in order to work!");//sends message in console
}
return 1;
}
//-------------------[Stop Work]---------------------------------------
stock StopWork(playerid)
{
if(T_OnMission[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not on mission.");
T_OnMission[playerid] = 0;
DisablePlayerCheckpoint(playerid);
SendClientMessage(playerid, COLOR_WHITE, "You chose to cancel the mission and got fined $1000");
GivePlayerMoney(playerid, -1000);
return 1;
}
stock CheckpointEntered(playerid)
{
new string[300];
new vID = GetPlayerVehicleID(playerid);//Explained earlier
if(!IsTrailerAttachedToVehicle(vID)) return SendClientMessage(playerid, COLOR_WHITE, "You need a trailer to unload!");//This line checks wether the player has a trailer attached to their truck.
if(T_OnMission[playerid] == 1)//checks the players mission status
{
DisablePlayerCheckpoint(playerid);//disables the checkpoint
SetPlayerCheckpoint(playerid, unx[playerid], uny[playerid], unz[playerid], 7);//creates the new checkpoint from the saved positions we made earlier
SendClientMessage(playerid, COLOR_WHITE, "Loaded. Please head to the second checkpoint!");//sends message
T_OnMission[playerid] = 2;//sets the players mission status
}
else if(T_OnMission[playerid] == 2)//checks the mission status of the player
{
new LoadText[128];
format(string,sizeof(string),"Well done. You have completed your mission and earned %d$",iPay[playerid]*5);
GivePlayerMoney(playerid,iPay[playerid]*5);
SendClientMessage(playerid, COLOR_YELLOW, string);
DisablePlayerCheckpoint(playerid);//disables the checkpoint
T_OnMission[playerid] = 0;
SetPlayerScore(playerid, GetPlayerScore(playerid)+2);//gives the player 2 score
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
INI_WriteInt(File,"Score",GetPlayerScore(playerid));
INI_Close(File);
}
return 1;
}
Код:
format(LoadText, 128, "Deliver %s",MisLocations[MisRand][LoadName]);// this is formatting the text the player will see in the console

I hope it's understandable enough ^^


