Advertisement
jlalt

wew

Jun 14th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.56 KB | None | 0 0
  1. #include a_samp
  2. #include foreach
  3. #include zcmd
  4.  
  5. new PlayerItem[MAX_PLAYERS], CompleteLoop[MAX_PLAYERS];
  6.  
  7. CMD:properties(playerid, params[])
  8. {
  9.     new string[128], cstring[128 * 10]/* | cause we wanna show 10 items so * 10 | */, cnt = 0;
  10.     foreach(new i : Player)
  11.     {
  12.         if(cnt > 9)
  13.         {
  14.             strcat(cstring, "Next\n");
  15.             break;
  16.         }
  17.         else
  18.         {
  19.             if(pOwns(playerid, i))
  20.             {
  21.                 new diff_secs = ( pInfo[i][PropertyExpire] - gettime() );
  22.                 new remain_months = ( diff_secs / (60 * 60 * 24 * 30) );
  23.                 diff_secs -= remain_months * 60 * 60 * 24 * 30;
  24.                 new remain_days = ( diff_secs / (60 * 60 * 24) );
  25.                 diff_secs -= remain_days * 60 * 60 * 24;
  26.                 new remain_hours = ( diff_secs / (60 * 60) );
  27.                 diff_secs -= remain_hours * 60 * 60;
  28.                 new remain_minutes = ( diff_secs / 60 );
  29.  
  30.                 format(string, sizeof(string), "{FFFFFF}Property: {00FF00}%s {FFFFFF}Location: {00FF00}%s (%d months %d days %d hours %d minutes)\n", pInfo[i][prName], GetZoneName(pInfo[i][PropertyX], pInfo[i][PropertyY], pInfo[i][PropertyZ]),
  31.                 remain_months, remain_days, remain_hours, remain_minutes);
  32.                 strcat(cstring, string);
  33.                 cnt++;
  34.                 CompleteLoop[playerid] = cnt;
  35.                 PlayerItem[playerid] = cnt;
  36.             }
  37.         }
  38.     }
  39.     if(cnt == 0) ShowPlayerDialog(playerid, WARN, DIALOG_STYLE_MSGBOX, "Properties", "{FF0000}No properties found", "Close", "");
  40.     else ShowPlayerDialog(playerid, DIALOG_PROPERTIES, DIALOG_STYLE_LIST, "Properties", cstring, "Close", "");
  41.     return 1;
  42. }
  43.  
  44. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  45. {
  46.     if(dialogid == DIALOG_PROPERTIES)
  47.     {
  48.         if(listitem == PlayerItem[playerid])
  49.         {
  50.             if(strfind(inputtext, "Back", true, 0) != -1))
  51.             {
  52.                 cmd_properties(playerid, "");
  53.             }
  54.             else
  55.             {
  56.                 new string[128], cstring[128 * 10]/* | cause we wanna show 10 items so * 10 | */, cnt = 0;
  57.                 foreach(new i : Player)
  58.                 {
  59.                     if(cnt == 0)
  60.                     {
  61.                         i = CompleteLoop[playerid];
  62.                     }
  63.                     if(cnt > 9)
  64.                     {
  65.                         strcat(cstring, "Next\n");
  66.                         break;
  67.                     }
  68.                     else
  69.                     {
  70.                         if(pOwns(playerid, i))
  71.                         {
  72.                             new diff_secs = ( pInfo[i][PropertyExpire] - gettime() );
  73.                             new remain_months = ( diff_secs / (60 * 60 * 24 * 30) );
  74.                             diff_secs -= remain_months * 60 * 60 * 24 * 30;
  75.                             new remain_days = ( diff_secs / (60 * 60 * 24) );
  76.                             diff_secs -= remain_days * 60 * 60 * 24;
  77.                             new remain_hours = ( diff_secs / (60 * 60) );
  78.                             diff_secs -= remain_hours * 60 * 60;
  79.                             new remain_minutes = ( diff_secs / 60 );
  80.  
  81.                             format(string, sizeof(string), "{FFFFFF}Property: {00FF00}%s {FFFFFF}Location: {00FF00}%s (%d months %d days %d hours %d minutes)\n", pInfo[i][prName], GetZoneName(pInfo[i][PropertyX], pInfo[i][PropertyY], pInfo[i][PropertyZ]),
  82.                             remain_months, remain_days, remain_hours, remain_minutes);
  83.                             strcat(cstring, string);
  84.                             cnt++;
  85.                             CompleteLoop[playerid] += cnt;
  86.                             PlayerItem[playerid] = cnt;
  87.                         }
  88.                     }
  89.                 }
  90.                 if(cnt <= 9)
  91.                 {
  92.                     strcat(cstring, "Back\n");
  93.                 }
  94.                 if(cnt == 0) ShowPlayerDialog(playerid, WARN, DIALOG_STYLE_MSGBOX, "Properties", "{FF0000}No properties found", "Close", "");
  95.                 else ShowPlayerDialog(playerid, DIALOG_PROPERTIES, DIALOG_STYLE_LIST, "Properties", cstring, "Close", "");
  96.             }
  97.         }
  98.         else
  99.         {
  100.            // Property chose
  101.         }
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement