Advertisement
Maki187

Untitled

Mar 31st, 2012
1,147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 27.32 KB | None | 0 0
  1. /* Dynamic Apartment System
  2. Credits:
  3. *Maki187 - Maki this filterscipt
  4. **Gagi_Corleone(Mr.Gagi) - switch on y_ini and translate thread on forum
  5. ***CuervO_NegrO - His command has help me for command for create apartment
  6.  
  7. PLEASE DON'T REMOVE CREDITS!!
  8. |=============[v0.1 - 3.3.2012]============|
  9. -Making the whole FS (with breaks)
  10. Commands: /setapartment(rcon) | /aptel (rcon) | /apedit price/level/int| /buyapartment | /sellapartment |/apartment lock [any number] |info [any number] |takemoney [value] |putmoney [value]| /aphelp | /changespawn | /reapartment
  11. |=============[v0.1 R1]============|
  12. -Fixed bug with /setapartment and problem with interior
  13. |=============[v0.2 - 07.3.2012]============|
  14. -fixed bug with deposit/withdraw money in apartment with same interior | fixed bug with money in apartment (with minus)
  15. -Added level on buying apartment
  16. -From now you'll spawn in apartment, you can change it with /changespawn
  17. -Now when you'r setting apartment it'll set random interior
  18. -Now you can in game edit price,level, furniture(int)....
  19. -Saving system switched from dini to y_ini (credits to gagi) and now all commands is like one (example: in the past it was be /lock or /sinfo, now it is all in one, like /apartment [some_part] [ ] [ ])
  20. Translating this to english, sorry if there are mistakes, my english is bad...
  21. */
  22. #define FILTERSCRIPT
  23.  
  24. #include <a_samp>
  25. #include <float>
  26. #include <zcmd>
  27. #include <foreach>
  28. #include <YSI/y_ini>
  29. #include <Streamer>
  30. #include <sscanf2>
  31.  
  32.  
  33. #define YELLOW 0xDABB3EAA
  34. #define WHITE 0xFFFFFFAA
  35. #define RED 0xFF0000FF
  36. #define GREY 0xBFC0C2FF
  37. #define PRESSED(%0) \
  38.     (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  39. #define randomEx(%0,%1)             (random((%1) - (%0)) + (%0)) // i saw this from my friend Gagi_Corleone(Mr.Gagi)
  40. #define MaxApartments 500
  41. enum Apartments
  42. {
  43.     Float:sEnterx,
  44.     Float:sEntery,
  45.     Float:sEnterz,
  46.     Float:sExitx,
  47.     Float:sExity,
  48.     Float:sExitz,
  49.     sOwner[MAX_PLAYER_NAME],
  50.     sDescription[MAX_PLAYER_NAME],
  51.     sOwned,
  52.     sCreated,
  53.     sLocked,
  54.     sMoney,
  55.     sPrice,
  56.     sWorld,
  57.     sMessage[32],
  58.     sInt,
  59.     sLevel,
  60.     sSpawn
  61. };
  62.  
  63. new ApartmentInfo[MaxApartments][Apartments];
  64. new InApartment[MAX_PLAYERS]; // checking is player in apartment
  65. new ApartmentPickup[sizeof(ApartmentInfo)]; // apartment pickup
  66. new Text3D:ApartmentLabel[sizeof(ApartmentInfo)]; // 3d text in front of door
  67. new plname[MAX_PLAYER_NAME]; // checking player name
  68. new randomINT;
  69.  
  70. public OnFilterScriptInit()
  71. {
  72.     print("\n--------------------------------------");
  73.     print(" Dynamic Apartment System by: Maki187 (Marko_Dimitrijevic)");
  74.     print(" Dynamic Apartment System v0.2");
  75.     print(" Balkan Rising - www.balkan-rising.info");
  76.     print(" Alfa Games - www.alfa-gaming.info");
  77.     print(" -------------[FRIENDS]------------");
  78.     print(" Bestbalkandj.com - www.bestbalkandj.com");
  79.     print(" Serbian Warez - www.serbian-warez.in.rs");
  80.     print("--------------------------------------\n");
  81.     new string[828];
  82.     for(new s = 0; s < sizeof(ApartmentInfo); s++)
  83.     {
  84.         new gFile[35];
  85.         format(gFile, 35, "Apartments/%d.ini" ,s);
  86.         INI_ParseFile(gFile, "LoadApartments", .bExtra = true, .extra = s);
  87.         if(ApartmentInfo[s][sCreated] == 1)
  88.         {
  89.             if(ApartmentInfo[s][sOwned] == 0)
  90.             {
  91.                 format(string,sizeof(string),"{458B00}For Sale! \n {458B00}Adress: {FFFFFF}%d \n {458B00}Price: {FFFFFF}$%d\n {458B00}Level: {FFFFFF}%d \n {458B00}Description: {FFFFFF}%s",ApartmentInfo[s][sWorld], ApartmentInfo[s][sPrice],ApartmentInfo[s][sLevel], ApartmentInfo[s][sDescription]);
  92.                 ApartmentLabel[s] = Create3DTextLabel(string ,0x00FF00AA,ApartmentInfo[s][sEnterx], ApartmentInfo[s][sEntery], ApartmentInfo[s][sEnterz],25, 0, 1);
  93.                 ApartmentPickup[s] = CreateDynamicPickup(1273, 1, ApartmentInfo[s][sEnterx], ApartmentInfo[s][sEntery], ApartmentInfo[s][sEnterz]);
  94.             }
  95.             if(ApartmentInfo[s][sOwned] == 1)
  96.             {
  97.                 format(string,sizeof(string)," {458B00}Owner: {FFFFFF}%s \n {458B00}Adress: {FFFFFF}%d \n {458B00}Description: {FFFFFF}%s",ApartmentInfo[s][sOwner],ApartmentInfo[s][sWorld], ApartmentInfo[s][sDescription]);
  98.                 ApartmentLabel[s] = Create3DTextLabel(string ,0x00FFFFAA,ApartmentInfo[s][sEnterx], ApartmentInfo[s][sEntery], ApartmentInfo[s][sEnterz],25, 0, 1);
  99.                 ApartmentPickup[s] = CreateDynamicPickup(1273, 1, ApartmentInfo[s][sEnterx], ApartmentInfo[s][sEntery], ApartmentInfo[s][sEnterz]);
  100.             }
  101.         }
  102.     }
  103.     return 1;
  104. }
  105. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  106. {
  107.     if(PRESSED(KEY_SECONDARY_ATTACK))
  108.     {
  109.         for(new i = 0; i < sizeof(ApartmentInfo); i++)
  110.         {
  111.             if (IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]))
  112.             {
  113.                 GetPlayerName(playerid, plname, sizeof(plname));
  114.                 if(ApartmentInfo[i][sLocked] == 0|| strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
  115.                 {
  116.                     SetPlayerInterior(playerid,ApartmentInfo[i][sInt]); SetPlayerVirtualWorld(playerid,ApartmentInfo[i][sWorld]);
  117.                     SetPlayerPos(playerid,ApartmentInfo[i][sExitx],ApartmentInfo[i][sExity],ApartmentInfo[i][sExitz]);
  118.                     InApartment[playerid] = i;
  119.                 }
  120.                 else
  121.                 {
  122.                     GameTextForPlayer(playerid, "~r~Locked", 5000, 1);
  123.                     return 1;
  124.                 }
  125.             }
  126.         }
  127.         if(InApartment[playerid] != MaxApartments+1)
  128.         {
  129.             new i = InApartment[playerid];
  130.             if(IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]))
  131.             {
  132.                 SetPlayerInterior(playerid,0); SetPlayerVirtualWorld(playerid,0);
  133.                 SetPlayerPos(playerid,ApartmentInfo[i][sEnterx],ApartmentInfo[i][sEntery],ApartmentInfo[i][sEnterz]);
  134.                 InApartment[playerid] = MaxApartments+1;
  135.                 return 1;
  136.             }
  137.         }
  138.     }
  139.     return 1;
  140. }
  141. public OnPlayerSpawn(playerid)
  142. {
  143.     for(new i = 0; i < sizeof(ApartmentInfo); i++)
  144.     {
  145.         GetPlayerName(playerid, plname, sizeof(plname));
  146.         if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0 && ApartmentInfo[i][sSpawn] == 1)
  147.         {
  148.             SetPlayerPos(playerid, ApartmentInfo[i][sEnterx],ApartmentInfo[i][sEntery],ApartmentInfo[i][sEnterz]);
  149.         }
  150.     }
  151.     return 1;
  152. }
  153. public OnPlayerConnect(playerid)
  154. {
  155.     SendClientMessage(playerid, WHITE, "This server use Dynamic Apartment System by: Maki187 (Marko_Dimitrijevic)");
  156.     return 1;
  157. }
  158. stock SaveApartment(idstana)
  159. {
  160.     new dFile[128];
  161.     format(dFile, sizeof(dFile),"Apartments/%d.ini",idstana);
  162.     new
  163.     INI:File = INI_Open(dFile);
  164.    
  165.     INI_WriteFloat(File, "Enter_X",ApartmentInfo[idstana][sEnterx]);
  166.     INI_WriteFloat(File, "Enter_Y", ApartmentInfo[idstana][sEntery]);
  167.     INI_WriteFloat(File, "Enter_Z",ApartmentInfo[idstana][sEnterz]);
  168.     INI_WriteFloat(File, "Exit_X", ApartmentInfo[idstana][sExitx]);
  169.     INI_WriteFloat(File, "Exit_Y", ApartmentInfo[idstana][sExity]);
  170.     INI_WriteFloat(File, "Exit_Z", ApartmentInfo[idstana][sExitz]);
  171.     INI_WriteString(File, "Owner", ApartmentInfo[idstana][sOwner]);
  172.     INI_WriteString(File, "Description", ApartmentInfo[idstana][sDescription]);
  173.     INI_WriteInt(File, "Owned", ApartmentInfo[idstana][sOwned]);
  174.     INI_WriteInt(File, "Created", ApartmentInfo[idstana][sCreated]);
  175.     INI_WriteInt(File, "Locked", ApartmentInfo[idstana][sLocked]);
  176.     INI_WriteInt(File, "Money", ApartmentInfo[idstana][sMoney]);
  177.     INI_WriteInt(File, "Price", ApartmentInfo[idstana][sPrice]);
  178.     INI_WriteInt(File, "World", ApartmentInfo[idstana][sWorld]);
  179.     INI_WriteString(File, "Message", ApartmentInfo[idstana][sMessage]);
  180.     INI_WriteInt(File, "Int", ApartmentInfo[idstana][sInt]);
  181.     INI_WriteInt(File, "Level", ApartmentInfo[idstana][sLevel]);
  182.     INI_WriteInt(File, "Spawn", ApartmentInfo[idstana][sSpawn]);
  183.  
  184.     INI_Close(File);
  185. }
  186. forward LoadApartments(idstana, name[], value[]);
  187. public LoadApartments(idstana, name[], value[])
  188. {
  189.         INI_Float("Enter_X",ApartmentInfo[idstana][sEnterx]);
  190.         INI_Float("Enter_Y",ApartmentInfo[idstana][sEntery]);
  191.         INI_Float("Enter_Z",ApartmentInfo[idstana][sEnterz]);
  192.         INI_Float("Exit_X",ApartmentInfo[idstana][sExitx]);
  193.         INI_Float("Exit_Y",ApartmentInfo[idstana][sExity]);
  194.         INI_Float("Exit_Z",ApartmentInfo[idstana][sExitz]);
  195.         INI_String("Owner",ApartmentInfo[idstana][sOwner],32);
  196.         INI_String("Description",ApartmentInfo[idstana][sDescription],32);
  197.         INI_Int("Owned",ApartmentInfo[idstana][sOwned]);
  198.         INI_Int("Created",ApartmentInfo[idstana][sCreated]);
  199.         INI_Int("Locked",ApartmentInfo[idstana][sLocked]);
  200.         INI_Int("Money",ApartmentInfo[idstana][sMoney]);
  201.         INI_Int("Price",ApartmentInfo[idstana][sPrice]);
  202.         INI_Int("World",ApartmentInfo[idstana][sWorld]);
  203.         INI_String("Message",ApartmentInfo[idstana][sMessage],32);
  204.         INI_Int("Int",ApartmentInfo[idstana][sInt]);
  205.         INI_Int("Level",ApartmentInfo[idstana][sLevel]);
  206.         INI_Int("Spawn",ApartmentInfo[idstana][sSpawn]);
  207.         return 1;
  208. }
  209. stock LabelIPickup(idstana)
  210. {
  211.     new string[828];
  212.     if(ApartmentInfo[idstana][sOwned] == 0)
  213.     {
  214.         Delete3DTextLabel(ApartmentLabel[idstana]);
  215.         format(string,sizeof(string),"{458B00}For Sale! \n {458B00}Adress: {FFFFFF}%d \n {458B00}Price: {FFFFFF}$%d\n {458B00}Level: {FFFFFF}%d \n {458B00}Description: {FFFFFF}%s",ApartmentInfo[idstana][sWorld], ApartmentInfo[idstana][sPrice],ApartmentInfo[idstana][sLevel], ApartmentInfo[idstana][sDescription]);
  216.         ApartmentLabel[idstana] = Create3DTextLabel(string ,0x00FF00AA,ApartmentInfo[idstana][sEnterx], ApartmentInfo[idstana][sEntery], ApartmentInfo[idstana][sEnterz],25, 0, 1);
  217.     }
  218.     if(ApartmentInfo[idstana][sOwned] == 1)
  219.     {
  220.         Delete3DTextLabel(ApartmentLabel[idstana]);
  221.         format(string,sizeof(string),"{458B00}Owner: {FFFFFF}%s \n {458B00}Adress: {FFFFFF}%d \n {458B00}Description: {FFFFFF}%s",ApartmentInfo[idstana][sOwner],ApartmentInfo[idstana][sWorld], ApartmentInfo[idstana][sDescription]);
  222.         ApartmentLabel[idstana] = Create3DTextLabel(string ,0x00FFFFAA,ApartmentInfo[idstana][sEnterx], ApartmentInfo[idstana][sEntery], ApartmentInfo[idstana][sEnterz],25, 0, 1);
  223.     }
  224.     DestroyDynamicPickup(ApartmentPickup[idstana]);
  225.     ApartmentPickup[idstana] = CreateDynamicPickup(1273, 1, ApartmentInfo[idstana][sEnterx], ApartmentInfo[idstana][sEntery], ApartmentInfo[idstana][sEnterz]);
  226. }
  227. //======================[CMD]==============================
  228. CMD:apartment(playerid, params[]) // main commands
  229. {
  230.     new text[48]; new novac;// novac = money
  231.     if(sscanf(params, "s[48]i",text , novac))
  232.     {
  233.         SendClientMessage(playerid, WHITE, "HELP: /apartment info [ ] | lock [ ] | takemoney [value] | putmoney [value]");
  234.         return 1;
  235.     }
  236.     if(strcmp(text,"info",true) == 0) // apartment info.
  237.     {
  238.         for(new i = 0; i < sizeof(ApartmentInfo); i++)
  239.         {
  240.             new string[500];
  241.             if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
  242.             {
  243.                 SendClientMessage(playerid, YELLOW, "|========================================|");
  244.                 if(ApartmentInfo[i][sLocked] == 1)
  245.                 {
  246.                     SendClientMessage(playerid, WHITE, "Locked: Yes");
  247.                 }
  248.                 if(ApartmentInfo[i][sLocked] == 0)
  249.                 {
  250.                     SendClientMessage(playerid, WHITE, "Locked: No");
  251.                 }
  252.                 format(string, sizeof(string), "Money in safe: %d $", ApartmentInfo[i][sMoney]);
  253.                 SendClientMessage(playerid, WHITE, string);
  254.                 format(string, sizeof(string), "Apartment Price: %d $", ApartmentInfo[i][sPrice]);
  255.                 SendClientMessage(playerid, WHITE, string);
  256.                 SendClientMessage(playerid, YELLOW, "|========================================|");
  257.                 return 1;
  258.             }
  259.         }
  260.         return 1;
  261.     }
  262.     if(strcmp(text,"lock",true) == 0) // lock/unlock apartment
  263.     {
  264.         for(new i = 0; i < sizeof(ApartmentInfo); i++)
  265.         {
  266.             if(IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]) && InApartment[playerid] == 501)
  267.             {
  268.                 GetPlayerName(playerid, plname, sizeof(plname));
  269.                 if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
  270.                 {
  271.                     if(ApartmentInfo[i][sLocked] == 1)
  272.                     {
  273.                         GameTextForPlayer(playerid, "~g~Unlocked", 5000, 6);
  274.                         ApartmentInfo[i][sLocked] = 0;
  275.                         return 1;
  276.                     }
  277.                     if(ApartmentInfo[i][sLocked] == 0)
  278.                     {
  279.                         GameTextForPlayer(playerid, "~r~Locked", 5000, 6);
  280.                         ApartmentInfo[i][sLocked] = 1;
  281.                         return 1;
  282.                     }
  283.                 }
  284.             }
  285.             if(IsPlayerInRangeOfPoint(playerid, 25,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]))
  286.             {
  287.                 if(IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && InApartment[playerid] != 501)
  288.                 {
  289.                     GetPlayerName(playerid, plname, sizeof(plname));
  290.                     if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
  291.                     {
  292.                         if(ApartmentInfo[i][sLocked] == 1)
  293.                         {
  294.                             GameTextForPlayer(playerid, "~g~Unlocked", 5000, 6);
  295.                             ApartmentInfo[i][sLocked] = 0;
  296.                             return 1;
  297.                         }
  298.                         if(ApartmentInfo[i][sLocked] == 0)
  299.                         {
  300.                             GameTextForPlayer(playerid, "~r~Locked", 5000, 6);
  301.                             ApartmentInfo[i][sLocked] = 1;
  302.                             return 1;
  303.                         }
  304.                     }
  305.                 }
  306.                 else { SendClientMessage(playerid, WHITE,"You are not in front of doors."); return 1; }
  307.             }
  308.         }
  309.         return 1;
  310.     }
  311.     if(strcmp(text,"putmoney",true) == 0) // taking money from safe
  312.     {
  313.         new string[128];
  314.         if(novac < 0) { return 1; }
  315.         for(new i = 0; i < sizeof(ApartmentInfo); i++)
  316.         {
  317.             GetPlayerName(playerid, plname, sizeof(plname));
  318.             if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0 && GetPlayerVirtualWorld(playerid) == ApartmentInfo[i][sWorld])
  319.             {
  320.                 if(GetPlayerMoney(playerid) >= novac)
  321.                 {
  322.                     ApartmentInfo[i][sMoney] += novac;
  323.                     GivePlayerMoney(playerid,-novac);
  324.                     format(string, sizeof(string), "You have put %d $ in safe, now you have: %d", novac, ApartmentInfo[i][sMoney]);
  325.                     SendClientMessage(playerid, YELLOW, string);
  326.                     SaveApartment(i);
  327.                     return 1;
  328.                 }
  329.                 else { SendClientMessage(playerid,GREY,"You don't have enoguht money!"); return 1; }
  330.             }
  331.         }
  332.         return 1;
  333.     }
  334.     if(strcmp(text,"takemoney",true) == 0) // puting money in safe
  335.     {
  336.         new string[128];
  337.         if(novac < 0) { return 1; }
  338.         for(new i = 0; i < sizeof(ApartmentInfo); i++)
  339.         {
  340.             GetPlayerName(playerid, plname, sizeof(plname));
  341.             if(IsPlayerInRangeOfPoint(playerid, 10,ApartmentInfo[i][sExitx], ApartmentInfo[i][sExity], ApartmentInfo[i][sExitz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0 && GetPlayerVirtualWorld(playerid) == ApartmentInfo[i][sWorld])
  342.             {
  343.                 if(ApartmentInfo[i][sMoney] >= novac)
  344.                 {
  345.                     ApartmentInfo[i][sMoney] -= novac;
  346.                     GivePlayerMoney(playerid,novac);
  347.                     format(string, sizeof(string), "You have take %d $ from safe, now you have: %d $", novac, ApartmentInfo[i][sMoney]);
  348.                     SendClientMessage(playerid, YELLOW, string);
  349.                     SaveApartment(i);
  350.                     return 1;
  351.                 }
  352.                 else { SendClientMessage(playerid,GREY,"You don't have enoguht money!"); return 1; }
  353.             }
  354.         }
  355.         return 1;
  356.     }
  357.     return 1;
  358. }
  359. CMD:buyapartment(playerid, params[]) // cmd to buy apartment
  360. {
  361.     for(new i = 0; i < sizeof(ApartmentInfo); i++)
  362.     {
  363.         GetPlayerName(playerid, plname, sizeof(plname));
  364.         if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
  365.         {
  366.             SendClientMessage(playerid, WHITE, "You alerdy have apartment!");
  367.             return 1;
  368.         }
  369.         if(IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]) && ApartmentInfo[i][sOwned] == 0)
  370.         {
  371.             if(GetPlayerMoney(playerid) > ApartmentInfo[i][sPrice])
  372.             {
  373.                 if(GetPlayerScore(playerid) >= ApartmentInfo[i][sLevel])
  374.                 {
  375.                     strmid(ApartmentInfo[i][sOwner], plname, 0, strlen(plname), 255);
  376.                     ApartmentInfo[i][sOwned] = 1;
  377.                     GivePlayerMoney(playerid,-ApartmentInfo[i][sPrice]);
  378.                     SendClientMessage(playerid, WHITE, "Congratz on new apartment, type /aphelp to see all commands!");
  379.                     strmid(ApartmentInfo[i][sOwner], plname, 0, strlen(plname), 255);
  380.                     LabelIPickup(i);
  381.                     SaveApartment(i);
  382.                     return 1;
  383.                 }
  384.                 else { SendClientMessage(playerid, GREY, "Your level is too low!"); return 1; }
  385.             }
  386.             else { SendClientMessage(playerid, GREY, "You don't have enough't money!"); return 1; }
  387.         }
  388.     }
  389.     return 1;
  390. }
  391. CMD:sellapartment(playerid, params[]) // selling apartment
  392. {
  393.     for(new i = 0; i < sizeof(ApartmentInfo); i++)
  394.     {
  395.         GetPlayerName(playerid, plname, sizeof(plname));
  396.         if(IsPlayerInRangeOfPoint(playerid, 3,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]) && strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
  397.         {
  398.             strmid(ApartmentInfo[i][sOwner], "State", 0, strlen("State"), 255);
  399.             ApartmentInfo[i][sOwned] = 0;
  400.             ApartmentInfo[i][sLocked] = 1;
  401.             GivePlayerMoney(playerid,ApartmentInfo[i][sPrice]);
  402.             SendClientMessage(playerid, WHITE, "You have sold you apartment!");
  403.             LabelIPickup(i);
  404.             SaveApartment(i);
  405.             return 1;
  406.         }
  407.     }
  408.     return 1;
  409. }
  410. CMD:changespawn(playerid, params[]) // change spawn
  411. {
  412.     for(new i = 0; i < sizeof(ApartmentInfo); i++)
  413.     {
  414.         GetPlayerName(playerid, plname, sizeof(plname));
  415.         if(strcmp(ApartmentInfo[i][sOwner], plname, false ) == 0)
  416.         {
  417.             if(ApartmentInfo[i][sSpawn] == 1)
  418.             {
  419.                 ApartmentInfo[i][sSpawn] = 0;
  420.                 SendClientMessage(playerid, YELLOW, "Now you will not spawn in apartment.");
  421.                 SaveApartment(i);
  422.                 return 1;
  423.             }
  424.             if(ApartmentInfo[i][sSpawn] == 0)
  425.             {
  426.                 ApartmentInfo[i][sSpawn] = 1;
  427.                 SendClientMessage(playerid, YELLOW, "From now, you will spawn in apartment!");
  428.                 SaveApartment(i);
  429.                 return 1;
  430.             }
  431.             return 1;
  432.         }
  433.     }
  434.     return 1;
  435. }
  436. CMD:aphelp(playerid, params[]) // list of all commands
  437. {
  438.     if(IsPlayerAdmin(playerid))
  439.     {
  440.         SendClientMessage(playerid, WHITE, "Admin Commands: /setapartment | /aptel | /reapartment | /apedit");
  441.     }
  442.     SendClientMessage(playerid, WHITE, "User Commands: /buyapartment | /sellapartment | /changespawn");
  443.     SendClientMessage(playerid, WHITE, "User Commands: /apartment info [any number] | lock [any number]| putmoney [value] | takemoney [value]");
  444.     return 1;
  445. }
  446. //======================[ADMIN CMD]=============================
  447. CMD:setapartment(playerid, params[]) // making apartment (ONLY RCON)
  448. {
  449.     if(IsPlayerAdmin(playerid))
  450.     {
  451.         new Float:X, Float:Y, Float:Z; new string[828]; new apid = 0;
  452.         GetPlayerPos(playerid, X,Y,Z);
  453.         for(new s = 0; s < sizeof(ApartmentInfo); s++)
  454.         {
  455.             if(ApartmentInfo[s][sCreated] == 1)
  456.             {
  457.                 apid = s + 1;
  458.             }
  459.         }
  460.         ApartmentInfo[apid][sEnterx] = X;
  461.         ApartmentInfo[apid][sEntery] = Y;
  462.         ApartmentInfo[apid][sEnterz] = Z;
  463.         ApartmentInfo[apid][sOwned] = 0;
  464.         ApartmentInfo[apid][sCreated] = 1;
  465.         ApartmentInfo[apid][sLocked] = 1;
  466.         ApartmentInfo[apid][sSpawn] = 1;
  467.         ApartmentInfo[apid][sWorld] = apid;
  468.         randomINT = randomEx(1,6); // random number from 1 to 5
  469.         if(randomINT == 1)
  470.         {
  471.             ApartmentInfo[apid][sExitx] = 225.756989;
  472.             ApartmentInfo[apid][sExity] = 1240.000000;
  473.             ApartmentInfo[apid][sExitz] = 1082.149902;
  474.             ApartmentInfo[apid][sInt] = 2;
  475.             ApartmentInfo[apid][sPrice] = 37000;
  476.             ApartmentInfo[apid][sLevel] = 1;
  477.             SaveApartment(apid);
  478.         }
  479.         if(randomINT == 2)
  480.         {
  481.             ApartmentInfo[apid][sExitx] = 260.983978;
  482.             ApartmentInfo[apid][sExity] = 1286.549927;
  483.             ApartmentInfo[apid][sExitz] = 1080.299927;
  484.             ApartmentInfo[apid][sInt] = 4;
  485.             ApartmentInfo[apid][sPrice] = 38000;
  486.             ApartmentInfo[apid][sLevel] = 2;
  487.             SaveApartment(apid);
  488.         }
  489.         if(randomINT == 3)
  490.         {
  491.             ApartmentInfo[apid][sExitx] = 385.803986;
  492.             ApartmentInfo[apid][sExity] = 1471.769897;
  493.             ApartmentInfo[apid][sExitz] = 1080.209961;
  494.             ApartmentInfo[apid][sInt] = 15;
  495.             ApartmentInfo[apid][sPrice] = 39000;
  496.             ApartmentInfo[apid][sLevel] = 3;
  497.             SaveApartment(apid);
  498.         }
  499.         if(randomINT == 4)
  500.         {
  501.             ApartmentInfo[apid][sExitx] = -42.4992;
  502.             ApartmentInfo[apid][sExity] = 1406.0690;
  503.             ApartmentInfo[apid][sExitz] = 1084.4297;
  504.             ApartmentInfo[apid][sInt] = 8;
  505.             ApartmentInfo[apid][sPrice] = 40000;
  506.             ApartmentInfo[apid][sLevel] = 4;
  507.             SaveApartment(apid);
  508.         }
  509.         if(randomINT == 5)
  510.         {
  511.             ApartmentInfo[apid][sExitx] = 446.5014;
  512.             ApartmentInfo[apid][sExity] = 507.0295;
  513.             ApartmentInfo[apid][sExitz] = 1001.4195;
  514.             ApartmentInfo[apid][sInt] = 12;
  515.             ApartmentInfo[apid][sPrice] = 41000;
  516.             ApartmentInfo[apid][sLevel] = 5;
  517.             SaveApartment(apid);
  518.         }
  519.         format(string,sizeof(string),"{458B00}For Sale! \n {458B00}Adress: {FFFFFF}%d \n {458B00}Price: {FFFFFF}$%d\n {458B00}Level: {FFFFFF}%d \n {458B00}Description: {FFFFFF}%s",ApartmentInfo[apid][sWorld], ApartmentInfo[apid][sPrice],ApartmentInfo[apid][sLevel], ApartmentInfo[apid][sDescription]);
  520.         ApartmentLabel[apid] = Create3DTextLabel(string ,0x00FF00AA,X,Y,Z,25, 0, 1);
  521.         strmid(ApartmentInfo[apid][sOwner],"State",0,strlen("State"),255);
  522.         strmid(ApartmentInfo[apid][sDescription], "Apartment", 0, strlen("Apartment"), 255);
  523.         strmid(ApartmentInfo[apid][sMessage],"For Sale",0,strlen("For Sale"),255);
  524.         ApartmentPickup[apid] = CreateDynamicPickup(1273, 1, ApartmentInfo[apid][sEnterx], ApartmentInfo[apid][sEntery], ApartmentInfo[apid][sEnterz]);
  525.         format(string, sizeof(string),"You have made Apartment ID: %d",apid);
  526.         SendClientMessage(playerid, RED, string);
  527.         LabelIPickup(apid);
  528.         SaveApartment(apid);
  529.         return 1;
  530.     }
  531.     else { SendClientMessage(playerid,GREY,"You are not admin(RCON)!!"); return 1; }
  532. }
  533. CMD:reapartment(playerid, params[]) // removing apartment (ONLY RCON)
  534. {
  535.     if(IsPlayerAdmin(playerid))
  536.     {
  537.         new apid;
  538.         if(sscanf(params, "i", apid))
  539.         {
  540.             SendClientMessage(playerid, WHITE, "/reapartment [id]");
  541.             return 1;
  542.         }
  543.         if(ApartmentInfo[apid][sCreated] == 1)
  544.         {
  545.             new string[500]; new file[500];
  546.             ApartmentInfo[apid][sCreated] = 0;
  547.             Delete3DTextLabel(ApartmentLabel[apid]);
  548.             DestroyDynamicPickup(ApartmentPickup[apid]);
  549.             SaveApartment(apid);
  550.             format(string, sizeof(string),"You have removed apartment id: %d",apid);
  551.             SendClientMessage(playerid, RED, string);
  552.             format(file,sizeof(file),"Apartments/%d.ini",apid);
  553.             fremove(file);
  554.             return 1;
  555.         }
  556.         else
  557.         {
  558.             SendClientMessage(playerid, GREY, "That apartment does not exist!");
  559.             return 1;
  560.         }
  561.     }
  562.     else { SendClientMessage(playerid,GREY,"You are not admin(RCON)!!"); return 1; }
  563. }
  564. CMD:aptel(playerid, params[]) // teleporting to apartment(ONLY RCON)
  565. {
  566.     if(IsPlayerAdmin(playerid))
  567.     {
  568.         new stan;
  569.         if(sscanf(params, "i", stan))
  570.         {
  571.             SendClientMessage(playerid, WHITE, "/apartment [id]");
  572.             return 1;
  573.         }
  574.         SetPlayerInterior(playerid,ApartmentInfo[stan][sInt]);
  575.         SetPlayerVirtualWorld(playerid,ApartmentInfo[stan][sWorld]);
  576.         SetPlayerPos(playerid,ApartmentInfo[stan][sExitx],ApartmentInfo[stan][sExity],ApartmentInfo[stan][sExitz]);
  577.         InApartment[playerid] = stan;
  578.         return 1;
  579.     }
  580.     else { SendClientMessage(playerid,GREY,"You are not admin(RCON)!!"); return 1; }
  581. }
  582. CMD:apedit(playerid, params[]) // editing apartments
  583. {
  584.     if(IsPlayerAdmin(playerid))
  585.     {
  586.         new text[48]; new broj; // broj = number
  587.         if(sscanf(params, "s[48]i",text, broj))
  588.         {
  589.             SendClientMessage(playerid, WHITE, "HELP: /sedit price [cena] | level [lvl] | int [1-3]");
  590.             return 1;
  591.         }
  592.         if(strcmp(text,"price",true) == 0) // editing price
  593.         {
  594.             if(broj < 0) { return 1; }
  595.             for(new i = 0; i < sizeof(ApartmentInfo); i++)
  596.             {
  597.                 new string[128];
  598.                 if(IsPlayerInRangeOfPoint(playerid, 2,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]))
  599.                 {
  600.                     ApartmentInfo[i][sPrice] = broj;
  601.                     format(string, sizeof(string), "You ahve changed Apartment ID: %d price, to: %d $", i, broj);
  602.                     SendClientMessage(playerid, WHITE, string);
  603.                     LabelIPickup(i);
  604.                     SaveApartment(i);
  605.                     return 1;
  606.                 }
  607.             }
  608.             return 1;
  609.         }
  610.         if(strcmp(text,"level",true) == 0) // editing level
  611.         {
  612.             if(broj < 0) { return 1; }
  613.             for(new i = 0; i < sizeof(ApartmentInfo); i++)
  614.             {
  615.                 new string[128];
  616.                 if(IsPlayerInRangeOfPoint(playerid, 2,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]))
  617.                 {
  618.                     ApartmentInfo[i][sLevel] = broj;
  619.                     format(string, sizeof(string), "You ahve changed Apartment ID: %d level to: %d", i, broj);
  620.                     SendClientMessage(playerid, WHITE, string);
  621.                     LabelIPickup(i);
  622.                     SaveApartment(i);
  623.                     return 1;
  624.                 }
  625.             }
  626.             return 1;
  627.         }
  628.         if(strcmp(text,"int",true) == 0) // editing interior(furniture)
  629.         {
  630.             if(broj < 0 || broj > 5) { SendClientMessage(playerid,GREY,"Interior(furniture) cannot be under 0 and over 5 !"); return 1; }
  631.             for(new i = 0; i < sizeof(ApartmentInfo); i++)
  632.             {
  633.                 new string[128];
  634.                 if(IsPlayerInRangeOfPoint(playerid, 2,ApartmentInfo[i][sEnterx], ApartmentInfo[i][sEntery], ApartmentInfo[i][sEnterz]))
  635.                 {
  636.                     if(broj == 1) // default furniture
  637.                     {
  638.                         ApartmentInfo[i][sExitx] = 225.756989;
  639.                         ApartmentInfo[i][sExity] = 1240.000000;
  640.                         ApartmentInfo[i][sExitz] = 1082.149902;
  641.                         ApartmentInfo[i][sInt] = 2;
  642.                         format(string, sizeof(string), "You have changed Apartment ID: %d furniture to  %d (this is default furniture)", i, broj);
  643.                         SendClientMessage(playerid, WHITE, string);
  644.                         SendClientMessage(playerid,WHITE,"Enter to Apartment to see new furniture!");
  645.                         SaveApartment(i);
  646.                         return 1;
  647.                     }
  648.                     if(broj == 2)
  649.                     {
  650.                         ApartmentInfo[i][sExitx] = 260.983978;
  651.                         ApartmentInfo[i][sExity] = 1286.549927;
  652.                         ApartmentInfo[i][sExitz] = 1080.299927;
  653.                         ApartmentInfo[i][sInt] = 4;
  654.                         format(string, sizeof(string), "You have changed Apartment ID: %d furniture to  %d", i, broj);
  655.                         SendClientMessage(playerid, WHITE, string);
  656.                         SendClientMessage(playerid,WHITE,"Enter to Apartment to see new furniture!");
  657.                         SaveApartment(i);
  658.                         return 1;
  659.                     }
  660.                     if(broj == 3)
  661.                     {
  662.                         ApartmentInfo[i][sExitx] = 385.803986;
  663.                         ApartmentInfo[i][sExity] = 1471.769897;
  664.                         ApartmentInfo[i][sExitz] = 1080.209961;
  665.                         ApartmentInfo[i][sInt] = 15;
  666.                         format(string, sizeof(string), "You have changed Apartment ID: %d furniture to  %d", i, broj);
  667.                         SendClientMessage(playerid, WHITE, string);
  668.                         SendClientMessage(playerid,WHITE,"Enter to Apartment to see new furniture!");
  669.                         SaveApartment(i);
  670.                         return 1;
  671.                     }
  672.                     if(broj == 4)
  673.                     {
  674.                         ApartmentInfo[i][sExitx] = -42.4992;
  675.                         ApartmentInfo[i][sExity] = 1406.0690;
  676.                         ApartmentInfo[i][sExitz] = 1084.4297;
  677.                         ApartmentInfo[i][sInt] = 8;
  678.                         format(string, sizeof(string), "You have changed Apartment ID: %d furniture to  %d", i, broj);
  679.                         SendClientMessage(playerid, WHITE, string);
  680.                         SendClientMessage(playerid,WHITE,"Enter to Apartment to see new furniture!");
  681.                         SaveApartment(i);
  682.                         return 1;
  683.                     }
  684.                     if(broj == 5)
  685.                     {
  686.                         ApartmentInfo[i][sExitx] = 446.5014;
  687.                         ApartmentInfo[i][sExity] = 507.0295;
  688.                         ApartmentInfo[i][sExitz] = 1001.4195;
  689.                         ApartmentInfo[i][sInt] = 12;
  690.                         format(string, sizeof(string), "You have changed Apartment ID: %d furniture to  %d", i, broj);
  691.                         SendClientMessage(playerid, WHITE, string);
  692.                         SendClientMessage(playerid,WHITE,"Enter to Apartment to see new furniture!");
  693.                         SaveApartment(i);
  694.                         return 1;
  695.                     }
  696.                 }
  697.             }
  698.             return 1;
  699.         }
  700.     }
  701.     else { SendClientMessage(playerid,GREY,"You are not admin(RCON)!!"); return 1; }
  702.     return 1;
  703. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement