Guest User

Oxside

a guest
Mar 31st, 2009
915
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.66 KB | None | 0 0
  1. /*---------------------------------------------------------------
  2. File Name: Level.pwn
  3. Script Name: Level System
  4. Scipter: Oxside
  5. -----------------------------------------------------------------
  6. This scipt has been created by oxside.
  7. The copyright completly to me, dont remove credits.
  8. If you edit this script you could put your name by the credits!
  9. DO NOT RERELEASE IT!!!!!! (If it is an edit too not!)
  10. Have fun with it!
  11. ----------------------------------------------------------------
  12. Credits goes to:
  13. - Myself - For making Script
  14. - Kye - For making SA-MP
  15. - DracoBlue for making dudb
  16. --------------------------------------------------------------*/
  17.  
  18. #include <a_samp>
  19. #include <dudb>
  20. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  21.  
  22. new Level[MAX_PLAYERS];
  23.  
  24. #if defined FILTERSCRIPT
  25.  
  26. public OnFilterScriptInit()
  27. {
  28.     print("Level Filterscript Loaded!");
  29.     return 1;
  30. }
  31.  
  32. public OnFilterScriptExit()
  33. {
  34.     return 1;
  35. }
  36.  
  37. #else
  38.  
  39. main()
  40. {
  41. }
  42.  
  43. #endif
  44.  
  45. public OnPlayerConnect(playerid)
  46. {
  47.     new formatZ[256];
  48.     format(formatZ,sizeof(formatZ),"%s Level.ox",PlayerName(playerid));
  49.     if(!udb_Exists(formatZ))
  50.     {
  51.     udb_Create(formatZ,"209010");
  52.     }
  53.     Level[playerid] = dUserINT(formatZ).("Level");
  54.     return 1;
  55. }
  56.  
  57. public OnPlayerDisconnect(playerid, reason)
  58. {
  59.     new formatZ2[256];
  60.     format(formatZ2,sizeof(formatZ2),"%s Level.ox",PlayerName(playerid));
  61.     dUserSetINT(formatZ2).("Level",Level[playerid]);
  62.     return 1;
  63. }
  64. stock PlayerName(playerid) {
  65.   new name[255];
  66.   GetPlayerName(playerid, name, 255);
  67.   return name;
  68. }
  69.  
  70.  
  71. public OnPlayerCommandText(playerid, cmdtext[])
  72. {
  73.     dcmd(setlevel, 7, cmdtext);
  74.     return 0;
  75. }
  76.  
  77.     dcmd_setlevel(playerid, params[])
  78.     {
  79.     new id, level;
  80.     if (sscanf(params, "ii", id, level)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/setlevel <playerid/partname> <level>\"");
  81.     if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "[ERROR] Player not found");
  82.     Level[id] = level;
  83.     SendClientMessage(id, 0xFF0000AA, "[INFO] SomeOne Has given you an level!");
  84.     SendClientMessage(playerid, 0x00FF00AA, "[INFO] You has got an level!");
  85.     return 1;
  86. }
  87.  
  88. stock sscanf(string[], format[], {Float,_}:...)
  89. {
  90.     #if defined isnull
  91.         if (isnull(string))
  92.     #else
  93.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  94.     #endif
  95.         {
  96.             return format[0];
  97.         }
  98.     #pragma tabsize 4
  99.     new
  100.         formatPos = 0,
  101.         stringPos = 0,
  102.         paramPos = 2,
  103.         paramCount = numargs(),
  104.         delim = ' ';
  105.     while (string[stringPos] && string[stringPos] <= ' ')
  106.     {
  107.         stringPos++;
  108.     }
  109.     while (paramPos < paramCount && string[stringPos])
  110.     {
  111.         switch (format[formatPos++])
  112.         {
  113.             case '\0':
  114.             {
  115.                 return 0;
  116.             }
  117.             case 'i', 'd':
  118.             {
  119.                 new
  120.                     neg = 1,
  121.                     num = 0,
  122.                     ch = string[stringPos];
  123.                 if (ch == '-')
  124.                 {
  125.                     neg = -1;
  126.                     ch = string[++stringPos];
  127.                 }
  128.                 do
  129.                 {
  130.                     stringPos++;
  131.                     if ('0' <= ch <= '9')
  132.                     {
  133.                         num = (num * 10) + (ch - '0');
  134.                     }
  135.                     else
  136.                     {
  137.                         return -1;
  138.                     }
  139.                 }
  140.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  141.                 setarg(paramPos, 0, num * neg);
  142.             }
  143.             case 'h', 'x':
  144.             {
  145.                 new
  146.                     num = 0,
  147.                     ch = string[stringPos];
  148.                 do
  149.                 {
  150.                     stringPos++;
  151.                     switch (ch)
  152.                     {
  153.                         case 'x', 'X':
  154.                         {
  155.                             num = 0;
  156.                             continue;
  157.                         }
  158.                         case '0' .. '9':
  159.                         {
  160.                             num = (num << 4) | (ch - '0');
  161.                         }
  162.                         case 'a' .. 'f':
  163.                         {
  164.                             num = (num << 4) | (ch - ('a' - 10));
  165.                         }
  166.                         case 'A' .. 'F':
  167.                         {
  168.                             num = (num << 4) | (ch - ('A' - 10));
  169.                         }
  170.                         default:
  171.                         {
  172.                             return -1;
  173.                         }
  174.                     }
  175.                 }
  176.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  177.                 setarg(paramPos, 0, num);
  178.             }
  179.             case 'c':
  180.             {
  181.                 setarg(paramPos, 0, string[stringPos++]);
  182.             }
  183.             case 'f':
  184.             {
  185.                 setarg(paramPos, 0, _:floatstr(string[stringPos]));
  186.             }
  187.             case 'p':
  188.             {
  189.                 delim = format[formatPos++];
  190.                 continue;
  191.             }
  192.             case '\'':
  193.             {
  194.                 new
  195.                     end = formatPos - 1,
  196.                     ch;
  197.                 while ((ch = format[++end]) && ch != '\'') {}
  198.                 if (!ch)
  199.                 {
  200.                     return -1;
  201.                 }
  202.                 format[end] = '\0';
  203.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  204.                 {
  205.                     if (format[end + 1])
  206.                     {
  207.                         return -1;
  208.                     }
  209.                     return 0;
  210.                 }
  211.                 format[end] = '\'';
  212.                 stringPos = ch + (end - formatPos);
  213.                 formatPos = end + 1;
  214.             }
  215.             case 'u':
  216.             {
  217.                 new
  218.                     end = stringPos - 1,
  219.                     id = 0,
  220.                     bool:num = true,
  221.                     ch;
  222.                 while ((ch = string[++end]) && ch != delim)
  223.                 {
  224.                     if (num)
  225.                     {
  226.                         if ('0' <= ch <= '9')
  227.                         {
  228.                             id = (id * 10) + (ch - '0');
  229.                         }
  230.                         else
  231.                         {
  232.                             num = false;
  233.                         }
  234.                     }
  235.                 }
  236.                 if (num && IsPlayerConnected(id))
  237.                 {
  238.                     setarg(paramPos, 0, id);
  239.                 }
  240.                 else
  241.                 {
  242.                     #if !defined foreach
  243.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  244.                         #define __SSCANF_FOREACH__
  245.                     #endif
  246.                     string[end] = '\0';
  247.                     num = false;
  248.                     new
  249.                         name[MAX_PLAYER_NAME];
  250.                     id = end - stringPos;
  251.                     foreach (Player, playerid)
  252.                     {
  253.                         GetPlayerName(playerid, name, sizeof (name));
  254.                         if (!strcmp(name, string[stringPos], true, id))
  255.                         {
  256.                             setarg(paramPos, 0, playerid);
  257.                             num = true;
  258.                             break;
  259.                         }
  260.                     }
  261.                     if (!num)
  262.                     {
  263.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  264.                     }
  265.                     string[end] = ch;
  266.                     #if defined __SSCANF_FOREACH__
  267.                         #undef foreach
  268.                         #undef __SSCANF_FOREACH__
  269.                     #endif
  270.                 }
  271.                 stringPos = end;
  272.             }
  273.             case 's', 'z':
  274.             {
  275.                 new
  276.                     i = 0,
  277.                     ch;
  278.                 if (format[formatPos])
  279.                 {
  280.                     while ((ch = string[stringPos++]) && ch != delim)
  281.                     {
  282.                         setarg(paramPos, i++, ch);
  283.                     }
  284.                     if (!i)
  285.                     {
  286.                         return -1;
  287.                     }
  288.                 }
  289.                 else
  290.                 {
  291.                     while ((ch = string[stringPos++]))
  292.                     {
  293.                         setarg(paramPos, i++, ch);
  294.                     }
  295.                 }
  296.                 stringPos--;
  297.                 setarg(paramPos, i, '\0');
  298.             }
  299.             default:
  300.             {
  301.                 continue;
  302.             }
  303.         }
  304.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  305.         {
  306.             stringPos++;
  307.         }
  308.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  309.         {
  310.             stringPos++;
  311.         }
  312.         paramPos++;
  313.     }
  314.     do
  315.     {
  316.         if ((delim = format[formatPos++]) > ' ')
  317.         {
  318.             if (delim == '\'')
  319.             {
  320.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  321.             }
  322.             else if (delim != 'z')
  323.             {
  324.                 return delim;
  325.             }
  326.         }
  327.     }
  328.     while (delim > ' ');
  329.     return 0;
  330. }
  331.  
Advertisement
Add Comment
Please, Sign In to add comment