Guest User

Untitled

a guest
Jun 6th, 2011
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.43 KB | None | 0 0
  1. #include <a_samp>
  2. #include <Dini>
  3. #include <dutils>
  4. #define FILTERSCRIPT
  5. #if defined FILTERSCRIPT
  6. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  7. #define COLOR_GREEN           0x33AA33AA
  8. #define COLOR_RED             0xAA3333AA
  9. #define COLOR_YELLOW          0xFFFF00AA
  10. #define COLOR_LIGHTBLUE       0x33CCFFAA
  11. #define COLOR_ORANGE          0xFF9900AA
  12. #pragma tabsize 0
  13. #define PlayerFile              "VIP/%s.ini"
  14. public OnFilterScriptInit()
  15.     {
  16.     return 1;
  17.     }
  18. #endif
  19. enum PLAYER_MAIN {
  20.     pName[MAX_PLAYER_NAME],
  21.     Pip[16],
  22.     Vip_Level
  23. }
  24. new Pinfo[MAX_PLAYERS][PLAYER_MAIN];
  25. public OnPlayerConnect(playerid)
  26. {
  27.     new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
  28.     if(!dini_Exists(file)) {
  29.         dini_Create(file);
  30.         dini_Set(file,"Name",Name);
  31.         dini_Set(file,"Ip",Ip);
  32.         dini_IntSet(file,"Vip_Level",0);
  33.     }
  34.     Pinfo[playerid][Vip_Level]                = dini_Int(file,"Vip_Level");
  35.     return 1;
  36. }
  37. public OnPlayerDisconnect(playerid, reason)
  38. {
  39.     new file[100];
  40.     format(file,sizeof(file),PlayerFile,Pinfo[playerid][pName]);
  41.     dini_Set(file,"Name",Pinfo[playerid][pName]);
  42.     dini_Set(file,"Ip",Pinfo[playerid][Pip]);
  43.     dini_IntSet(file,"Vip_Level",Pinfo[playerid][Vip_Level]);
  44.     Pinfo[playerid][Vip_Level]  = 0;
  45.     return 1;
  46. }
  47. public OnPlayerCommandText(playerid, cmdtext[])
  48. {
  49. dcmd(setvip,6,cmdtext);
  50. dcmd(viplevel,8,cmdtext);
  51. return 0;
  52. }
  53.  
  54. dcmd_setvip(playerid, params[])
  55. {
  56.     new file[100];
  57.     format(file,sizeof(file),PlayerFile,Pinfo[playerid][pName]);
  58.     new string[128],string2[128];
  59.     new giveplayerid, level;
  60.     new playername[MAX_PLAYER_NAME],idname[MAX_PLAYER_NAME];
  61.     GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
  62.     GetPlayerName(playerid,idname,MAX_PLAYER_NAME);
  63.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You Have To Be Rcon Admin To Use This Command!");
  64.     if(sscanf(params, "ud", giveplayerid, level))return SendClientMessage(playerid, COLOR_RED, "Usage: /setvip [Playerid/Partname] [Level]");
  65.     else if (giveplayerid == INVALID_PLAYER_ID)return SendClientMessage(playerid, COLOR_RED, "Player Is Not Connected");
  66.     else if (level > 3)return SendClientMessage(playerid, COLOR_RED, "Maximum Vip Level Is 3");
  67.     else
  68.     {
  69.         Pinfo[giveplayerid][Vip_Level] = level;
  70.         format(string,sizeof(string),"Administrator %s Set Your Vip Level To %d",playername,level);
  71.         SendClientMessage(giveplayerid,COLOR_YELLOW,string);
  72.         format(string2,sizeof(string2),"%s Vip Level Is Now %d",idname,level);
  73.         SendClientMessageToAll(COLOR_YELLOW,string2);
  74.         dini_IntSet(file,"Vip_Level",Pinfo[playerid][Vip_Level]);
  75.     }
  76.     return 1;
  77. }
  78. dcmd_viplevel(playerid, params[])
  79. {
  80. #pragma unused params
  81. new string1[128],string2[128],string3[128];
  82. format(string1,sizeof(string1),"============================");
  83. format(string2,sizeof(string2),"Your V.I.P Level Is %d",Pinfo[playerid][Vip_Level]);
  84. format(string3,sizeof(string3),"============================");
  85. SendClientMessage(playerid,COLOR_YELLOW,string1);
  86. SendClientMessage(playerid,COLOR_YELLOW,string2);
  87. SendClientMessage(playerid,COLOR_YELLOW,string3);
  88. return 1;
  89. }
  90.  
  91. //------------------[SSCANF]-------------------------------------
  92. stock sscanf(string[], format[], {Float,_}:...)
  93. {
  94.     #if defined isnull
  95.         if (isnull(string))
  96.     #else
  97.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  98.     #endif
  99.         {
  100.             return format[0];
  101.         }
  102.     #pragma tabsize 4
  103.     new
  104.         formatPos = 0,
  105.         stringPos = 0,
  106.         paramPos = 2,
  107.         paramCount = numargs(),
  108.         delim = ' ';
  109.     while (string[stringPos] && string[stringPos] <= ' ')
  110.     {
  111.         stringPos++;
  112.     }
  113.     while (paramPos < paramCount && string[stringPos])
  114.     {
  115.         switch (format[formatPos++])
  116.         {
  117.             case '\0':
  118.             {
  119.                 return 0;
  120.             }
  121.             case 'i', 'd':
  122.             {
  123.                 new
  124.                     neg = 1,
  125.                     num = 0,
  126.                     ch = string[stringPos];
  127.                 if (ch == '-')
  128.                 {
  129.                     neg = -1;
  130.                     ch = string[++stringPos];
  131.                 }
  132.                 do
  133.                 {
  134.                     stringPos++;
  135.                     if ('0' <= ch <= '9')
  136.                     {
  137.                         num = (num * 10) + (ch - '0');
  138.                     }
  139.                     else
  140.                     {
  141.                         return -1;
  142.                     }
  143.                 }
  144.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  145.                 setarg(paramPos, 0, num * neg);
  146.             }
  147.             case 'h', 'x':
  148.             {
  149.                 new
  150.                     num = 0,
  151.                     ch = string[stringPos];
  152.                 do
  153.                 {
  154.                     stringPos++;
  155.                     switch (ch)
  156.                     {
  157.                         case 'x', 'X':
  158.                         {
  159.                             num = 0;
  160.                             continue;
  161.                         }
  162.                         case '0' .. '9':
  163.                         {
  164.                             num = (num << 4) | (ch - '0');
  165.                         }
  166.                         case 'a' .. 'f':
  167.                         {
  168.                             num = (num << 4) | (ch - ('a' - 10));
  169.                         }
  170.                         case 'A' .. 'F':
  171.                         {
  172.                             num = (num << 4) | (ch - ('A' - 10));
  173.                         }
  174.                         default:
  175.                         {
  176.                             return -1;
  177.                         }
  178.                     }
  179.                 }
  180.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  181.                 setarg(paramPos, 0, num);
  182.             }
  183.             case 'c':
  184.             {
  185.                 setarg(paramPos, 0, string[stringPos++]);
  186.             }
  187.             case 'f':
  188.             {
  189.  
  190.                 new changestr[16], changepos = 0, strpos = stringPos;
  191.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  192.                 {
  193.                     changestr[changepos++] = string[strpos++];
  194.                     }
  195.                 changestr[changepos] = '\0';
  196.                 setarg(paramPos,0,_:floatstr(changestr));
  197.             }
  198.             case 'p':
  199.             {
  200.                 delim = format[formatPos++];
  201.                 continue;
  202.             }
  203.             case '\'':
  204.             {
  205.                 new
  206.                     end = formatPos - 1,
  207.                     ch;
  208.                 while ((ch = format[++end]) && ch != '\'') {}
  209.                 if (!ch)
  210.                 {
  211.                     return -1;
  212.                 }
  213.                 format[end] = '\0';
  214.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  215.                 {
  216.                     if (format[end + 1])
  217.                     {
  218.                         return -1;
  219.                     }
  220.                     return 0;
  221.                 }
  222.                 format[end] = '\'';
  223.                 stringPos = ch + (end - formatPos);
  224.                 formatPos = end + 1;
  225.             }
  226.             case 'u':
  227.             {
  228.                 new
  229.                     end = stringPos - 1,
  230.                     id = 0,
  231.                     bool:num = true,
  232.                     ch;
  233.                 while ((ch = string[++end]) && ch != delim)
  234.                 {
  235.                     if (num)
  236.                     {
  237.                         if ('0' <= ch <= '9')
  238.                         {
  239.                             id = (id * 10) + (ch - '0');
  240.                         }
  241.                         else
  242.                         {
  243.                             num = false;
  244.                         }
  245.                     }
  246.                 }
  247.                 if (num && IsPlayerConnected(id))
  248.                 {
  249.                     setarg(paramPos, 0, id);
  250.                 }
  251.                 else
  252.                 {
  253.                     #if !defined foreach
  254.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  255.                         #define __SSCANF_FOREACH__
  256.                     #endif
  257.                     string[end] = '\0';
  258.                     num = false;
  259.                     new
  260.                         name[MAX_PLAYER_NAME];
  261.                     id = end - stringPos;
  262.                     foreach (Player, playerid)
  263.                     {
  264.                         GetPlayerName(playerid, name, sizeof (name));
  265.                         if (!strcmp(name, string[stringPos], true, id))
  266.                         {
  267.                             setarg(paramPos, 0, playerid);
  268.                             num = true;
  269.                             break;
  270.                         }
  271.                     }
  272.                     if (!num)
  273.                     {
  274.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  275.                     }
  276.                     string[end] = ch;
  277.                     #if defined __SSCANF_FOREACH__
  278.                         #undef foreach
  279.                         #undef __SSCANF_FOREACH__
  280.                     #endif
  281.                 }
  282.                 stringPos = end;
  283.             }
  284.             case 's', 'z':
  285.             {
  286.                 new
  287.                     i = 0,
  288.                     ch;
  289.                 if (format[formatPos])
  290.                 {
  291.                     while ((ch = string[stringPos++]) && ch != delim)
  292.                     {
  293.                         setarg(paramPos, i++, ch);
  294.                     }
  295.                     if (!i)
  296.                     {
  297.                         return -1;
  298.                     }
  299.                 }
  300.                 else
  301.                 {
  302.                     while ((ch = string[stringPos++]))
  303.                     {
  304.                         setarg(paramPos, i++, ch);
  305.                     }
  306.                 }
  307.                 stringPos--;
  308.                 setarg(paramPos, i, '\0');
  309.             }
  310.             default:
  311.             {
  312.                 continue;
  313.             }
  314.         }
  315.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  316.         {
  317.             stringPos++;
  318.         }
  319.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  320.         {
  321.             stringPos++;
  322.         }
  323.         paramPos++;
  324.     }
  325.     do
  326.     {
  327.         if ((delim = format[formatPos++]) > ' ')
  328.         {
  329.             if (delim == '\'')
  330.             {
  331.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  332.             }
  333.             else if (delim != 'z')
  334.             {
  335.                 return delim;
  336.             }
  337.         }
  338.     }
  339.     while (delim > ' ');
  340.     return 0;
  341. }
  342.  
  343. //================MYCODE======================//
  344.  
  345. dcmd_vr(playerid,params[])
  346.  {
  347.  if(Pinfo[giveplayerid][Vip_Level] == 1)
  348.  {
  349.  if (strcmp("/nameoff", cmdtext, true) == 0)
  350.  {
  351.     for(new i = 0; i < MAX_PLAYERS; i++) ShowPlayerNameTagForPlayer(playerid, i, false);
  352.     GameTextForPlayer(playerid, "~W~Nametags ~R~off", 5000, 5);
  353.     return 1;
  354.  }
  355.  }
  356.  else
  357.  {
  358.  SendClientMessage(playerid,COLOR_RED,"You need to be a VIP to use this command!!");
  359.  }
  360.  return 1;
  361.  }
Advertisement
Add Comment
Please, Sign In to add comment