Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ============================================================================
- **** ****** ****
- ***** ******* ******
- ** ** ** ** ** **
- ** ** ******* ***
- ** ** ****** ***
- ***** ** ** ***
- **** ** *******
- ** *****
- ============================================================================
- DaVe Property System include v1.0 | Vytvoril: DaVe 20.2.2015
- ============================================================================
- *Jak na to?
- 1) napiseme do vaseho modu upne nahoru #include <DPS>
- 2) musime priradit funkce do publicu nasledovne:
- public OnGameModeInit() { DPS_OnGameModeInit(); }
- public OnGameModeExit() { DPS_OnGameModeExit(); }
- public OnPlayerConnect(playerid) { DPS_OnPlayerConnect(playerid); }
- public OnPlayerPickUpPickup(playerid, pickupid) { DPS_OnPlayerPickUpPickup(playerid, pickupid); }
- public OnPlayerSelectedMenuRow(playerid, row) { DPS_OnPlayerSelectedMenuRow(playerid, row); }
- 3) vyuzijeme funkci(tuto funkci zadavame do public GameModeInit() ve vasem modu):
- AddProperty(nazev[],barvatextu,Float:x,Float:y,Float:z,cena,prumernyzisk,mapicon)
- nazev = Jmeno nemovitosti
- barvatextu = barva, kterou bude nemovitost popsana pomoci Create3DTextLabel
- Float:X, Float:Y, Float:Z = pozice pro pickup nemovitosti
- cena = Cena nemovitosti
- prumernyzisk = Prumerný výnos nemovitosti
- mapicon = ikona, kterou bude nemovitost označena na mapě
- 4) nadefinujte MAX_NEMOVITOSTI na počet vašich nemovitostí:
- #define MAX_NEMOVITOSTI [počet využitých nemovitostí bez těchto hranatých závorek]
- Příklad:
- #define MAX_NEMOVITOSTI 3
- ! Je velice důležité dodržet návod, v případě nedodržení váš mód může spamovat peníze a texty !
- 5) ostatní definice:
- pokud chcete nemovitosti ukládat do jiné složky, než má nastavený include,
- nadefinujte:
- SYSTEM_FOLDER "vase slozka s uvozovkama bez koncoveho lomitka"
- příklad:
- #define SYSTEM_FOLDER "Nemovitosti"
- nadefinujte si timer výnosů z nemovitostí pomocí definice:
- TIME_ZISK [sekundy bez zavorek, jedna sekunda = 1000, tudíž minuta = 60000]
- příklad:
- #define TIME_ZISK 60000 //tato definice vám bude dávat zisky po minutě
- ============================================================================
- */
- #include <a_samp>
- #define MAX_NEMOVITOSTI 20
- #define SYSTEM_FOLDER "Nemovitosti"
- #define TIME_ZISK 60000
- #define NEVLASTNICI "Nikdo"
- enum INFO
- {
- Float:X,
- Float:Y,
- Float:Z,
- Vlastnik[MAX_PLAYER_NAME],
- Cena,
- PrumernyZisk,
- ikona,
- Nazev[70]
- };
- new Nemovitost[MAX_NEMOVITOSTI][INFO],VytvorenoNemovitosti = 0, DPSI[100], File: DPSS;
- new Menu: NemovitostMenu, NaseMenu[MAX_PLAYERS];
- forward Zisky();
- stock DPS_OnGameModeInit()
- {
- NemovitostMenu = CreateMenu("Nemovitost",1, 50.0, 180.0, 400.0, 200.0);
- AddMenuItem(NemovitostMenu,0,"Koupit");
- AddMenuItem(NemovitostMenu,0,"Prodat");
- AddMenuItem(NemovitostMenu,0,"Vydelky");
- AddMenuItem(NemovitostMenu,0,"Nic");
- SetTimer("Zisky",TIME_ZISK,true);
- for(new DPS=0; DPS<MAX_NEMOVITOSTI; DPS++)
- {
- format(Nemovitost[DPS][Vlastnik],MAX_PLAYER_NAME,NEVLASTNICI);
- format(DPSI,50,"%s/N.%d",SYSTEM_FOLDER,DPS);
- if(fexist(DPSI))
- {
- DPSS = fopen(DPSI,io_read);
- {
- fread(DPSS,Nemovitost[DPS][Vlastnik]);
- }
- fclose(DPSS);
- }
- }
- }
- stock DPS_OnGameModeExit()
- {
- if(!fexist(SYSTEM_FOLDER))
- {
- SendClientMessageToAll(-1,"[ DaVe Property System include ]: Nemovitosti nemohly být uloženy, složka neexistuje!");
- printf("[ DaVe Property System include ]: Nemovitosti nemohly být uloženy, složka neexistuje!");
- }else{
- for(new DPS=0; DPS<MAX_NEMOVITOSTI; DPS++)
- {
- format(DPSI,50,"%s/N.%d",SYSTEM_FOLDER,DPS);
- DPSS = fopen(DPSI,io_write);
- {
- fwrite(DPSS,Nemovitost[DPS][Vlastnik]);
- }
- fclose(DPSS);
- }
- }
- }
- stock DPS_OnPlayerConnect(playerid)
- {
- for(new DPS=0; DPS<MAX_NEMOVITOSTI; DPS++)
- {
- #if defined Streamer_IncludeFileVersion
- CreateDynamicMapIcon(Nemovitost[DPS][X],Nemovitost[DPS][Y],Nemovitost[DPS][Z],Nemovitost[DPS][ikona],-1,-1,-1,-1,100);
- #else
- SetPlayerMapIcon(playerid,DPS,Nemovitost[DPS][X],Nemovitost[DPS][Y],Nemovitost[DPS][Z],Nemovitost[DPS][ikona],DPS,MAPICON_GLOBAL);
- #endif
- }
- }
- stock DPS_OnPlayerPickUpPickup(playerid, pickupid)
- {
- #pragma unused pickupid
- for(new DPS=0; DPS<MAX_NEMOVITOSTI; DPS++)
- {
- if(IsPlayerInRangeOfPoint(playerid,2,Nemovitost[DPS][X],Nemovitost[DPS][Y],Nemovitost[DPS][Z]))
- {
- ShowMenuForPlayer(NemovitostMenu,playerid);
- NaseMenu[playerid] = DPS;
- }
- }
- }
- stock DPS_OnPlayerSelectedMenuRow(playerid, row)
- {
- new Menu:zvoleno; zvoleno = GetPlayerMenu(playerid);
- if(zvoleno == NemovitostMenu)
- {
- switch(row)
- {
- case 0: {
- if(strcmp(Nemovitost[NaseMenu[playerid]][Vlastnik],NEVLASTNICI,false))
- {
- format(DPSI,100,"[ CHYBA ]: Tuto nemovitost vlastní hráč %s",Nemovitost[NaseMenu[playerid]][Vlastnik]);
- SendClientMessage(playerid,-1,DPSI);
- return 1;
- }
- if(GetPlayerMoney(playerid) < Nemovitost[NaseMenu[playerid]][Cena])
- {
- format(DPSI,100,"[ CHYBA ]: Nemáte dostatek peněz ( %d$ )",Nemovitost[NaseMenu[playerid]][Cena]);
- SendClientMessage(playerid,-1,DPSI);
- return 1;
- }
- GivePlayerMoney(playerid,-Nemovitost[NaseMenu[playerid]][Cena]);
- format(Nemovitost[NaseMenu[playerid]][Vlastnik],MAX_PLAYER_NAME,GetPlayerNick(playerid));
- format(DPSI,100,"Hráč %s koupil nemovitost %s",GetPlayerNick(playerid),Nemovitost[NaseMenu[playerid]][Nazev]);
- SendClientMessageToAll(-1,DPSI);
- }
- case 1: {
- if(strcmp(Nemovitost[NaseMenu[playerid]][Vlastnik],GetPlayerNick(playerid),false))
- {
- format(DPSI,100,"[ CHYBA ]: Tato nemovitost neni vase!");
- SendClientMessage(playerid,-1,DPSI);
- return 1;
- }
- GivePlayerMoney(playerid,Nemovitost[NaseMenu[playerid]][Cena]);
- format(Nemovitost[NaseMenu[playerid]][Vlastnik],MAX_PLAYER_NAME,NEVLASTNICI);
- format(DPSI,100,"Hráč %s prodal nemovitost %s",GetPlayerNick(playerid),Nemovitost[NaseMenu[playerid]][Nazev]);
- SendClientMessageToAll(-1,DPSI);
- }
- case 2: {
- format(DPSI,100,"Průměrný zisk této nemovitosti činí %d$",Nemovitost[NaseMenu[playerid]][PrumernyZisk]);
- SendClientMessage(playerid,-1,DPSI);
- }
- case 3: return 1;
- }
- }
- return 1;
- }
- stock AddProperty(nazev[],barvatextu,Float:x,Float:y,Float:z,cena,prumernyzisk,mapicon)
- {
- if(VytvorenoNemovitosti == MAX_NEMOVITOSTI)
- {
- printf("[ DaVe Property System ]: ERROR -> Překročený počet MAX_NEMOVITOSTI");
- }else{
- Nemovitost[VytvorenoNemovitosti][X] = x; Nemovitost[VytvorenoNemovitosti][Y] = y; Nemovitost[VytvorenoNemovitosti][Z] = z;
- Nemovitost[VytvorenoNemovitosti][Cena] = cena; Nemovitost[VytvorenoNemovitosti][PrumernyZisk] = prumernyzisk;
- Nemovitost[VytvorenoNemovitosti][ikona] = mapicon;
- format(Nemovitost[VytvorenoNemovitosti][Nazev],70,nazev);
- Create3DTextLabel(nazev,barvatextu,x,y,z,100,0);
- CreatePickup(1272,1,x,y,z);
- VytvorenoNemovitosti++;
- }
- }
- stock GetPlayerNick(playerid)
- {
- new j[MAX_PLAYER_NAME];
- if(IsPlayerConnected(playerid))
- {
- GetPlayerName(playerid,j,MAX_PLAYER_NAME);
- }
- return j;
- }
- public Zisky()
- {
- for(new DPS=0; DPS<MAX_NEMOVITOSTI; DPS++)
- {
- new castka; castka = Nemovitost[DPS][PrumernyZisk];
- switch(random(4))
- {
- case 0: castka-=1400;
- case 1: castka-=5250;
- case 2: castka+=6502;
- case 3: castka+=9600;
- }
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(!strcmp(Nemovitost[DPS][Vlastnik],GetPlayerNick(i),false))
- {
- format(DPSI,100,"[ VÝNOSY Z NEMOVITOSTÍ ] %s vám vynesl %d$",Nemovitost[DPS][Nazev],castka);
- SendClientMessage(i,-1,DPSI);
- GivePlayerMoney(i,castka);
- }
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement