Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-------------[PECANJE SISTEM]---------------//
- //---------------[BY GOPPERT]-----------------//
- //----------------[INCLUDES]------------------//
- #include <a_samp>
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 100
- #include <streamer>
- #include <sscanf2>
- #include <YSI\y_ini>
- #include <YSI\y_va>
- #include <YSI\y_timers>
- #include <PAWN.cmd>
- //----------------[DEFINICIJE]----------------//
- #define CIJENASTAPA 2000
- #define CIJENAMAMCA 150
- #define MAX_TRG 10
- enum
- {
- DIALOG_PECANJEOPREMA,
- DIALOG_KUPOVINAMAMCA,
- DIALOG_PANEL,
- DIALOG_PANEL2
- }
- //----------------[VARIJABLE]----------------//
- new Peca[MAX_PLAYERS],KreiraShop[MAX_PLAYERS] = -1;
- enum rInfo
- {
- Novac,
- StapPecanje,
- Mamac,
- Riba
- }
- new RibarInfo[MAX_PLAYERS][rInfo];
- new Text3D:TrgovinaLabel[MAX_TRG],TrgovinaPickup[MAX_TRG];
- new Float:PickupPos[MAX_TRG][3],Kreirana[MAX_TRG],Trgovinaarea[MAX_TRG],TrgMapIcon[MAX_TRG],interierarea;
- //----------------[PUBLICS]----------------//
- public OnGameModeInit()
- {
- DisableInteriorEnterExits();
- new komada = 0;
- for(new d; d < MAX_TRG; d++)
- {
- new TrgovinaFile[50],string[72];
- format(TrgovinaFile, sizeof(TrgovinaFile), "/Trgovine/%d.ini", d);
- if(fexist(TrgovinaFile))
- {
- INI_ParseFile(TrgovinaFile, "UcitajTrgovinu", .bExtra = true, .extra = d);
- if(Kreirana[d] == 1)
- {
- format(string,sizeof(string),"Trgovina Ribarske Opreme\nPritisnite 'F' za ulazak\nID: %d",d);
- TrgovinaLabel[d] = Create3DTextLabel(string,-1,PickupPos[d][0],PickupPos[d][1],PickupPos[d][2], 15.0,0,0);
- TrgovinaPickup[d] = CreatePickup(1239, 1, PickupPos[d][0],PickupPos[d][1],PickupPos[d][2]);
- Trgovinaarea[d] = CreateDynamicSphere(PickupPos[d][0], PickupPos[d][1], PickupPos[d][2], 1.3, -1, -1, -1);
- TrgMapIcon[d] = CreateDynamicMapIcon(PickupPos[d][0],PickupPos[d][1],PickupPos[d][2], 56, -1, 0, 0, -1, 3000.0);
- komada ++;
- }
- }
- }
- printf("- Trgovine ribolovske opreme uspjesno ucitane. %d trgovina",komada);
- interierarea = CreateDynamicSphere(255.2819,-41.5168,1002.0234, 1.2, -1, 14, -1);
- //----------------[INT TRGOVINE]----------------//
- CreateDynamicObject(2626, 256.050415, -40.543006, 1001.543945, 0.000000, 0.000000, 0.000000);
- CreateDynamicObject(1567, 257.387603, -39.120681, 1000.883300, 0.000000, 0.000000, 0.000000);
- CreateDynamicObject(1806, 255.970336, -39.536037, 1001.023437, 0.000000, 0.000000, 180.000000);
- CreateDynamicObject(18632, 259.436248, -39.419803, 1001.135437, 0.000000, 195.000000, 0.000000);
- CreateDynamicObject(18632, 259.436248, -39.529796, 1001.135437, 0.000000, 195.000000, 0.000000);
- CreateDynamicObject(18632, 259.436248, -39.619781, 1001.135437, 0.000000, 195.000000, 0.000000);
- CreateDynamicObject(18632, 259.436248, -39.699768, 1001.135437, 0.000000, 195.000000, 0.000000);
- CreateDynamicObject(18632, 259.436248, -39.789756, 1001.135437, 0.000000, 195.000000, 0.000000);
- CreateDynamicObject(18632, 259.436248, -39.879753, 1001.135437, 0.000000, 195.000000, 0.000000);
- CreateDynamicObject(19565, 257.547973, -43.774082, 1002.704101, 0.000000, 0.000000, 46.799987);
- CreateDynamicObject(19566, 257.306762, -43.753383, 1002.704101, 0.000000, 0.000000, 46.799987);
- CreateDynamicObject(19566, 257.030059, -43.726737, 1002.704101, 0.000000, 0.000000, 46.799987);
- CreateDynamicObject(19566, 256.725372, -43.715095, 1002.704101, 0.000000, 0.000000, 46.799987);
- CreateDynamicObject(19566, 256.428497, -43.724460, 1002.704101, 0.000000, 0.000000, 46.799987);
- CreateDynamicObject(19566, 256.137939, -43.712394, 1002.704101, 0.000000, 0.000000, 46.799987);
- CreateDynamicObject(19573, 257.950012, -43.969707, 1001.033447, 0.000000, 0.000000, 0.000000);
- CreateDynamicObject(19573, 257.559844, -43.969707, 1001.033447, 0.000000, 0.000000, 0.000000);
- CreateDynamicObject(19573, 257.169769, -43.969707, 1001.033447, 0.000000, 0.000000, 0.000000);
- CreateDynamicObject(19565, 258.645446, -43.803211, 1002.704101, 0.000000, 0.000000, 46.799987);
- CreateDynamicObject(19565, 258.390167, -43.782978, 1002.704101, 0.000000, 0.000000, 46.799987);
- CreateDynamicObject(19565, 258.078277, -43.764522, 1002.704101, 0.000000, 0.000000, 46.799987);
- CreateDynamicObject(19565, 257.822845, -43.744270, 1002.704101, 0.000000, 0.000000, 46.799987);
- CreateDynamicObject(19831, 259.383544, -43.382118, 1000.993408, 0.000000, 0.000000, -90.000000);
- CreateDynamicObject(1775, 254.159408, -43.122272, 1002.104187, 0.000000, 0.000000, 90.000000);
- CreateDynamicObject(1776, 255.199096, -44.032176, 1002.024108, 0.000000, 0.000000, 180.000000);
- return 1;
- }
- public OnGameModeExit()
- {
- for(new d; d < MAX_TRG; d++) { SacuvajTrgovinu(d); }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- defer spawnuj(playerid);
- INI_ParseFile(RibarPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- if(!fexist(RibarPath(playerid)))
- {
- RibarInfo[playerid][Novac] = 10000;
- SacuvajRibara(playerid);
- }
- RemoveBuildingForPlayer(playerid, 2087, 257.8047, -43.8438, 1001.0313, 0.25);
- RemoveBuildingForPlayer(playerid, 2103, 258.1953, -43.7422, 1002.6953, 0.25);
- RemoveBuildingForPlayer(playerid, 2406, 259.5781, -43.2656, 1002.2266, 0.25);
- RemoveBuildingForPlayer(playerid, 2295, 258.6563, -42.7578, 1001.0234, 0.25);
- RemoveBuildingForPlayer(playerid, 2295, 259.2344, -39.7422, 1001.0234, 0.25);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- KreiraShop[playerid] = -1; Peca[playerid] = -1; SacuvajRibara(playerid);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if(IsPlayerNPC(playerid)) return 1;
- SetPlayerInterior(playerid,0);
- TogglePlayerClock(playerid,0);
- ResetPlayerMoney(playerid);
- GivePlayerMoney(playerid,RibarInfo[playerid][Novac]);
- SetPlayerPos(playerid, 379.530, -2020.623, 7.83);
- GivePlayerWeapon(playerid,24,100);
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case DIALOG_PECANJEOPREMA:
- {
- if(response)
- {
- if(listitem == 0)
- {
- if(RibarInfo[playerid][StapPecanje] != 0) return SendClientMessage(playerid,-1,"Vec posjedujes stap za pecanje");
- if(RibarInfo[playerid][Novac] < CIJENASTAPA) return va_SendClientMessage(playerid,-1,"Nemas dovoljno novca (%d$)",CIJENASTAPA);
- RibarInfo[playerid][StapPecanje] = 5+random(15);
- RibarInfo[playerid][Novac] -= CIJENASTAPA;
- GivePlayerMoney(playerid, -CIJENASTAPA);
- }
- if(listitem == 1)
- {
- if(RibarInfo[playerid][Mamac] >= 20) return SendClientMessage(playerid,-1,"Vec imas maksimalnu kolicinu mamca (20)");
- va_ShowPlayerDialog(playerid, DIALOG_KUPOVINAMAMCA,DIALOG_STYLE_INPUT, "Ribarska Oprema","Unesite kolicinu mamca koju zelite kupiti\nKolicina koju posjedujete %d/20\n{FF0000}Cijena mamca\t{33AA33}%d$/komadu",RibarInfo[playerid][Mamac],CIJENAMAMCA);
- }
- }
- }
- case DIALOG_KUPOVINAMAMCA:
- {
- if(response)
- {
- new kolicina;
- if(sscanf(inputtext, "d", kolicina)) return va_ShowPlayerDialog(playerid, DIALOG_KUPOVINAMAMCA,DIALOG_STYLE_INPUT, "Ribarska Oprema","Unesite kolicinu mamca koju zelite kupiti\nKolicina koju posjedujete %d/20\n{FF0000}Cijena mamca\t{33AA33}%d$/komadu",RibarInfo[playerid][Mamac],CIJENAMAMCA);
- if(kolicina < 1 || kolicina > 20 || kolicina+RibarInfo[playerid][Mamac] > 20) return SendClientMessage(playerid, -1, "Ne mozes kupiti manje od 1 i vise od 20 komada mamca");
- if(kolicina*CIJENAMAMCA >= RibarInfo[playerid][Novac]) return va_SendClientMessage(playerid, -1, "Nemas dovoljno novca. Fali %d$",RibarInfo[playerid][Novac]-(kolicina*CIJENAMAMCA));
- RibarInfo[playerid][Mamac] += kolicina;
- RibarInfo[playerid][Novac] -= kolicina*CIJENAMAMCA;
- GivePlayerMoney(playerid, -kolicina*CIJENAMAMCA);
- va_SendClientMessage(playerid,-1,"Kupio si %d komada mamca i platio %d$",kolicina,kolicina*CIJENAMAMCA);
- }
- }
- case DIALOG_PANEL:
- {
- if(!response) return 1;
- if(response)
- {
- switch(listitem)
- {
- case 0:
- {
- if(KreiraShop[playerid] != -1) return va_SendClientMessage(playerid,-1,"Vec kreiras trgovinu id %d",KreiraShop[playerid]);
- for(new d = 0; d < MAX_TRG; d++)
- {
- new TrgovinaFile[50];
- format(TrgovinaFile, sizeof(TrgovinaFile), "Trgovine/%d.ini", d);
- if(!fexist(TrgovinaFile))
- {
- KreiraShop[playerid] = d;
- SendClientMessage(playerid,-1,"Pritisnite 'Y' kad budete na lokaciji kreiranja trgovine ribarske opreme");
- return 1;
- }
- }
- return SendClientMessage(playerid,-1,"Kreiran je maksimalan broj trgovina ribarske opreme");
- }
- case 1:
- {
- ShowPlayerDialog(playerid, DIALOG_PANEL2, DIALOG_STYLE_INPUT, "Panel", "Unesite ID trgovine koji zelite obrisati", "Unesi", "Zatvori");
- }
- }
- }
- }
- case DIALOG_PANEL2:
- {
- if(!response) return 1;
- if(response)
- {
- new TrgovinaFile[60],id;
- if(sscanf(inputtext, "i", id)) return ShowPlayerDialog(playerid, DIALOG_PANEL2, DIALOG_STYLE_INPUT, "Panel", "Unesite ID trgovine koji zelite obrisati", "Unesi", "Zatvori");
- if(id == -1 || id > MAX_TRG || Kreirana[id] == 0) return SendClientMessage(playerid,-1,"Pogresan ID ili trgovina nije kreirana");
- DestroyPickup(TrgovinaPickup[id]); Delete3DTextLabel(TrgovinaLabel[id]); DestroyDynamicMapIcon(TrgMapIcon[id]); DestroyDynamicArea(Trgovinaarea[id]);
- Kreirana[id] = 0; va_SendClientMessage(playerid,-1,"Uspjesno ste obrisali trgovinu ribarske opreme ID %d!",id);
- format(TrgovinaFile, sizeof(TrgovinaFile), "Trgovine/%d.ini", id);
- if(fexist(TrgovinaFile))
- {
- fremove(TrgovinaFile);
- }
- }
- }
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(newkeys == KEY_YES)
- {
- if(KreiraShop[playerid] != -1)
- {
- new d = KreiraShop[playerid],Float:Pos[3],string[72];
- format(string,sizeof(string),"Trgovina Ribarske Opreme\nPritisnite 'F' za ulazak\nID: %d",d);
- GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]); PickupPos[d][0] = Pos[0]; PickupPos[d][1] = Pos[1]; PickupPos[d][2] = Pos[2]; Kreirana[d] = 1;
- TrgovinaLabel[d] = Create3DTextLabel(string,-1,PickupPos[d][0],PickupPos[d][1],PickupPos[d][2], 15.0,0,0);
- TrgovinaPickup[d] = CreatePickup(1239, 1, PickupPos[d][0],PickupPos[d][1],PickupPos[d][2]);
- Trgovinaarea[d] = CreateDynamicSphere(PickupPos[d][0], PickupPos[d][1], PickupPos[d][2], 1.5, -1, -1, -1);
- TrgMapIcon[d] = CreateDynamicMapIcon(PickupPos[d][0],PickupPos[d][1],PickupPos[d][2], 56, -1, 0, 0, -1, 3000.0);
- SacuvajTrgovinu(d); KreiraShop[playerid] = -1;
- return 1;
- }
- }
- if(newkeys == KEY_SECONDARY_ATTACK)
- {
- if(IsPlayerInAnyDynamicArea(playerid, 0))
- {
- for(new d = 0; d < MAX_TRG; d++)
- {
- if(IsPlayerInDynamicArea(playerid,Trgovinaarea[d], 0))
- {
- SetPlayerVirtualWorld(playerid, d); SetPlayerInterior(playerid, 14);
- SetPlayerPos(playerid, 255.2819,-41.5168,1002.0234);
- GameTextForPlayer(playerid, "~b~/kupi~n~ ~w~da kupite ribarsku opremu", 2000, 5);
- return 1;
- }
- }
- }
- if(IsPlayerInDynamicArea(playerid,interierarea, 0))
- {
- new d = GetPlayerVirtualWorld(playerid);
- SetPlayerVirtualWorld(playerid, 0); SetPlayerInterior(playerid, 0);
- SetPlayerPos(playerid, PickupPos[d][0],PickupPos[d][1],PickupPos[d][2]);
- return 1;
- }
- }
- return 1;
- }
- //----------------[KOMANDE]----------------//
- CMD:kupi(playerid, params[])
- {
- if(!IsPlayerInDynamicArea(playerid,interierarea, 0)) return SendClientMessage(playerid,-1,"Niste na mjestu kupovine ribarske opreme");
- va_ShowPlayerDialog(playerid, DIALOG_PECANJEOPREMA,DIALOG_STYLE_TABLIST_HEADERS, "Ribarska Oprema" , "Oprema\tCijena Opreme:\n{FF0000}Stap za pecanje\t{33AA33}%d$\n{FF0000}Mamac\t{33AA33}%d$",CIJENASTAPA,CIJENAMAMCA);
- return 1;
- }
- CMD:pecaj(playerid, params[])
- {
- if(Peca[playerid] != 0) return SendClientMessage(playerid,-1,"Vec pecate");
- if(RibarInfo[playerid][StapPecanje] == 0) return SendClientMessage(playerid,-1,"Ne posjedujes stap za pecanje");
- if(RibarInfo[playerid][Mamac] < 1) return SendClientMessage(playerid,-1,"Nemas mamac za pecanje kupi ga u trgovini ribarske opreme");
- defer PecaRibu(playerid);
- SetPlayerAttachedObject(playerid, 3,18632,6,0.079376,0.037070,0.007706,181.482910,0.000000,0.000000,1.000000,1.000000,1.000000);
- TogglePlayerControllable(playerid,false);
- SetPlayerFacingAngle(playerid,179.688461);
- ApplyAnimation(playerid,"SWORD","sword_block",50.0,0,1,0,1,1);
- RibarInfo[playerid][Mamac] --;
- Peca[playerid] = 1;
- return 1;
- }
- CMD:stats(playerid, params[])
- {
- va_SendClientMessage(playerid,-1,"Novac: %d$ | Riba: %d kg| Mamac %d/20 komada",RibarInfo[playerid][Novac],RibarInfo[playerid][Riba],RibarInfo[playerid][Mamac]);
- return 1;
- }
- CMD:panel(playerid, params[])
- {
- ShowPlayerDialog(playerid,DIALOG_PANEL,DIALOG_STYLE_LIST,"Panel","Kreiraj trgovinu ribarske opreme\nObrisi trgovinu ribarske opreme","Odaberi","Odustani");
- return 1;
- }
- //----------------[TIMERI]----------------//
- timer PecaRibu[20000](playerid)
- {
- if(Peca[playerid] != 0)
- {
- switch(random(6))
- {
- case 0:
- {
- va_SendClientMessage(playerid,-1,"Nisi upecao nista");
- RemovePlayerAttachedObject(playerid,3);
- TogglePlayerControllable(playerid,true); Peca[playerid] = 0; ClearAnimations(playerid);
- RibarInfo[playerid][StapPecanje] -= 1;
- if(RibarInfo[playerid][StapPecanje] == 0) return SendClientMessage(playerid,-1,"Vas stap za pecanje se potrgao, morate kupiti novi");
- }
- case 1:
- {
- va_SendClientMessage(playerid,-1,"Upecao si sardinu");
- RemovePlayerAttachedObject(playerid,3);
- TogglePlayerControllable(playerid,true); Peca[playerid] = 0; ClearAnimations(playerid);
- RibarInfo[playerid][StapPecanje] -= 1; RibarInfo[playerid][Riba] += 1;
- if(RibarInfo[playerid][StapPecanje] == 0) return SendClientMessage(playerid,-1,"Vas stap za pecanje se potrgao, morate kupiti novi");
- }
- case 2:
- {
- va_SendClientMessage(playerid,-1,"Nisi upecao nista");
- RemovePlayerAttachedObject(playerid,3);
- TogglePlayerControllable(playerid,true); Peca[playerid] = 0; ClearAnimations(playerid);
- RibarInfo[playerid][StapPecanje] -= 1;
- if(RibarInfo[playerid][StapPecanje] == 0) return SendClientMessage(playerid,-1,"Vas stap za pecanje se potrgao, morate kupiti novi");
- }
- case 3:
- {
- va_SendClientMessage(playerid,-1,"Upecao si oradu");
- RemovePlayerAttachedObject(playerid,3);
- TogglePlayerControllable(playerid,true); Peca[playerid] = 0; ClearAnimations(playerid);
- RibarInfo[playerid][StapPecanje] -= 1; RibarInfo[playerid][Riba] += 1;
- if(RibarInfo[playerid][StapPecanje] == 0) return SendClientMessage(playerid,-1,"Vas stap za pecanje se potrgao, morate kupiti novi");
- }
- case 4:
- {
- va_SendClientMessage(playerid,-1,"Upecao si sardinu");
- RemovePlayerAttachedObject(playerid,3);
- TogglePlayerControllable(playerid,true); Peca[playerid] = 0; ClearAnimations(playerid);
- RibarInfo[playerid][StapPecanje] -= 1; RibarInfo[playerid][Riba] += 1;
- if(RibarInfo[playerid][StapPecanje] == 0) return SendClientMessage(playerid,-1,"Vas stap za pecanje se potrgao, morate kupiti novi");
- }
- case 5:
- {
- va_SendClientMessage(playerid,-1,"Nisi upecao nista");
- RemovePlayerAttachedObject(playerid,3);
- TogglePlayerControllable(playerid,true); Peca[playerid] = 0; ClearAnimations(playerid);
- RibarInfo[playerid][StapPecanje] -= 1;
- if(RibarInfo[playerid][StapPecanje] == 0) return SendClientMessage(playerid,-1,"Vas stap za pecanje se potrgao, morate kupiti novi");
- }
- }
- SacuvajRibara(playerid);
- }
- return 1;
- }
- timer spawnuj[3000](playerid)
- {
- TogglePlayerSpectating(playerid,false);
- SpawnPlayer(playerid);
- return 1;
- }
- //----------------[CUVANJA I CITANJA]----------------//
- forward LoadUser_data(id, name[], value[]);
- public LoadUser_data(id, name[], value[])
- {
- INI_Int("Novac", RibarInfo[id][Novac]);
- INI_Int("StapPecanje", RibarInfo[id][StapPecanje]);
- INI_Int("Mamac", RibarInfo[id][Mamac]);
- INI_Int("Riba", RibarInfo[id][Riba]);
- return 1;
- }
- SacuvajRibara(id)
- {
- new INI:File = INI_Open(RibarPath(id));
- INI_SetTag(File,"data");
- INI_WriteInt(File, "Novac", RibarInfo[id][Novac]);
- INI_WriteInt(File, "StapPecanje", RibarInfo[id][StapPecanje]);
- INI_WriteInt(File, "Mamac", RibarInfo[id][Mamac]);
- INI_WriteInt(File, "Riba", RibarInfo[id][Riba]);
- INI_Close(File);
- return 1;
- }
- forward UcitajTrgovinu(d, name[], value[]);
- public UcitajTrgovinu(d, name[], value[])
- {
- INI_Int("Kreirana",Kreirana[d]);
- if(Kreirana[d] == 1)
- {
- INI_Float("PickupX",PickupPos[d][0]);
- INI_Float("PickupY",PickupPos[d][1]);
- INI_Float("PickupZ",PickupPos[d][2]);
- }
- return 1;
- }
- SacuvajTrgovinu(d)
- {
- new dFile[128];
- format(dFile, sizeof(dFile), "Trgovine/%d.ini", d);
- new INI:File = INI_Open(dFile);
- INI_WriteInt(File,"Kreirana",Kreirana[d]);
- if(Kreirana[d] == 1)
- {
- INI_WriteFloat(File,"PickupX",PickupPos[d][0]);
- INI_WriteFloat(File,"PickupY",PickupPos[d][1]);
- INI_WriteFloat(File,"PickupZ",PickupPos[d][2]);
- }
- INI_Close(File);
- }
- //----------------[OSTALO]----------------//
- RibarPath(playerid)
- {
- new string[128];
- format(string,sizeof(string), "Ribari/%s.ini", GetName(playerid));
- return string;
- }
- GetName(id)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(id, name, sizeof(name));
- return name;
- }
- stock va_ShowPlayerDialog(playerid,dialogid,type,name[],const fmat[], va_args<>)
- {
- return ShowPlayerDialog(playerid,dialogid,type,name,va_return(fmat, va_start<5>),"Odaberi","Odustani");
- }
- //----------------[END OF THE LINE]----------------//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement