Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //------------------------------------------||
- //---------||^^^^^^^^^^^^^^^^^^||-----------||
- //---------|| Fishing System ||-----------||
- //---------|| v1.0 ||-----------||
- //---------|| By BumbiS* ||-----------||
- //---------||__________________||-----------||
- //------------------------------------------||
- //---------|| Do NOT remove credits ||------||
- //------------------------------------------||
- //---------|| Credits ||--------------------||
- //------|| BumbiS* for creating this FS ||--||
- //-------|| DracoBlue for dcmd ||-----------||
- //--------|| Y_Less for randomEx ||---------||
- //------------------------------------------||
- #include <a_samp>
- #include <string>
- #include <core>
- //--------|| Here you can basically change prices ||-------||
- #define BaitPrice 15
- #define FishingToolPrice 150
- //--------|| dcmd by DracoBlue ||---------------------||
- #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- //--------|| Colors ||--------------------------------||
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_GREEN 0x9EC73DAA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_YELLOW 0xDABB3EAA
- #define COLOR_YELLOW2 0xF5DEB3AA
- #define COLOR_GREENYELLOW 0xADFF2FFF
- #define COLOR_PURPLE 0xB370FCFF
- #define COLOR_WHITE 0xFFFFFFAA
- //----------------------------------------------------||
- new Fishes[MAX_PLAYERS];
- new AlreadyFished[MAX_PLAYERS];
- new FishingTool[MAX_PLAYERS];
- new Worms[MAX_PLAYERS];
- new FishWeight[MAX_PLAYERS];
- new IsFishing[MAX_PLAYERS];
- new fishing;
- forward IsAtFishPlace(playerid);
- forward FishTime(playerid);
- forward SendRPMessage(playerid, Float:radius, color, string[]);
- forward StopFish(playerid);
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Fishing System by BumbiS* started");
- print("--------------------------------------\n");
- /////////////////////////////////////////////////
- fishing = AddStaticPickup(1239, 23, 153.9523,-1946.2955,5.1874);
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- Worms[playerid] = 0; FishingTool[playerid] = 0; AlreadyFished[playerid] = 0;
- Fishes[playerid] = 0; FishWeight[playerid] = 0; IsFishing[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- Worms[playerid] = 0; FishingTool[playerid] = 0; AlreadyFished[playerid] = 0;
- Fishes[playerid] = 0; FishWeight[playerid] = 0; IsFishing[playerid] = 0;
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- Worms[playerid] = 0; FishWeight[playerid] = 0;
- Fishes[playerid] = 0; FishingTool[playerid] = 0;
- return 1;
- }
- //-----------DCMD Commands--------------------||
- dcmd_buytools(playerid, params[])
- {
- #pragma unused params
- if(IsPlayerInRangeOfPoint(playerid, 2.5,153.9523,-1946.2955,5.1874))
- {
- new string[128];
- format(string,128,"FishingTools $%d\nWorms $%d per one",FishingToolPrice,BaitPrice);
- ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Fishing tools", string,"Purchase","Exit");
- return 1;
- }
- return 1;
- }
- dcmd_inventory(playerid, params[])
- {
- #pragma unused params
- new string[128];
- new string2[128];
- new string3[128];
- SendClientMessage(playerid, COLOR_GREEN, "____|| Your inventory ||___");
- if(FishingTool[playerid]==1)
- {
- format(string,sizeof(string)," - Fishing Tool");
- SendClientMessage(playerid, COLOR_YELLOW, string);
- }
- if(Worms[playerid]>0)
- {
- format(string2,sizeof(string2)," - %d Worms", Worms[playerid]);
- SendClientMessage(playerid, COLOR_YELLOW, string2);
- }
- if(Fishes[playerid]>0)
- {
- format(string3,sizeof(string3)," - %d fishes", Fishes[playerid]);
- SendClientMessage(playerid, COLOR_YELLOW, string3);
- }
- SendClientMessage(playerid, COLOR_GREEN, "___________________________");
- return 1;
- }
- dcmd_fishhelp(playerid,params[])
- {
- #pragma unused params
- SendClientMessage(playerid,COLOR_GREEN,"________|| Fishing Help ||___________");
- SendClientMessage(playerid,COLOR_WHITE,"/inventory /buytools");
- SendClientMessage(playerid,COLOR_WHITE,"/fish");
- SendClientMessage(playerid,COLOR_WHITE,"/releaseallfishes");
- SendClientMessage(playerid,COLOR_WHITE,"/sellfishes");
- SendClientMessage(playerid,COLOR_GREEN,"_____________________________________");
- return 1;
- }
- dcmd_releaseallfishes(playerid,params[])
- {
- #pragma unused params
- if(Fishes[playerid] > 0 && IsAtFishPlace(playerid))
- {
- SendClientMessage(playerid, COLOR_YELLOW2, "You released all fishes back in sea.");
- Fishes[playerid] = 0;
- FishWeight[playerid] = 0;
- return 1;
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, "You already don't have fishes or you are not at fishing place(Big Wheel)");
- return 1;
- }
- }
- dcmd_fish(playerid,params[])
- {
- #pragma unused params
- new string[128];
- new name[MAX_PLAYER_NAME];
- if(FishingTool[playerid] == 1)
- {
- if(Worms[playerid] > 0)
- {
- if(IsAtFishPlace(playerid))
- {
- if(AlreadyFished[playerid] == 0 && IsFishing[playerid] == 0)
- {
- if(Fishes[playerid] >= 15)
- {
- SendClientMessage(playerid,COLOR_RED,"You have enough fishes and you are tiered of fishing.");
- SendClientMessage(playerid,COLOR_RED,"You can sell your fishes at Los Santos docks (/sellfish @ CheckPoint)");
- AlreadyFished[playerid] = 1;
- SetPlayerCheckpoint(playerid, 2766.6602,-2575.1614,3.0000,3.0);
- SetTimerEx("StopFish", 1000*60*10, 0, "i",playerid);
- }
- else
- {
- new random2 = randomEx(4000,14000);
- IsFishing[playerid] = 1;
- SetTimerEx("FishTime", random2, 0, "i",playerid);
- GetPlayerName(playerid,name,sizeof(name));
- format(string,sizeof(string),"%s swings fishing rod and starts to wait for fish",name);
- SendRPMessage(playerid, 20.0, COLOR_PURPLE, string);
- GameTextForPlayer(playerid, "~w~Fishing...",random2,3);
- TogglePlayerControllable(playerid, false);
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, "You need to wait some time to fish again.");
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, "You are not at fishing place(Big Whell or on water)");
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, "You dont have any Baits, buy them at lighthouse");
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, "You don't have fishing tools, buy them at lighthouse");
- }
- return 1;
- }
- dcmd_sellfish(playerid,params[])
- {
- #pragma unused params
- if(Fishes[playerid] >= 1)
- {
- if(IsPlayerInRangeOfPoint(playerid, 3.0,2766.6602,-2575.1614,3.0000))
- {
- new string[128];
- Fishes[playerid] = 0;
- format(string,sizeof(string),"You sold all your fishes for $%d.", FishWeight[playerid]);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- GivePlayerMoney(playerid, FishWeight[playerid]);
- FishWeight[playerid] = 0;
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, "You need to be at Los Santos docks.");
- SetPlayerCheckpoint(playerid, 2766.6602,-2575.1614,3.0000,3.0);
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, "You dont have any fishes that you can sell.");
- return 1;
- }
- return 1;
- }
- //--------------------------------------------||
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(buytools,8,cmdtext);
- dcmd(inventory,9,cmdtext);
- dcmd(fishhelp,8,cmdtext);
- dcmd(releaseallfishes,16,cmdtext);
- dcmd(fish,4,cmdtext);
- dcmd(sellfish,8,cmdtext);
- return 0;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- if(IsPlayerInRangeOfPoint(playerid, 3.0,2766.6602,-2575.1614,3.0000))
- {
- if(Fishes[playerid] >= 1)
- {
- new string[128];
- Fishes[playerid] = 0;
- format(string,sizeof(string),"You sold all your fishes for $%d.", FishWeight[playerid]);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- GivePlayerMoney(playerid, FishWeight[playerid]);
- FishWeight[playerid] = 0;
- DisablePlayerCheckpoint(playerid);
- return 1;
- }
- }
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- if(pickupid == fishing)
- {
- GameTextForPlayer(playerid, "~w~You can buy here~n~some fishing tools~n~type ~r~/buytools ~w~to buy some", 3500, 3);
- }
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == 1)
- {
- if(listitem == 0)
- {
- if(GetPlayerMoney(playerid) >= FishingToolPrice)
- {
- SendClientMessage(playerid, COLOR_YELLOW, "Successfully purchased Fishing tool! You can now use /fish");
- SendClientMessage(playerid, COLOR_YELLOW, ", but you also need some baits");
- FishingTool[playerid] = 1;
- GivePlayerMoney(playerid, -FishingToolPrice);
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, "You don't have enough money");
- }
- }
- if(listitem == 1)
- {
- new string[128];
- format(string,sizeof(string),"Enter below how much baits do you want.\n$%d per one",BaitPrice);
- ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Baits",string,"Purchase","Exit");
- }
- }
- if(dialogid == 2 && response)
- {
- new price = BaitPrice;
- new string[128];
- new baits = strval(inputtext);
- if(baits > 0)
- {
- new price1 = price*baits;
- if(GetPlayerMoney(playerid) >= price1)
- {
- GivePlayerMoney(playerid, -price1);
- format(string,sizeof(string),"You just purchased %d worms for $%d", baits, price1);
- SendClientMessage(playerid, COLOR_GREEN, string);
- Worms[playerid] += baits;
- return 1;
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, "You don't have that much money.");
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, "You can't buy baits less than 0");
- }
- }
- return 1;
- }
- public IsAtFishPlace(playerid)
- {
- if(IsPlayerConnected(playerid))
- {
- if(IsPlayerInRangeOfPoint(playerid,1.0,403.8266,-2088.7598,7.8359) || IsPlayerInRangeOfPoint(playerid,1.0,398.7553,-2088.7490,7.8359))
- {
- return 1;
- }
- else if(IsPlayerInRangeOfPoint(playerid,1.0,396.2197,-2088.6692,7.8359) || IsPlayerInRangeOfPoint(playerid,1.0,391.1094,-2088.7976,7.8359))
- {
- return 1;
- }
- else if(IsPlayerInRangeOfPoint(playerid,1.0,383.4157,-2088.7849,7.8359) || IsPlayerInRangeOfPoint(playerid,1.0,374.9598,-2088.7979,7.8359))
- {
- return 1;
- }
- else if(IsPlayerInRangeOfPoint(playerid,1.0,369.8107,-2088.7927,7.8359) || IsPlayerInRangeOfPoint(playerid,1.0,367.3637,-2088.7925,7.8359))
- {
- return 1;
- }
- else if(IsPlayerInRangeOfPoint(playerid,1.0,362.2244,-2088.7981,7.8359) || IsPlayerInRangeOfPoint(playerid,1.0,354.5382,-2088.7979,7.8359))
- {
- return 1;
- }
- else if(IsPlayerInWater(playerid))
- {
- return 1;
- }
- }
- return 0;
- }
- public FishTime(playerid)
- {
- new string[128];
- if(IsPlayerConnected(playerid))
- {
- new rand = randomEx(1,11);
- new weight = randomEx(50,180);
- new money = randomEx(20, 80);
- if(rand == 1)
- {
- SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out some trash and throwed it back in sea");
- Worms[playerid] -= 1;
- IsFishing[playerid] = 0;
- TogglePlayerControllable(playerid,true);
- return 1;
- }
- else if(rand == 2)
- {
- SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out tuna!");
- Fishes[playerid] += 1;
- Worms[playerid] -= 1;
- IsFishing[playerid] = 0;
- FishWeight[playerid] += weight;
- TogglePlayerControllable(playerid,true);
- return 1;
- }
- else if(rand == 3)
- {
- SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Swordfish!");
- Fishes[playerid] += 1;
- IsFishing[playerid] = 0;
- Worms[playerid] -= 1;
- FishWeight[playerid] += weight;
- TogglePlayerControllable(playerid,true);
- return 1;
- }
- else if(rand == 4)
- {
- SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Blue Marlin!");
- Fishes[playerid] += 1;
- Worms[playerid] -= 1;
- IsFishing[playerid] = 0;
- FishWeight[playerid] += weight;
- TogglePlayerControllable(playerid,true);
- return 1;
- }
- else if(rand == 5)
- {
- SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Shark!");
- Fishes[playerid] += 1;
- Worms[playerid] -= 1;
- IsFishing[playerid] = 0;
- FishWeight[playerid] += weight;
- TogglePlayerControllable(playerid,true);
- return 1;
- }
- else if(rand == 6)
- {
- format(string,sizeof(string),"You just fished out Wallet and in there was $%d!", money);
- SendClientMessage(playerid,COLOR_GREENYELLOW,string);
- GivePlayerMoney(playerid, money);
- Worms[playerid] -= 1;
- TogglePlayerControllable(playerid,true);
- IsFishing[playerid] = 0;
- return 1;
- }
- else if(rand == 7)
- {
- SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Eel!");
- Fishes[playerid] += 1;
- TogglePlayerControllable(playerid,true);
- Worms[playerid] -= 1;
- IsFishing[playerid] = 0;
- FishWeight[playerid] += weight;
- return 1;
- }
- else if(rand == 8)
- {
- SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Sea Bass!");
- Fishes[playerid] += 1;
- Worms[playerid] -= 1;
- TogglePlayerControllable(playerid,true);
- IsFishing[playerid] = 0;
- FishWeight[playerid] += weight;
- return 1;
- }
- else if(rand == 9)
- {
- SendClientMessage(playerid,COLOR_GREENYELLOW,"You just fished out Sail Fish!");
- Fishes[playerid] += 1;
- TogglePlayerControllable(playerid,true);
- Worms[playerid] -= 1;
- IsFishing[playerid] = 0;
- FishWeight[playerid] += weight;
- return 1;
- }
- else if(rand == 10)
- {
- SendClientMessage(playerid,COLOR_GREENYELLOW,"You didnt catch anything.");
- Worms[playerid] -= 1;
- TogglePlayerControllable(playerid,true);
- IsFishing[playerid] = 0;
- return 1;
- }
- else
- {
- SendClientMessage(playerid,COLOR_GREENYELLOW,"You didnt catch anything, but you your worm remained");
- IsFishing[playerid] = 0;
- TogglePlayerControllable(playerid,true);
- return 1;
- }
- }
- return 0;
- }
- //-----------|| Function By Bumbis ||--------------||
- public SendRPMessage(playerid, Float:radius, color, string[])
- {
- if(IsPlayerConnected(playerid))
- {
- for(new i=0;i<MAX_PLAYERS;i++)
- {
- new Float:x,Float:y,Float:z;
- GetPlayerPos(playerid,x,y,z);
- if(IsPlayerInRangeOfPoint(i, radius, x,y,z))
- {
- SendClientMessage(i,color,string);
- return 1;
- }
- }
- }
- return 0;
- }
- //--------------------------------------------------||
- //-----------|| By Y_Less ||---------------||
- stock randomEx(minnum = cellmin, maxnum = cellmax) return random(maxnum - minnum + 1) + minnum;
- //----------|| Unknown creator of this, but thanks ||--||
- stock IsPlayerInWater(playerid)
- {
- new Float:x,Float:y,Float:pz;
- GetPlayerPos(playerid,x,y,pz);
- if (
- (IsPlayerInArea(playerid, 2032.1371, 1841.2656, 1703.1653, 1467.1099) && pz <= 9.0484) //lv piratenschiff
- || (IsPlayerInArea(playerid, 2109.0725, 2065.8232, 1962.5355, 10.8547) && pz <= 10.0792) //lv visage
- || (IsPlayerInArea(playerid, -492.5810, -1424.7122, 2836.8284, 2001.8235) && pz <= 41.06) //lv staucamm
- || (IsPlayerInArea(playerid, -2675.1492, -2762.1792, -413.3973, -514.3894) && pz <= 4.24) //sf südwesten kleiner teich
- || (IsPlayerInArea(playerid, -453.9256, -825.7167, -1869.9600, -2072.8215) && pz <= 5.72) //sf gammel teich
- || (IsPlayerInArea(playerid, 1281.0251, 1202.2368, -2346.7451, -2414.4492) && pz <= 9.3145) //ls neben dem airport
- || (IsPlayerInArea(playerid, 2012.6154, 1928.9028, -1178.6207, -1221.4043) && pz <= 18.45) //ls mitte teich
- || (IsPlayerInArea(playerid, 2326.4858, 2295.7471, -1400.2797, -1431.1266) && pz <= 22.615) //ls weiter südöstlich
- || (IsPlayerInArea(playerid, 2550.0454, 2513.7588, 1583.3751, 1553.0753) && pz <= 9.4171) //lv pool östlich
- || (IsPlayerInArea(playerid, 1102.3634, 1087.3705, -663.1653, -682.5446) && pz <= 112.45) //ls pool nordwestlich
- || (IsPlayerInArea(playerid, 1287.7906, 1270.4369, -801.3882, -810.0527) && pz <= 87.123) //pool bei maddog's haus oben
- || (pz < 1.5)
- )
- {
- return 1;
- }
- return 0;
- }
- stock IsPlayerInArea(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
- {
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerid, x, y, z);
- if (x > minx && x < maxx && y > miny && y < maxy) return 1;
- return 0;
- }
- //----------------------------------------------------||
- public StopFish(playerid)
- {
- AlreadyFished[playerid] = 0;
- SendClientMessage(playerid, COLOR_GREEN, "Hey, you can fish now!");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment