Advertisement
DucK196

DucK's Properties System!!

May 28th, 2012
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.37 KB | None | 0 0
  1. #include <a_samp>
  2. #define PropBuy 147
  3. #define PropSell 148
  4. #define Msg 149
  5. #define PayTime 3 // Pay Timer (In MINUTES!!!!)
  6.  
  7. new Ptime[MAX_PLAYERS]=0;
  8. new HProps[MAX_PLAYERS];
  9. enum Prop
  10. {
  11.     PName[30],
  12.     PPrice,
  13.     PEarn,
  14.     Float:Px,
  15.     Float:Py,
  16.     Float:Pz,
  17.     POwner[24],
  18.     PoID
  19. };
  20. new PropVar[][Prop] =
  21. {
  22. //  {"Name", Price, Earning, X, Y, Z},
  23.     {"LV Gas Station", 15000, 70, 2117.5022,897.8309,11.1797},
  24.     {"LV Ammunation", 20000, 2000, 2155.4102,946.4137,10.8203},
  25.     {"Four-Dragons Casino",100000, 5000, 2024.5090,1008.0150,10.5257},
  26.     {"LV Money Ship", 50000, 2500, 2008.6862,1544.8174,12.4446},
  27.     {"Royal Casino", 70000, 3500, 2087.8044,1516.0709,10.5244}
  28. };
  29.  
  30. new Pu[sizeof(PropVar)+1];
  31. new Text3D:Pt[sizeof(PropVar)+1];
  32. new CurrentP[MAX_PLAYERS];
  33. new str[256];
  34.  
  35. public OnFilterScriptInit()
  36. {
  37.     for(new i; i<sizeof(PropVar); i++)
  38.     {
  39.         format(PropVar[i][POwner], 24, "None");
  40.         PropVar[i][PoID] = -1;
  41.         Pu[i] = CreatePickup(1272, 1, PropVar[i][Px], PropVar[i][Py] , PropVar[i][Pz], -1);
  42.         format(str, 256, "{FF0000}%s\n{FFFF00}Owner: {FFFFFF}%s\n{FFFF00}Price: {FFFFFF}%d$\n{FFFF00}Earning: {FFFFFF}%d$",PropVar[i][PName], PropVar[i][POwner], PropVar[i][PPrice], PropVar[i][PEarn]);
  43.         Pt[i] = Create3DTextLabel(str, 0xFFFFFFAA, PropVar[i][Px], PropVar[i][Py] , PropVar[i][Pz], 20.0, 0, 0);
  44.     }
  45.     print(">>PropSys By _DucK_ >>....Loaded");
  46.     return 1;
  47. }
  48.  
  49. public OnFilterScriptExit()
  50. {
  51.     for(new i; i<sizeof(PropVar)+1; i++)
  52.     {
  53.         DestroyPickup(Pu[i]);
  54.         Delete3DTextLabel(Pt[i]);
  55.     }
  56.     print(">>PropSys By _DucK_ >>....UnLoaded");
  57.     return 1;
  58. }
  59.  
  60. public OnPlayerPickUpPickup(playerid, pickupid)
  61. {
  62.     for(new i; i<sizeof(PropVar); i++)
  63.     {
  64.         if(pickupid == Pu[i])
  65.         {
  66.             if(!strcmp(PropVar[i][POwner], "None", false))
  67.             {          
  68.                 format(str, 256, "{FFFFFF}Do You Want To Buy {0000FF}%s {FFFFFF}For {0000FF}%d$ {FFFFFF}And Earn  {0000FF}%d$?", PropVar[i][PName], PropVar[i][PPrice], PropVar[i][PEarn]);
  69.                 ShowPlayerDialog(playerid, PropBuy, DIALOG_STYLE_MSGBOX, "{FFFFFF}Property System",str, "Buy", "Exit");
  70.                 CurrentP[playerid] = i;
  71.             }
  72.             else if(!strcmp(PropVar[i][POwner], GetName(playerid), false))
  73.             {
  74.                 format(str, 256, "{FFFFFF}Do You Want To Sell {0000FF}%s {FFFFFF}For {0000FF}%d$ {FFFFFF}And Stop Earning Money From It?", PropVar[i][PName], PropVar[i][PPrice]/2);
  75.                 ShowPlayerDialog(playerid, PropSell, DIALOG_STYLE_MSGBOX, "{FFFFFF}Property System", str, "Sell", "Exit");
  76.             }
  77.             else
  78.             {
  79.                 format(str, 256, "{FFFFFF}Owned Property. {FFFFFF}This Property Is Owned By Another Player, So You Can't Buy Ita");
  80.                 SendClientMessage(playerid, -1, str);
  81.             }
  82.         }
  83.     }
  84.     return 1;
  85. }
  86.  
  87. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  88. {
  89.     if(dialogid == PropBuy && response)
  90.     {
  91.         if(GetPlayerMoney(playerid) < PropVar[CurrentP[playerid]][PPrice]) return SendClientMessage(playerid, -1, "no Enough Money");
  92.         GivePlayerMoney(playerid, -PropVar[CurrentP[playerid]][PPrice]);
  93.         format(PropVar[CurrentP[playerid]][POwner], 24, "%s", GetName(playerid));
  94.         PropVar[CurrentP[playerid]][PoID] = playerid;
  95.         format(str, 256, "{00FF00}%s\n{FFFF00}Owner: {FFFFFF}%s\n{FFFF00}Price: {FFFFFF}%d$\n{FFFF00}Earning: {FFFFFF}%d$", PropVar[CurrentP[playerid]][PName], PropVar[CurrentP[playerid]][POwner], PropVar[CurrentP[playerid]][PPrice], PropVar[CurrentP[playerid]][PEarn]);
  96.         Update3DTextLabelText(Pt[CurrentP[playerid]], 0xFFFFFFAA, str);
  97.         PayTimer(playerid);
  98.         SendClientMessage(playerid, -1, "{FFFF00}PropSys: You Have Bought A New Propery! (/PropList)");
  99.     }
  100.     if(dialogid == PropSell && response)
  101.     {
  102.         GivePlayerMoney(playerid, PropVar[CurrentP[playerid]][PPrice]/2);
  103.         format(PropVar[CurrentP[playerid]][POwner], 24, "None");
  104.         PropVar[CurrentP[playerid]][PoID] = -1;
  105.         format(str, 256, "{FF0000}%s\n{FFFF00}Owner: {FFFFFF}%s\n{FFFF00}Price: {FFFFFF}%d$\n{FFFF00}Earning: {FFFFFF}%d$", PropVar[CurrentP[playerid]][PName], PropVar[CurrentP[playerid]][POwner], PropVar[CurrentP[playerid]][PPrice], PropVar[CurrentP[playerid]][PEarn]);
  106.         Update3DTextLabelText(Pt[CurrentP[playerid]], 0xFFFFFFAA, str);
  107.         SendClientMessage(playerid, -1, "{FFFF00}PropSys: You Have Sold Your Propery! (/PropList)");
  108.         CurrentP[playerid] = 0;
  109.         HProps[playerid]--;
  110.         if(HProps[playerid] == 0)
  111.         {
  112.             KillTimer(Ptime[playerid]);
  113.         }
  114.     }
  115.     return 0;
  116. }
  117. public OnPlayerCommandText(playerid, cmdtext[])
  118. {
  119.     if(!strcmp(cmdtext, "/PropList", true))
  120.     {
  121.         if(HProps[playerid] == 0) return ShowPlayerDialog(playerid, Msg, DIALOG_STYLE_MSGBOX, "{FFFF00}PropSys", "{FFFFFF}You Don't Have Any Properties!", "OK", "");
  122.         new Te;
  123.         format(str, sizeof(str), "");
  124.         for(new i; i<sizeof(PropVar); i++)
  125.         {
  126.             if(playerid == PropVar[i][PoID])
  127.             {
  128.                 format(str, 256, "%s\n{FFFFFF}Name: {FFFF00}%s {FFFFFF}- Earning: {FFFF00}%d$", str, PropVar[i][PName], PropVar[i][PEarn]);
  129.                 Te += PropVar[i][PEarn];
  130.             }
  131.         }
  132.         format(str, 256, "%s\n{FFFFFF}Total Earning: {0000FF}%d$", str, Te);
  133.         ShowPlayerDialog(playerid, Msg, DIALOG_STYLE_MSGBOX, "{FFFF00}PropSys", str, "OK", "");
  134.         return 1;
  135.     }
  136.     if(!strcmp(cmdtext, "/Credit", true))
  137.     {
  138.         ShowPlayerDialog(playerid, Msg, DIALOG_STYLE_MSGBOX, "{FFFF00}PropSys", "{FF0000}Credits:\n{FFFFFF}\n\nPropSys By _DucK_\nv0.1\nDO NOT REMOVE", "OK", "");
  139.         return 1;
  140.     }
  141.     return 0;
  142. }
  143. public OnPlayerDisconnect(playerid)
  144. {
  145.     for(new i; i<sizeof(PropVar); i++)
  146.     {
  147.         format(PropVar[i][POwner], 24, "None");
  148.         PropVar[i][PoID] = -1;
  149.         format(str, 256, "{FF0000}%s\n{FFFF00}Owner: {FFFFFF}%s\n{FFFF00}Price: {FFFFFF}%d$\n{FFFF00}Earning: {FFFFFF}%d$", PropVar[i][PName], PropVar[i][POwner], PropVar[i][PPrice], PropVar[i][PEarn]);
  150.         Update3DTextLabelText(Pt[i], 0xFFFFFFAA, str);
  151.         HProps[playerid] = 0;
  152.     }
  153.     return 1;
  154. }
  155.  
  156. forward PayTimer(playerid);
  157. public PayTimer(playerid)
  158. {
  159.     if(HProps[playerid] == 0)
  160.     {
  161.         Ptime[playerid] = SetTimerEx("PayTZ",1000*60*PayTime,1,"i",playerid);
  162.     }
  163.     HProps[playerid]++;
  164. }
  165.  
  166. forward PayTZ(playerid);
  167. public PayTZ(playerid)
  168. {
  169.     new Earn[MAX_PLAYERS];
  170.     for(new i; i<sizeof(PropVar); i++)
  171.     {
  172.         if(PropVar[i][PoID] == playerid)
  173.         {
  174.             Earn[playerid] += PropVar[i][PEarn];   
  175.         }
  176.     }
  177.     format(str, 256, "{FFFF00}PropSys: {FFFFFF}You Have Earned {00FF00}%d$ {FFFFFF}From Your Properties {FF0000}(/PropList)", Earn[playerid]);
  178.     SendClientMessage(playerid, -1, str);
  179.     GivePlayerMoney(playerid, Earn[playerid]);
  180. }
  181. stock GetName(playerid)
  182. {
  183.     new xname[MAX_PLAYER_NAME];
  184.     GetPlayerName(playerid,xname,sizeof(xname));
  185.     return xname;
  186. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement