Ksardas |
Дата: Понедельник, 22.05.2017, 13:13 | Сообщение # 1
|
Сообщений: 1311
Статус: Offline
|
Доброго времени суток друзья!Сегодня я расскажу вам как добавить рыбалку на свой сервер!
Ко всем new добавляем:
Код new RodObject; new FishMarketIcon; new FishInfoIcon; new FRod[MAX_PLAYERS]; new Fishing[MAX_PLAYERS]; new Bait[MAX_PLAYERS]; new FLine[MAX_PLAYERS]; Ко всем forward добавляем:
Код forward VaildFishPlace(playerid); forward FishTimer(playerid); forward AnimFixer(playerid); forward LeavePosition(playerid); Далее:
Код public OnPlayerConnect
Код Добавляем: SetPlayerMapIcon( playerid, 0, 377.1194,-2121.7058,-0.5328, 9, 0, MAPICON_LOCAL ); После добавляем в:
Код public OnGameModeInit()
Код Create3DTextLabel("{FFA500}Информация: {00BFFF}Рыбалка",0xFFFFDD,382.4216,-2080.1860,7.8359,20.0,0,1); FishInfoIcon = CreatePickup(1239, 2, 382.4216,-2080.1860,7.8359, -1); Create3DTextLabel("{FFA500}Магазин: {00BFFF}Рыбный рынок",0xFFFFDD,359.3295,-2032.0739,7.8359,20.0,0,1); FishMarketIcon = CreatePickup(1318, 2, 359.3295,-2032.0739,7.8359, -1);
Далее идём в:
Код public OnPlayerCommandText( И добавляем:
Код if (strcmp("/fishinfo", cmdtext, true, 10) == 0) { SendClientMessage(playerid,0xFFFFFFFF, "Рыбалка:"); SendClientMessage(playerid,0xFFFFFFFF, "{C0C0C0}/fish {FFFFFF}- начать рыбалку"); SendClientMessage(playerid,0xFFFFFFFF, "{C0C0C0}/fishend {FFFFFF}- остановить рыбалку"); SendClientMessage(playerid,0xFFFFFFFF, "{C0C0C0}/+rod {FFFFFF}- взять удочку"); SendClientMessage(playerid,0xFFFFFFFF, "{C0C0C0}/-rod {FFFFFF}- убрать удочку"); return 1; } if (strcmp("/+rod", cmdtext, true, 10) == 0) { if(FRod[playerid] == 1) { FRod[playerid] = 2; RodObject = SetPlayerAttachedObject(playerid, 0,18632,6,0.079376,0.037070,0.007706,181.482910,0.000000,0.000000,1.000000,1.000000,1.000000); } else { SendClientMessage(playerid,0xFFFFFFFF, "{FF0000}x{FFFFFF} У Вас нет удочки!"); } return 1; } if (strcmp("/-rod", cmdtext, true, 10) == 0) { if(FRod[playerid] == 2 || FRod[playerid] == 1 || Fishing[playerid] == 0) { FRod[playerid] = 1; RemovePlayerAttachedObject(playerid,0); RemovePlayerAttachedObject(playerid,RodObject); } else { SendClientMessage(playerid,0xFFFFFFFF, "{FF0000}x{FFFFFF} У Вас нет ни чего, чем можно ловить рыбу!"); } return 1; } if (strcmp("/fishend", cmdtext, true, 10) == 0) { if(Fishing[playerid] == 1) { Fishing[playerid] = 0; TogglePlayerControllable(playerid, 1); ApplyAnimation(playerid, "CARRY", "crry_prtial", 2.0, 0, 0, 0, 0, 0); SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}x{FFFFFF} Рыбалка остановлена"); GameTextForPlayer(playerid,"~w~fishing ~r~stopped", 3000, 3); } else { SendClientMessage(playerid,0xFFFFFFFF, "{FF0000}x{FFFFFF} Рыбалка не была начата!"); } return 1; } if (strcmp("/fish", cmdtext, true, 10) == 0) { if(VaildFishPlace(playerid) && !IsPlayerInAnyVehicle(playerid)) { if(Bait[playerid] > 0) { if(FLine[playerid] > 0) { if(FRod[playerid] == 2) { if(Fishing[playerid] == 0) { TogglePlayerControllable(playerid, 0); ApplyAnimation(playerid,"SWORD","sword_block",50.0,0,1,0,1,1); Fishing[playerid] = 1; SetTimerEx("FishTimer", 50000, false, "i", playerid); SetTimerEx("LeavePosition", 40000, false, "i", playerid); SetTimerEx("AnimFixer", 1000, false, "i", playerid); SendClientMessage(playerid,0xFFFFFFFF, "{00FF00}х {FFFFFF}Вы начали рыбачить!"); GameTextForPlayer(playerid,"~w~fishing ~g~started", 49000, 3); } else { SendClientMessage(playerid,0xCD0000FF, "{FF0000}x{FFFFFF} Вы уже ловили!"); } return 1; } return SendClientMessage(playerid,0xFFFFFFFF, "{FF0000}x{FFFFFF} Возмите удочку в руки!"); } return SendClientMessage(playerid,0xFFFFFFFF, "{FF0000}x{FFFFFF} У Вас нет лесок в запасе!"); } return SendClientMessage(playerid,0xFFFFFFFF, "{FF0000}x{FFFFFF} У Вас нет приманок в запасе!"); } return SendClientMessage(playerid,0xFFFFFFFF, "{FF0000}x{FFFFFF} В этом месте запрещена рыбалка!"); } После ищем:
Код public OnPlayerPickUpPickup(playerid, pickupid) И вставляем:
Код if(pickupid == FishMarketIcon) { ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Рыбный рынок", "Удочка (50$)\nПриманка (35$)\nЛеска (15$)\nПолный комплект (100$)", "Купить", "Отмена"); return 1; } if(pickupid == FishInfoIcon) { SendClientMessage(playerid, 0xFFFFFFFF, "х {C0C0C0}=================[ {FFFFFF}Рыбалка{C0C0C0} ]================"); SendClientMessage(playerid, 0xFFFFFFFF, "х {C0C0C0}/+rod {FFFFFF}- взять удочку"); SendClientMessage(playerid, 0xFFFFFFFF, "х {C0C0C0}/-rod {FFFFFF}- убрать удочку"); SendClientMessage(playerid, 0xFFFFFFFF, "х {C0C0C0}/fish {FFFFFF}- начать рыбалку"); SendClientMessage(playerid, 0xFFFFFFFF, "х {C0C0C0}/fishend {FFFFFF}- остановить рыбалку"); } Далее идём:
Код public OnDialogResponse И вставляем:
Код case 1: { if(!response) return SendClientMessage(playerid, 0xFFFFFFFF,"Вы закончили покупки"); switch(listitem) { case 0: { if(IsPlayerInRangeOfPoint(playerid, 2, 359.3295,-2032.0739,7.8359) && GetPlayerMoney(playerid) >= 50) { if(FRod[playerid] == 0) { FRod[playerid] = 1; SendClientMessage(playerid,0xFFFFFFFF, "{00FF00}x{FFFFFF} Удочка куплена!"); GameTextForPlayer(playerid,"~r~-50$", 1200, 1); GivePlayerMoney(playerid,-50); } else { SendClientMessage(playerid,0xFFFFFFFF, "{FF0000}x{FFFFFF} Вы уже купили удочку!"); } return 1; } } case 1: { if(IsPlayerInRangeOfPoint(playerid, 2, 359.3295,-2032.0739,7.8359) && GetPlayerMoney(playerid) >= 35) { if(Bait[playerid] == 0) { Bait[playerid] = 1; SendClientMessage(playerid,0xFFFFFFFF, "{00FF00}x{FFFFFF} Приманка куплена!"); GameTextForPlayer(playerid,"~r~-35$", 1200, 1); GivePlayerMoney(playerid,-35); } else { SendClientMessage(playerid,0xFFFFFFFF, "{FF0000}x{FFFFFF} Вы уже купили приманку!"); } return 1; } } case 2: { if(IsPlayerInRangeOfPoint(playerid, 2, 359.3295,-2032.0739,7.8359) && GetPlayerMoney(playerid) >= 15) { if(FLine[playerid] == 0) { FLine[playerid] = 1; SendClientMessage(playerid,0xFFFFFFFF, "{00FF00}x{FFFFFF} Леска куплена!"); GameTextForPlayer(playerid,"~r~-15$", 1200, 1); GivePlayerMoney(playerid,-15); } else { SendClientMessage(playerid,0xFFFFFFFF, "{FF0000}x{FFFFFF} Вы уже купили леску!"); } return 1; } } case 3: { if(IsPlayerInRangeOfPoint(playerid, 2, 359.3295,-2032.0739,7.8359) && GetPlayerMoney(playerid) >= 100) { if(FLine[playerid] == 0) if(Bait[playerid] == 0) if(FRod[playerid] == 0) { FLine[playerid] = 1; Bait[playerid] = 1; FRod[playerid] = 1; SendClientMessage(playerid,0xFFFFFFFF, "{00FF00}x{FFFFFF} Удочка, приманка и леска куплены!"); GameTextForPlayer(playerid,"~r~-100$", 1200, 1); GivePlayerMoney(playerid,-100); } else { SendClientMessage(playerid,0xFFFFFFFF, "{FF0000}x{FFFFFF} Вы уже купили удочку, приманку и леску!"); } return 1; } } } return true; } } В конечном итоге всталяем это:
Код public VaildFishPlace(playerid) { if(IsPlayerConnected(playerid)) { if(IsPlayerInRangeOfPoint(playerid, 4,403.8266,-2088.7598,7.8359) || IsPlayerInRangeOfPoint(playerid, 4,398.7553,-2088.7490,7.8359)) { return 1; } else if(IsPlayerInRangeOfPoint(playerid, 4,396.2197,-2088.6692,7.8359) || IsPlayerInRangeOfPoint(playerid, 4,391.1094,-2088.7976,7.8359)) { return 1; } else if(IsPlayerInRangeOfPoint(playerid, 4,383.4157,-2088.7849,7.8359) || IsPlayerInRangeOfPoint(playerid, 4,374.9598,-2088.7979,7.8359)) { return 1; } else if(IsPlayerInRangeOfPoint(playerid, 4,369.8107,-2088.7927,7.8359) || IsPlayerInRangeOfPoint(playerid, 4,367.3637,-2088.7925,7.8359)) { return 1; } else if(IsPlayerInRangeOfPoint(playerid, 4,362.2244,-2088.7981,7.8359) || IsPlayerInRangeOfPoint(playerid, 4,354.5382,-2088.7979,7.8359)) { return 1; } } return 0; }
public FishTimer(playerid) { if(VaildFishPlace(playerid)) { if(Fishing[playerid] == 1) { new fish = random(10); new fishname[100]; new string[256]; if(fish == 1) { fishname = "{00FF00}х {FFFFFF}Вы поймали {88AA88}Ерша {FFFFFF}и продали на рынке за {88AA88}1 вирт{FFFFFF}!"; } else if(fish == 2) { fishname = "{00FF00}х {FFFFFF}Вы поймали {88AA88}Окуня {FFFFFF}и продали на рынке за {88AA88}3 вирта{FFFFFF}!"; } else if(fish == 3) { fishname = "{00FF00}х {FFFFFF}Вы поймали {88AA88}Карася {FFFFFF}и продали на рынке за {88AA88}5 вирт{FFFFFF}!"; } else if(fish == 4) { fishname = "{00FF00}х {FFFFFF}Вы поймали {88AA88}Щуку {FFFFFF}и продали на рынке за {88AA88}8 вирт{FFFFFF}!"; } else if(fish == 5) { fishname = "{00FF00}х {FFFFFF}Вы поймали {88AA88}Белугу {FFFFFF}и продали на рынке за {88AA88}10 вирт{FFFFFF}!"; } else if(fish == 6) { fishname = "{00FF00}х {FFFFFF}Вы поймали {88AA88}Кету {FFFFFF}и продали на рынке за {88AA88}13 вирт{FFFFFF}!"; } else if(fish == 7) { fishname = "{00FF00}х {FFFFFF}Вы поймали {88AA88}Горбушу {FFFFFF}и продали на рынке за {88AA88}15 вирт{FFFFFF}!"; } else if(fish == 8) { fishname = "{00FF00}х {FFFFFF}Вы поймали {88AA88}Семгу {FFFFFF}и продали на рынке за {88AA88}18 вирт{FFFFFF}!"; } else if(fish == 9) { fishname = "{00FF00}х {FFFFFF}Вы поймали {88AA88}Нерку {FFFFFF}и продали на рынке за {88AA88}20 вирт{FFFFFF}!"; } else if(fish == 10) { fishname = "{00FF00}х {FFFFFF}Вы поймали {88AA88}Лосося {FFFFFF}и продали на рынке за {88AA88}25 вирт{FFFFFF}!"; } else { fishname = "{FF0000}x {FFFFFF}Рыба сорвалась и порвала леску!"; } format(string, sizeof(string), "%s", fishname); SendClientMessage(playerid,0xFFFFFFFF, string); if(fish == 1) { fishname = "1"; } else if(fish == 2) { fishname = "3"; } else if(fish == 3) { fishname = "5"; } else if(fish == 4) { fishname = "8"; } else if(fish == 5) { fishname = "10"; } else if(fish == 6) { fishname = "13"; } else if(fish == 7) { fishname = "15"; } else if(fish == 8) { fishname = "18"; } else if(fish == 9) { fishname = "20"; } else if(fish == 10) { fishname = "25"; } else { fishname = "{FF0000}х {FFFFFF}Рыба сорвалась!"; } format(string, sizeof(string), "~g~+%s$", fishname); GameTextForPlayer(playerid, string, 1200, 1); if(fish == 1) { GivePlayerMoney(playerid,1); } else if(fish == 2) { GivePlayerMoney(playerid,3); } else if(fish == 3) { GivePlayerMoney(playerid,5); } else if(fish == 4) { GivePlayerMoney(playerid,8); } else if(fish == 5) { GivePlayerMoney(playerid,10); } else if(fish == 6) { GivePlayerMoney(playerid,13); } else if(fish == 7) { GivePlayerMoney(playerid,15); } else if(fish == 8) { GivePlayerMoney(playerid,18); } else if(fish == 9) { GivePlayerMoney(playerid,20); } else if(fish == 10) { GivePlayerMoney(playerid,25); } else { FLine[playerid] = 0; } Fishing[playerid] = 0; TogglePlayerControllable(playerid, 1); ApplyAnimation(playerid, "CARRY", "crry_prtial", 2.0, 0, 0, 0, 0, 0); } } }
public AnimFixer(playerid) { if(VaildFishPlace(playerid)) { if(Fishing[playerid] == 1) { SetCameraBehindPlayer(playerid); ApplyAnimation(playerid,"SWORD","sword_block",50.0,0,1,0,1,1); } } } public LeavePosition(playerid) { if(!VaildFishPlace(playerid)) { if(Fishing[playerid] == 1) { Fishing[playerid] = 0; SetCameraBehindPlayer(playerid); ApplyAnimation(playerid, "CARRY", "crry_prtial", 2.0, 0, 0, 0, 0, 0); } } }
Скриншоты:
Спасибо за помощь моему другу Dron_Turbo! P.S:Надеюсь кому-то помог)
Сообщение отредактировал Ksardas - Понедельник, 22.05.2017, 21:16 |
|
|
|