Advertisement
Guest User

bla

a guest
Jul 13th, 2012
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.50 KB | None | 0 0
  1.  
  2. #define FILTERSCRIPT
  3.  
  4. #include <a_samp>
  5. #include <dini>
  6. #include <gTeam>
  7. #include <pInfo>
  8.  
  9.  
  10. #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
  11.  
  12. #define GREY 0xAFAFAFAA
  13. #define GREEN 0x33AA33AA
  14. #define YELLOW 0xFFFF00AA
  15. #define WHITE 0xFFFFFFAA
  16. #define LIGHTBLUE 0x33CCFFAA
  17. #define ORANGE 0xFF9900AA
  18.  
  19. enum PInfo
  20. {
  21.     Logged,
  22.     Regged,
  23.     Level
  24. }
  25.  
  26.  
  27. #if defined FILTERSCRIPT
  28.  
  29. //TEAMS ------------------------------------------------------------------------
  30. #define TEAM_ADMIN 1
  31. #define TEAM_DRIFTER 2
  32. //TEAM COLOUR-------------------------------------------------------------------
  33. #define TEAM_ADMIN_COLOUR 0xFFFFFFAA
  34. #define TEAM_DRIFTER_COLOUR 0x0000BBAA
  35. //DEFINES A VARIABLE TO STORE THE TEAMS DATA------------------------------------
  36.  
  37.  
  38. public OnFilterScriptInit()
  39. {
  40.     print("\n--------------------------------------");
  41.     print("    Admin Script ");
  42.     print("--------------------------------------\n");
  43.     return 1;
  44. }
  45.  
  46. public OnFilterScriptExit()
  47. {
  48.     return 1;
  49. }
  50.  
  51. #else
  52.  
  53. main()
  54. {
  55.     print("\n----------------------------------");
  56.     print(" Class Script ");
  57.     print("----------------------------------\n");
  58. }
  59.  
  60. #endif
  61.  
  62. public OnGameModeInit()
  63. {
  64.    
  65.     SetGameModeText("Blank Script");
  66.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  67.     AddPlayerClass(282,1607.0870,1815.6981,10.8203,193.8336,0,0,0,0,0,0);
  68.     return 1;
  69. }
  70.  
  71.  
  72. public OnPlayerConnect(playerid)
  73. {
  74.    
  75.     PInfo[playerid][Regged] = 0;
  76.     PInfo[playerid][Level] = 0;
  77.     new n[MAX_PLAYER_NAME], file[256];
  78.     GetPlayerName(playerid,n,sizeof(n));
  79.     format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
  80.     if(dini_Exists(file))
  81.     {
  82.         SendClientMessage(playerid,LIGHTBLUE,"You are registered, Please /login!");
  83.         PInfo[playerid][Regged] = 1;
  84.         PInfo[playerid][Logged] = 0;
  85.         return 1;
  86.     }
  87.     if(!dini_Exists(file))
  88.     {
  89.         SendClientMessage(playerid,LIGHTBLUE,"You are not registered, Please /register!");
  90.         PInfo[playerid][Regged] = 0;
  91.         PInfo[playerid][Logged] = 0;
  92.         return 1;
  93.     }
  94.     return 1;
  95. }
  96.  
  97. public OnPlayerDisconnect(playerid, reason)
  98. {
  99.     new n[MAX_PLAYER_NAME], file[256];
  100.     GetPlayerName(playerid,n,sizeof(n));
  101.     format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
  102.     PInfo[playerid][Logged] = 0;
  103.     dini_IntSet(file,"Logged",0);
  104.     return 1;
  105. }
  106.  
  107. public OnPlayerText(playerid, text[])
  108. {
  109.     return 1;
  110. }
  111.  
  112. public OnPlayerCommandText(playerid, cmdtext[])
  113. {
  114.     new cmd[256], idx;
  115.     cmd = strtok(cmdtext, idx);
  116.     dcmd(register,8,cmdtext);
  117.     dcmd(login,5,cmdtext);
  118.     dcmd(setlevel,8,cmdtext);
  119.     dcmd(kick,4,cmdtext);
  120.     dcmd(ban,3,cmdtext);
  121.     return 0;
  122. }
  123.  
  124. dcmd_register(playerid,params[])
  125. {
  126.     new file[256],n[MAX_PLAYER_NAME];
  127.     GetPlayerName(playerid,n,MAX_PLAYER_NAME);
  128.     format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
  129.     if(dini_Exists(file)) return SendClientMessage(playerid,YELLOW,"You are already registered!");
  130.     if(PInfo[playerid][Regged] == 1) return SendClientMessage(playerid,LIGHTBLUE,"You are already registered!");
  131.     if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,ORANGE,"You are already registered, and logged in!");
  132.     if(strlen(params))
  133.     {
  134.         if(!dini_Exists(file))
  135.         {
  136.             dini_Create(file);
  137.             dini_Set(file,"Password",params);
  138.             dini_IntSet(file,"Regged",1);
  139.             dini_IntSet(file,"Logged",0);
  140.             dini_IntSet(file,"Level",0);
  141.             dini_IntSet(file, "Class", 2);//SETS THE DEFAULT CLASS NUMBER WHEN A PLAYER REGISTERS! 2 = DRIFTER [LINE 30]
  142.             SendClientMessage(playerid,LIGHTBLUE,"Congratulations, you have just registered, please /login");
  143.             PInfo[playerid][Regged] = 1;
  144.             return 1;
  145.         }
  146.     }
  147.     else
  148.     {
  149.         SendClientMessage(playerid,GREY,"USAGE: /register <Password>");
  150.         return 1;
  151.     }
  152.     return 1;
  153. }
  154.  
  155. dcmd_login(playerid,params[])
  156. {
  157.     new file[256],n[MAX_PLAYER_NAME];
  158.     GetPlayerName(playerid,n,MAX_PLAYER_NAME);
  159.     format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
  160.     if(!dini_Exists(file)) return SendClientMessage(playerid,YELLOW,"You are not registered! Please /register");
  161.     if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,LIGHTBLUE,"You are already logged in!");
  162.     if(PInfo[playerid][Regged] == 0) return SendClientMessage(playerid,ORANGE,"You are not registered! Please /register");
  163.     if(strlen(params))
  164.     {
  165.         new pass[256];
  166.         pass = dini_Get(file,"Password");
  167.         if(dini_Exists(file))
  168.         {
  169.             if(strcmp(params,pass,false) != 0)
  170.             {
  171.                 SendClientMessage(playerid,YELLOW,"Wrong Password!");
  172.             }
  173.             else
  174.             {
  175.                 dini_IntSet(file,"Logged",1);
  176.                 PInfo[playerid][Logged] = 1;
  177.                 PInfo[playerid][Level] = dini_Int(file,"Level");
  178.                 SendClientMessage(playerid,YELLOW,"You have now logged in!");
  179.                 return 1;
  180.             }
  181.         }
  182.     }
  183.     else
  184.     {
  185.         SendClientMessage(playerid,GREY,"USAGE: /login <Password>");
  186.         return 1;
  187.     }
  188.     return 1;
  189. }
  190. //admin cmds
  191. dcmd_setlevel(playerid,params[])
  192. {
  193.     new level,id,file[256],n[MAX_PLAYER_NAME];
  194.     new tmp[256], tmp2[256], Index,str[50];
  195.     tmp = strtok(params,Index), tmp2 = strtok(params,Index),id = strval(tmp),level = strval(tmp2);
  196.     GetPlayerName(id,n,MAX_PLAYER_NAME);
  197.     format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
  198.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,GREY,"You are not an RCON admin!");
  199.     if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /setlevel <ID> <Level>");
  200.     if(!IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"You have entered an incorrect ID");
  201.     PInfo[id][Level] = level;
  202.     dini_IntSet(file,"Level",level);
  203.     format(str,sizeof(str),"You have set %s's level to %d",n,level);
  204.     SendClientMessage(playerid,LIGHTBLUE,str);
  205.     return 1;
  206. }
  207. dcmd_kick(playerid,params[])
  208. {
  209.     new id,n[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
  210.     new tmp[256], Index, str[49];
  211.     tmp = strtok(params,Index), id = strval(tmp);
  212.     GetPlayerName(id,on,sizeof(on));
  213.     GetPlayerName(playerid,n,sizeof(n));
  214.     if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,ORANGE,"You need to be level 3 to use this command!");
  215.     if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /kick <ID> ");
  216.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
  217.     format(str,sizeof(str),"%s has kicked %s",n,on);
  218.     SendClientMessageToAll(LIGHTBLUE,str);
  219.     Kick(id);
  220.     return 1;
  221. }
  222. dcmd_ban(playerid,params[])
  223. {
  224.     new id, n[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
  225.     new tmp[256], Index, str[49];
  226.     tmp = strtok(params,Index), id = strval(tmp);
  227.     GetPlayerName(id,on,sizeof(on));
  228.     GetPlayerName(playerid,n,sizeof(n));
  229.     if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,ORANGE,"You need to be level 3 to use this command!");
  230.     if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /ban <ID> ");
  231.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
  232.     format(str,sizeof(str),"%s has banned %s",n,on);
  233.     SendClientMessageToAll(ORANGE,str);
  234.     Ban(id);
  235.     return 1;
  236. }
  237.  
  238.  
  239. dcmd_gethere(playerid,params[])
  240. (
  241.     new targetid, Float:x, Float:y, Float:z;
  242.     if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR, "USAGE: /gethere [id]");
  243.     if(!IsPlayerConnected(id) || id == playerid) return SendClientMessage(playerid, 0xFF0000FF, "This player is offline or it is yourself");
  244.     GetPlayerPos(playerid, x, y, z);
  245.     SetPlayerPos(targetid, x+1, y+1, z);
  246.     return 1;
  247. }
  248.  
  249. dcmd_goto(playerid,params[])
  250. (
  251.    new ID;
  252.     if(sscanf(params, "u", ID)) SendClientMessage(playerid, 0xFF0000FF, "USAGE: /goto [id]");
  253.     else if(!IsPlayerConnected(id) || id == playerid) return SendClientMessage(playerid, 0xFF0000FF, "This player is offline or it is yourself");
  254.     else
  255.     {
  256.     new Float:x, Float:y, Float:z;
  257.     GetPlayerPos(ID, x, y, z);
  258.     SetPlayerPos(playerid, x+1, y+1, z);
  259.     return 1;
  260. }
  261.  
  262. dcmd_stats(playerid,params[])
  263. {
  264.     new string[128];
  265.     new pDeaths;
  266.     new player1, h, m, s;
  267.  
  268.     if(!strlen(params)) player1 = playerid;
  269.     else player1 = strval(params);
  270.  
  271.     if(IsPlayerConnected(player1))
  272.     {
  273.     TotalGameTime(player1, h, m, s);
  274.     if(AccInfo[player1][Deaths] == 0) pDeaths = 1;
  275.     else pDeaths = AccInfo[player1][Deaths];
  276.     format(string, sizeof(string), "|- %s's Statistics -|",PlayerName2(player1));
  277.     SendClientMessage(playerid, green, string);
  278.     format(string, sizeof(string), "Kills: [%d] | Deaths: [%d] | Ratio: [%0.2f] | Money: [$%d] | Time: [%d] hrs [%d] mins [%d] secs |", AccInfo[player1][Kills], AccInfo[player1][Deaths], Float:AccInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1), h, m, s);
  279.     return SendClientMessage(playerid, green, string);
  280.     } else
  281.     return SendClientMessage(playerid, red, "ERROR: Player Not Connected!");
  282. }
  283. #endif
  284.  
  285.  
  286.  
  287. strtok(const string[], &index)
  288. {
  289.     new length = strlen(string);
  290.     while ((index < length) && (string[index] <= ' '))
  291.     {
  292.         index++;
  293.     }
  294.     new offset = index;
  295.     new result[20];
  296.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  297.     {
  298.         result[index - offset] = string[index];
  299.         index++;
  300.     }
  301.     result[index - offset] = EOS;
  302.     return result;
  303. }
  304.  
  305. public OnPlayerSpawn (playerid)
  306. {
  307.     if(gTeam[playerid] == TEAM_DRIFTER)
  308.     {
  309.     SetPlayerInterior(playerid, 0);
  310.     SetPlayerPos(playerid, -2537.0408, -611.9086, 132.5625);
  311.     return 1;
  312.     }
  313.     else if(gTeam[playerid] == TEAM_ADMIN)
  314.     {
  315.     SetPlayerInterior(playerid, 0);
  316.     SetPlayerPos(playerid, -1590.0541,715.7346,-5.2422);
  317.     return 1;
  318. }
  319.  
  320.  
  321.  
  322. ///////STOCK BY STUOYTO, DO NOT REMOVE OR CLASSES WONT HAVE DESIGNATED COLOURS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement