Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- #include <a_samp>
- #include <mapandreas> // http://forum.sa-mp.com/showthread.php?t=273263
- #define PACKAGE_MODEL (2912)
- #define MAPICON_INDEX (69)
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- enum e_droplocations
- {
- dropLocation[32],
- Float: dropX,
- Float: dropY,
- Float: dropZ
- };
- enum e_dropobjects
- {
- OBJECT_PACKAGE,
- OBJECT_ZONE
- };
- new
- DropLocations[][e_droplocations] = {
- // example locations
- {"Farm", 22.3, 17.4, 5.0},
- {"Area 51", 302.2160, 1955.8740, 17.6406},
- {"Flying School", 415.5471, 2503.8643, 16.9425},
- {"NSA HQ", -317.4946, 1523.1005, 75.3594}
- };
- new
- bool: InDelivery[MAX_PLAYERS] = {false, ...},
- PackageCount[MAX_PLAYERS] = {5, ...},
- TraffickingObjects[MAX_PLAYERS][2];
- stock IsATraffickingPlane(modelid)
- {
- new planes[] = {593, 511, 460};
- for(new i; i < sizeof(planes); ++i)
- {
- if(planes[i] == modelid) return 1;
- }
- return 0;
- }
- stock ResetDelivery(playerid)
- {
- if(!IsPlayerConnected(playerid)) return 0;
- InDelivery[playerid] = false;
- PackageCount[playerid] = 5;
- RemovePlayerMapIcon(playerid, MAPICON_INDEX);
- SetPVarInt(playerid, "DeliveryCooldown", tickcount()+120000);
- if(IsValidObject(TraffickingObjects[playerid][OBJECT_PACKAGE]))
- {
- DestroyObject(TraffickingObjects[playerid][OBJECT_PACKAGE]);
- TraffickingObjects[playerid][OBJECT_PACKAGE] = INVALID_OBJECT_ID;
- }
- if(IsValidPlayerObject(playerid, TraffickingObjects[playerid][OBJECT_ZONE]))
- {
- DestroyPlayerObject(playerid, TraffickingObjects[playerid][OBJECT_ZONE]);
- TraffickingObjects[playerid][OBJECT_ZONE] = INVALID_OBJECT_ID;
- }
- return 1;
- }
- stock Float:Distance(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2) // http://forum.sa-mp.com/showpost.php?p=2919962&postcount=2
- return floatsqroot((((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2))+((z1-z2)*(z1-z2))));
- stock RandomEx(min, max)
- return random(max - min) + min;
- public OnPlayerConnect(playerid)
- {
- InDelivery[playerid] = false;
- PackageCount[playerid] = 5;
- TraffickingObjects[playerid][OBJECT_PACKAGE] = INVALID_OBJECT_ID;
- TraffickingObjects[playerid][OBJECT_ZONE] = INVALID_OBJECT_ID;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- ResetDelivery(playerid);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(InDelivery[playerid])
- {
- SendClientMessage(playerid, 0xE74C3CFF, "DELIVERY FAILED: {FFFFFF}You died.");
- ResetDelivery(playerid);
- }
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER && IsATraffickingPlane(GetVehicleModel(GetPlayerVehicleID(playerid))) && GetPVarInt(playerid, "DeliveryCooldown") < tickcount())
- {
- GameTextForPlayer(playerid, "~n~~n~~n~~w~Air Trafficking Available~n~Press ~y~~k~~TOGGLE_SUBMISSIONS~ ~w~to start", 3000, 3);
- }
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- if(InDelivery[playerid])
- {
- SendClientMessage(playerid, 0xE74C3CFF, "DELIVERY FAILED: {FFFFFF}You left your plane.");
- ResetDelivery(playerid);
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(IsATraffickingPlane(GetVehicleModel(GetPlayerVehicleID(playerid))) && PRESSED(KEY_SUBMISSION))
- {
- if(!InDelivery[playerid]) {
- if(GetPVarInt(playerid, "DeliveryCooldown") > tickcount()) return SendClientMessage(playerid, 0xE74C3CFF, "DELIVERY: {FFFFFF}Please wait to start another delivery mission again.");
- new id = random(sizeof(DropLocations)), string[144];
- TraffickingObjects[playerid][OBJECT_ZONE] = CreatePlayerObject(playerid, 19946, DropLocations[id][dropX], DropLocations[id][dropY], DropLocations[id][dropZ], 0.0, 0.0, 0.0, 1200.0);
- SetPlayerMapIcon(playerid, MAPICON_INDEX, DropLocations[id][dropX], DropLocations[id][dropY], DropLocations[id][dropZ], 24, 0, MAPICON_GLOBAL);
- SendClientMessage(playerid, 0x2ECC71FF, "DELIVERY: {FFFFFF}You've started a delivery mission.");
- format(string, sizeof(string), "DELIVERY: {FFFFFF}Drop the package in the marked area at {3498DB}%s {FFFFFF}and you'll get your money.", DropLocations[id][dropLocation]);
- SendClientMessage(playerid, 0x2ECC71FF, string);
- SendClientMessage(playerid, 0x2ECC71FF, "DELIVERY: {FFFFFF}You can drop a crate using H/CAPS LOCK.");
- SendClientMessage(playerid, 0x2ECC71FF, "DELIVERY: {FFFFFF}You can cancel the delivery mission using 2 or by leaving your plane.");
- InDelivery[playerid] = true;
- PackageCount[playerid] = 5;
- }else{
- SendClientMessage(playerid, 0xE74C3CFF, "DELIVERY CANCELLED: {FFFFFF}You've cancelled the delivery mission.");
- ResetDelivery(playerid);
- }
- }
- if(InDelivery[playerid] && PRESSED(KEY_CROUCH))
- {
- if(IsValidObject(TraffickingObjects[playerid][OBJECT_PACKAGE])) return 1;
- if(PackageCount[playerid] == 0) return SendClientMessage(playerid, 0xE74C3CFF, "DELIVERY: {FFFFFF}You don't have any more packages.");
- new Float: x, Float: y, Float: z, Float: z2;
- GetPlayerPos(playerid, x, y, z);
- GetPointZPos(x, y, z2);
- TraffickingObjects[playerid][OBJECT_PACKAGE] = CreateObject(PACKAGE_MODEL, x, y, z-1.5, 0.0, 0.0, 0.0);
- MoveObject(TraffickingObjects[playerid][OBJECT_PACKAGE], x, y, z2, 20.0);
- PackageCount[playerid]--;
- }
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- if(GetObjectModel(objectid) == PACKAGE_MODEL)
- {
- new owner = INVALID_PLAYER_ID;
- for(new i, p = GetPlayerPoolSize(); i <= p; ++i)
- {
- if(objectid == TraffickingObjects[i][OBJECT_PACKAGE])
- {
- owner = i;
- break;
- }
- }
- new Float: objx, Float: objy, Float: objz, Float: zonex, Float: zoney, Float: zonez, money;
- GetObjectPos(objectid, objx, objy, objz);
- GetPlayerObjectPos(owner, TraffickingObjects[owner][OBJECT_ZONE], zonex, zoney, zonez);
- new Float: dist = Distance(objx, objy, objz, zonex, zoney, zonez);
- if(dist < 8.0) {
- money = 1500 + floatround(-100 * dist, floatround_floor);
- if(money < 250) money = 250;
- GivePlayerMoney(owner, money);
- new id = random(sizeof(DropLocations)), string[144];
- format(string, sizeof(string), "DELIVERY: {FFFFFF}You've delivered a package and earned {2ECC71}$%d{FFFFFF}.", money);
- SendClientMessage(owner, 0x2ECC71FF, string);
- DestroyPlayerObject(owner, TraffickingObjects[owner][OBJECT_ZONE]);
- TraffickingObjects[owner][OBJECT_ZONE] = CreatePlayerObject(owner, 19946, DropLocations[id][dropX], DropLocations[id][dropY], DropLocations[id][dropZ], 0.0, 0.0, 0.0, 1200.0);
- SetPlayerMapIcon(owner, 69, DropLocations[id][dropX], DropLocations[id][dropY], DropLocations[id][dropZ], 24, 0, MAPICON_GLOBAL);
- format(string, sizeof(string), "DELIVERY: {FFFFFF}Drop the package in the marked area at {3498DB}%s{FFFFFF}.", DropLocations[id][dropLocation]);
- SendClientMessage(owner, 0x2ECC71FF, string);
- format(string, sizeof(string), "DELIVERY: {FFFFFF}Packages left: {3498DB}%d{FFFFFF}.", PackageCount[owner]);
- SendClientMessage(owner, 0x2ECC71FF, string);
- }else{
- SendClientMessage(owner, 0xE74C3CFF, "DELIVERY: {FFFFFF}Package didn't land in the marked area, better luck next time.");
- }
- DestroyObject(TraffickingObjects[owner][OBJECT_PACKAGE]);
- TraffickingObjects[owner][OBJECT_PACKAGE] = INVALID_OBJECT_ID;
- if(PackageCount[owner] == 0)
- {
- SendClientMessage(owner, 0x2ECC71FF, "DELIVERY: {FFFFFF}You're out of packages.");
- ResetDelivery(owner);
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement