shourya90

Untitled

May 22nd, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.00 KB | None | 0 0
  1. RCONCMD:redeemcodes(playerid, params[])
  2. {
  3.     mysql_query(connectionHandle, "SELECT * FROM vipcodes", true);
  4.    
  5.    
  6.     new s[1500], title[64], code[64],x = 0, i;
  7.     format(title, 64, "Unused Redeem Codes");
  8.     format(s, 1500, "ID\tCodes\tFor Vip Level\n");
  9.    
  10.    
  11.     for(new xx = cache_get_row_count(); x < xx; x++)
  12.     {
  13.      
  14.            
  15.         i = Iter_Free(Rcodes);
  16.         VipRedeem[i][VipCodeID] = cache_get_field_content_int(x, "id");
  17.         cache_get_field_content(x, "codes", code);
  18.         VipRedeem[i][VipLevels] = cache_get_field_content_int(x, "viplevel");
  19.         VipRedeem[i][CodeOwner] = cache_get_field_content_int(x, "owner");
  20.         VipRedeem[i][CodeUsed] = cache_get_field_content_int(x, "used");
  21.         Iter_Add(Rcodes, i);
  22.         if(VipRedeem[i][CodeOwner])
  23.         {
  24.             continue;
  25.         }
  26.        
  27.         if(VipRedeem[i][CodeUsed] != 0)
  28.         {
  29.             continue;
  30.         }
  31.         format(s, 1500, "%s%d\t%s\t%d\n", s, VipRedeem[i][VipCodeID], code, VipRedeem[i][VipLevels]);  
  32.     }
  33.     Dialog_Show(playerid, DialogRedeemsend, DIALOG_STYLE_TABLIST_HEADERS, title, s, "Send", "Close");    
  34.     return 1;
  35. }          
  36.  
  37. Dialog:DialogRedeemsend(playerid, response, listitem, inputtext[])
  38. {
  39.     if(response)
  40.     {
  41.         new a;
  42.         foreach(new i : Rcodes)
  43.         {
  44.    
  45.             if(a == listitem)
  46.             {
  47.                
  48.                 pData[playerid][ChosenCode] = i;  
  49.                 Dialog_Show(playerid, DialogRedeemsendopt, DIALOG_STYLE_LIST, "Sent Code To Player Options","Send by playerid ({FFFF66}If player is online{FFFFFF})\n{FFFFFF}Send by player name ({FFFF66}If player is offline{FFFFFF})", "Select", "Cancel");
  50.                 break;
  51.             }
  52.             else
  53.               a++;
  54.            
  55.                  
  56.         }
  57.     }
  58.     return 1;
  59. }
  60.  
  61. Dialog:DialogRedeemsendopt(playerid, response, listitem, inputtext[])
  62. {
  63.     if(response)
  64.     {
  65.        
  66.         switch(listitem)
  67.         {
  68.             case 0:
  69.             {
  70.                 Dialog_Show(playerid, DialogRedeemplayerid, DIALOG_STYLE_INPUT, "Sent Code By Playerid","Enter player id", "Send", "Cancel");
  71.             }
  72.             case 1:
  73.             {
  74.                 Dialog_Show(playerid, DialogRedeemplayername, DIALOG_STYLE_INPUT, "Sent Code By Player name","Enter player name", "Send", "Cancel");
  75.             }
  76.         }
  77.        
  78.     }
  79.     return 1;
  80. }        
  81.  
  82. Dialog:DialogRedeemplayerid(playerid, response, listitem, inputtext[])
  83. {
  84.     if(response)
  85.     {
  86.         new i = pData[playerid][ChosenCode],query[128];
  87.         new m = strval(inputtext);
  88.         if(!IsPlayerConnected(m))
  89.           return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
  90.  
  91.         mysql_format(connectionHandle, query, 128, "UPDATE vipcodes SET owner = %d WHERE id = %d",  pData[m][RealID], VipRedeem[i][VipCodeID]);
  92.         mysql_query(connectionHandle, query, false);
  93.         SendClientMessage(playerid, COLOR_YELLOW, "Redeem Code Sended");
  94.         Iter_Remove(Rcodes, i);
  95.         pData[playerid][ChosenCode] = -1;
  96.     }
  97.     return 1;
  98. }
  99.  
  100.  
  101. Dialog:DialogRedeemplayername(playerid, response, listitem, inputtext[])
  102. {
  103.     if(response)
  104.     {
  105.         new i = pData[playerid][ChosenCode],query[256];
  106.         //new m = strlen(inputtext);
  107.         mysql_format(connectionHandle, query, 256, "SELECT id FROM account WHERE username = '%e'",inputtext);
  108.         mysql_query(connectionHandle, query, true);
  109.         if(!cache_get_row_count())
  110.           return ShowNotification(playerid, "Sent Code By Player name", "Invalid player name");
  111.  
  112.         mysql_format(connectionHandle, query, 256, "UPDATE vipcodes SET owner = %d WHERE id = %d", cache_get_field_content_int(0, "id"), VipRedeem[i][VipCodeID]);
  113.         mysql_query(connectionHandle, query, false);
  114.         SendClientMessage(playerid, COLOR_YELLOW, "Redeem Code Sended");
  115.        
  116.         Iter_Remove(Rcodes, i);
  117.         pData[playerid][ChosenCode] = -1;
  118.     }
  119.     return 1;
  120. }
Add Comment
Please, Sign In to add comment