Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #include <streamer>
- #define FILTERSCRIPT
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_RED 0xAA3333AA
- #define MAX_TRASH_CANS 20
- new TrashSkill[MAX_PLAYERS]; //Save this in SQL/yini/dini w/e if u want
- new Float:TRASH_PRICE,
- MAX_FACTORY_RESOURCES = 10000;
- new TrashcanObject[MAX_TRASH_CANS],
- TrashcanResources[MAX_TRASH_CANS],
- Text3D:TrashcanText[MAX_TRASH_CANS],
- TrashOnPlayer[MAX_PLAYERS], //Save this in SQL/yini/dini w/e if u want
- Text3D:TrashFactoryText,
- TrashFactoryResources,
- TotalEarnedFromTrash[MAX_PLAYERS], //Save this in SQL/yini/dini w/e if u want
- TotalTrashCollected[MAX_PLAYERS], //Save this in SQL/yini/dini w/e if u want
- VehicleTrash[MAX_VEHICLES];
- forward Float:GetTrashPrice();
- forward ChangeTrashPrice();
- forward UpdateTrashcans();
- forward Float:frandomEx(Float:min, Float:max);
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Trashmaster by Twinki");
- print("--------------------------------------\n");
- TRASH_PRICE = frandomEx(1.0,5.0);
- CreateTrashcan(0,0,1236, 1832.65869, -1878.72766, 13.08714, 0.00000, 0.00000, 0.00000);
- CreateTrashcan(0,1,1236, 1808.64380, -1882.34753, 13.22466, 0.00000, 0.00000, 0.00000);
- CreateTrashcan(0,2,1236, 1972.82422, -1782.74658, 13.17289, 0.00000, 0.00000, 0.00000);
- CreateTrashcan(0,3,1236, 2045.69812, -1740.98816, 13.15423, 0.00000, 0.00000, 90.00000);
- CreateTrashcan(0,4,1236, 2112.68066, -1790.14978, 13.12404, 0.00000, 0.00000, 0.00000);
- CreateTrashcan(0,5,1236, 2232.01758, -1688.12073, 13.63301, 0.00000, 0.00000, 0.00000);
- CreateTrashcan(0,6,1236, 1970.78918, -1970.21753, 13.15715, 0.00000, 0.00000, 90.00000);
- CreateTrashcan(0,7,1236, 1931.81104, -2096.23999, 13.12531, 0.00000, 0.00000, 0.00000);
- CreateTrashcan(0,8,1236, 2284.95874, -2066.20703, 13.14678, 0.00000, 0.00000, 45.00000);
- CreateTrashcan(0,9,1236, 2723.42236, -2005.76831, 13.11397, 0.00000, 0.00000, 90.00000);
- CreateTrashcan(0,10,1236, 2516.59814, -1774.16284, 13.15267, 0.00000, 0.00000, 0.00000);
- CreateTrashcan(0,11,1236, 1421.72192, -1043.13342, 23.37464, 0.00000, 0.00000, 0.00000);
- CreateTrashcan(0,12,1236, 1227.62195, -1271.63403, 13.18324, 0.00000, 0.00000, 0.00000);
- CreateTrashcan(0,13,1236, 1083.30225, -1384.33569, 13.39849, 0.00000, 0.00000, 90.00000);
- CreateTrashcan(0,14,1236, 615.13269, -1522.93030, 14.65041, 0.00000, 0.00000, 0.00000);
- CreateTrashcan(0,15,1236, 657.12463, -1766.36340, 13.20883, 0.00000, 0.00000, 77.00000);
- CreateTrashcan(0,16,1236, 1072.77515, -1883.04297, 13.12016, 0.00000, 0.00000, 0.00000);
- CreateTrashcan(0,17,1236, 1378.96277, -1889.41687, 13.08524, 0.00000, 0.00000, 90.00000);
- CreateTrashcan(0,18,1236, 1337.37939, -1760.76477, 13.05930, 0.00000, 0.00000, 90.00000);
- CreateTrashcan(0,19,1236, 858.76263, -1359.91516, 13.37865, 0.00000, 0.00000, 0.00000);
- Create3DTextLabel("{FFFF9F}Type {00FF00}/loadtrash {FFFF9F}to load the trashmaster with trash",COLOR_GREEN,2163.0125,-1971.2373,13.5533, 20.0, 0, 0);
- new string[128];
- format(string,sizeof(string),"{FFFFFF}Resources; {2FFF9F}%i/%i{FFFFFF}\nCurrent Price: {2FFF9F}%.2f$",GetFactoryResources(),GetMaxFactoryResources(),GetTrashPrice());
- TrashFactoryText = Create3DTextLabel(string,COLOR_GREEN,2194.0925, -1973.0626, 13.3654, 20.0, 0, 0);
- Create3DTextLabel("{FFFF9F}Type {00FF00}/droptrash {FFFF9F}to unload the trashmaster",COLOR_GREEN,2547.5715,-2221.8047,13.2977,20.0,0,0);
- for(new i = 0; i < sizeof(TrashcanObject); i++) {
- new rr = randomEx(1,100);
- TrashcanResources[i] = rr;
- format(string,sizeof(string),"{007BFF}%i{00FF00}/{FFFF00}100",TrashcanResources[i]);
- Update3DTextLabelText(TrashcanText[i],COLOR_GREEN,string);
- printf("Trashcan %i filled with %i resources",i,TrashcanResources[i]);
- }
- AddStaticVehicle(408,2189.6274,-1983.0913,14.0977,82.3771,0,0); // v1
- AddStaticVehicle(408,2188.6338,-1987.3062,14.0867,80.9790,0,0); // v2
- AddStaticVehicle(408,2189.2195,-1994.7833,14.0882,74.2583,0,0); // v3
- SetTimer("UpdateTrashcans",240000,true);
- SetTimer("ChangeTrashPrice",300000,true);
- return 1;
- }
- public OnFilterScriptExit()
- {
- for(new i = 0; i < sizeof(TrashcanObject); i++) {
- Delete3DTextLabel(TrashcanText[i]);
- DestroyDynamicObject(TrashcanObject[i]);
- }
- Delete3DTextLabel(TrashFactoryText);
- return 1;
- }
- #else
- main()
- {
- print("\n----------------------------------");
- print(" Blank Gamemode by your name here");
- print("----------------------------------\n");
- }
- #endif
- /* Commands for normal players */
- CMD:collecttrash(playerid,params[]) {
- if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"You cannot do this while inside vehicle");
- new Float:x, Float:y, Float:z;
- for(new i = 0; i < sizeof(TrashcanObject); i++) {
- GetDynamicObjectPos(TrashcanObject[i],x,y,z);
- if(IsPlayerInRangeOfPoint(playerid, 10.0, x,y,z)) {
- if(TrashcanResources[i] <= 0) return SendClientMessage(playerid,COLOR_RED,"This trash can is empty");
- if(GetPlayerTrash(playerid) >= 200) return SendClientMessage(playerid,COLOR_RED,"You already have too much trash on you");
- new string[64];
- TotalTrashCollected[playerid] += TrashcanResources[i];
- format(string,sizeof(string),"You took %i trash from this can",TrashcanResources[i]);
- SendClientMessage(playerid,COLOR_RED,string);
- GivePlayerTrash(playerid,TrashcanResources[i]);
- UpdateTrashcanResources(i, 0);
- UpdatePlayerTrashSkill(playerid);
- printf("Player trash skill %i",GetPlayerTrashSkill(playerid));
- break;
- }
- }
- return true;
- }
- CMD:selltrash(playerid,params[]) {
- if(TrashOnPlayer[playerid] <= 0) return SendClientMessage(playerid,COLOR_RED,"You dont have any trash on you to sell!");
- if(!IsPlayerInRangeOfPoint(playerid,10.0,2194.0925, -1973.0626, 13.3654)) return SendClientMessage(playerid,COLOR_RED,"You are not near the dumpyard in LS");
- if(GetFactoryResources() >= MAX_FACTORY_RESOURCES) return SendClientMessage(playerid,COLOR_RED,"Factory is already full!");
- PayByResources(playerid,TrashOnPlayer[playerid]);
- GivePlayerTrash(playerid,-TrashOnPlayer[playerid]);
- UpdateResources(TrashOnPlayer[playerid]);
- GivePlayerMoney(playerid,-GetTrashTax(playerid));
- new string[128];
- format(string,sizeof(string),"You have paid %i$ as a state tax",GetTrashTax(playerid));
- SendClientMessage(playerid,COLOR_RED,string);
- return true;
- }
- CMD:mytrash(playerid,params[]) {
- new string[128];
- format(string,sizeof(string),"{00AAFF}Total Earned: {FFFF00}%i$ {00AAFF}Current Tax: {FFFF00}%i$ {00AAFF}Total Trash: {FFFF00}%i ",TotalEarnedFromTrash[playerid],GetTrashTax(playerid),TotalTrashCollected[playerid]);
- SendClientMessage(playerid,COLOR_GREEN,string);
- return true;
- }
- CMD:loadtrash(playerid,params[]) {
- if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not inside any vehicles");
- if(!IsPlayerInTrashmaster(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not inside trashmaster");
- if(!IsPlayerInRangeOfPoint(playerid,10.0,2163.0125,-1971.2373,13.5533)) return SendClientMessage(playerid,COLOR_RED,"You are not at the LS dumpyard");
- if(GetFactoryResources() <= 999) return SendClientMessage(playerid,COLOR_RED,"There are not enough materials inside the factory!");
- new vid = GetPlayerVehicleID(playerid);
- if(VehicleTrash[vid] >= 999) return SendClientMessage(playerid,COLOR_RED,"This vehicle is already full");
- VehicleTrash[vid] = 1000;
- UpdateResources(-1000);
- SendClientMessage(playerid,COLOR_RED,"You have loaded your truck with 1000 trash. Go to LS dumpyard and type /droptrash");
- return true;
- }
- CMD:droptrash(playerid,params[]) {
- if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not inside any vehicles");
- if(!IsPlayerInTrashmaster(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not inside trashmaster");
- if(!IsPlayerInRangeOfPoint(playerid,10.0,2547.5715,-2221.8047,13.2977)) return SendClientMessage(playerid,COLOR_RED,"You are not at the drop point!");
- new vid = GetPlayerVehicleID(playerid);
- if(VehicleTrash[vid] <= 999) return SendClientMessage(playerid,COLOR_RED,"This truck doesnt have any trash!");
- GivePlayerMoney(playerid,GetPaymentBasedOnSkill(playerid));
- VehicleTrash[vid] = 0;
- new string[128];
- format(string,sizeof(string),"You have delivered 1000 trash and received %i$",GetPaymentBasedOnSkill(playerid));
- SendClientMessage(playerid,COLOR_GREEN,string);
- return true;
- }
- /* Functions */
- GetPlayerTrash(playerid) return TrashOnPlayer[playerid];
- GivePlayerTrash(playerid, amount) { TrashOnPlayer[playerid] += amount; }
- Float:GetTrashPrice() return TRASH_PRICE;
- GetFactoryResources() return TrashFactoryResources;
- UpdateFactoryResources(amount) { TrashFactoryResources += amount; }
- GetMaxFactoryResources() return MAX_FACTORY_RESOURCES;
- UpdatePlayerTrashSkill(playerid) { TrashSkill[playerid] += 1; }
- GetPlayerTrashSkill(playerid) return TrashSkill[playerid];
- stock CreateTrashcan(ResourceAmount,UniqueID,ID, Float:X,Float:Y,Float:Z,Float:RX,Float:RY,Float:RZ) {
- TrashcanObject[UniqueID] = CreateDynamicObject(ID,X,Y,Z,RX,RY,RZ);
- TrashcanText[UniqueID] = Create3DTextLabel("{007BFF}0{00FF00}/{FFFF00}100",0x008080FF,X,Y,Z,20.0,0,0);
- TrashcanResources[UniqueID] = ResourceAmount;
- }
- stock IsPlayerInTrashmaster(playerid) {
- if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 408) return true;
- return false;
- }
- UpdateResources(amount) {
- UpdateFactoryResources(amount);
- new string[128];
- format(string,sizeof(string),"{FFFFFF}Resources; {2FFF9F}%i/%i{FFFFFF}\nCurrent Price: {2FFF9F}%.2f$",GetFactoryResources(),GetMaxFactoryResources(),GetTrashPrice());
- Update3DTextLabelText(TrashFactoryText,COLOR_GREEN,string);
- }
- PayByResources(playerid,Float:amount) {
- new Float:calc = GetTrashPrice()*amount;
- printf("%.2f*%.2f",GetTrashPrice(),amount);
- new pp = floatround(calc, floatround_round);
- new calc2 = floatround(amount,floatround_round);
- GivePlayerMoney(playerid,pp);
- new string[128];
- format(string,sizeof(string),"You have received %i$ for %i trash. Current trash price %.2f$",pp, calc2, GetTrashPrice());
- SendClientMessage(playerid,COLOR_GREEN,string);
- TotalEarnedFromTrash[playerid] += pp;
- return true;
- }
- stock UpdateTrashcanResources(tID, ress) {
- TrashcanResources[tID] = ress;
- new string[64];
- format(string,sizeof(string),"{007BFF}%i{00FF00}/{FFFF00}100",TrashcanResources[tID]);
- Update3DTextLabelText(TrashcanText[tID],COLOR_GREEN,string);
- }
- stock GetTrashTax(playerid) {
- new current_tax_price;
- switch(GetPlayerTrashSkill(playerid)) {
- case 0 .. 100: current_tax_price = 20;
- case 101 .. 250: current_tax_price = 15;
- case 251 .. 500: current_tax_price = 10;
- case 501 .. 1000: current_tax_price = 5;
- case 1001 .. 9999: current_tax_price = 0;
- }
- return current_tax_price;
- }
- stock GetPaymentBasedOnSkill(playerid) {
- new earnings_Now;
- switch(GetPlayerTrashSkill(playerid)) {
- case 0 .. 100: earnings_Now = 100;
- case 101 .. 250: earnings_Now = 120;
- case 251 .. 500: earnings_Now = 150;
- case 501 .. 1000: earnings_Now = 200;
- case 1001 .. 9999: earnings_Now = 250;
- }
- return earnings_Now;
- }
- stock randomEx(minnum = cellmin, maxnum = cellmax) return random(maxnum - minnum + 1) + minnum; //Y_Less
- stock Float:frandomEx(Float:min, Float:max) return min + (max - min) * random(32768) / 32768.0; // Y_Less
- /* Timers */
- public UpdateTrashcans() {
- new rrX = randomEx(1,10);
- for(new i = 0; i < sizeof(TrashcanObject); i++) {
- if(TrashcanResources[i] <= 95) {
- TrashcanResources[i] += rrX;
- new string[128];
- format(string,sizeof(string),"{007BFF}%i{00FF00}/{FFFF00}100",TrashcanResources[i]);
- Update3DTextLabelText(TrashcanText[i],COLOR_GREEN,string);
- printf("Trash can ID: %i now has %i resources",i,TrashcanResources[i]);
- if(TrashcanResources[i] >= 101) {
- TrashcanResources[i] = 100;
- }
- }
- }
- return true;
- }
- public ChangeTrashPrice() {
- new Float:rr = frandomEx(1,5), string[128];
- TRASH_PRICE = rr;
- format(string,sizeof(string),"{FFFFFF}Resources; {2FFF9F}%i/%i{FFFFFF}\nCurrent Price: {2FFF9F}%.2f$",GetFactoryResources(),GetMaxFactoryResources(),GetTrashPrice());
- Update3DTextLabelText(TrashFactoryText,COLOR_GREEN,string);
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement