Advertisement
Guest User

iAdmin and iRegister system by iPrivate

a guest
Dec 16th, 2013
611
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 20.93 KB | None | 0 0
  1.  
  2. /* ______________________________________________
  3.  
  4. You might edit this filterscript to your fits,
  5. but please do not remove credits, since there
  6. are not any credits appearing in-game, which
  7. is better to call this this filterscript yours.
  8. I don't care if you call this yours or not, I just want that my name is kept
  9. in here because my hard work counts a lot for me.
  10.  
  11. ________________________________________________*/
  12.  
  13. //Credits to Y_Less, Dracoblue and Kush. for most of includes
  14.  
  15. #include <a_samp>
  16. #include <YSI\y_ini>
  17. #include <zcmd>
  18. #include <sscanf2>
  19. #include <foreach>
  20.  
  21. // ------ Dialogs ----- //
  22.  
  23. #define DIALOG_REGISTER 1
  24. #define DIALOG_LOGIN 2
  25.  
  26. // ------- Accounts ------//
  27.  
  28. #define PATH "/Users/%s.ini"
  29.  
  30. // ------- Colors ------ //
  31.  
  32. #define COL_WHITE "{FFFFFF}"
  33. #define COL_RED "{F81414}"
  34. #define COL_GREEN "{00FF22}"
  35. #define COL_LIGHTBLUE "{00CED1}"
  36. #define COLOR_GREY 0xADADADFF
  37. #define COLOR_RED 0xFF3D3DFF
  38. #define COLOR_LIGHTRED 0xFF6347FF
  39. #define COLOR_PURPLE 0xFF2E6DFF
  40.  
  41.  
  42. enum pInfo
  43. {
  44.     pPass,
  45.     pCash,
  46.     pAdmin
  47. }
  48.  
  49. new PlayerInfo[MAX_PLAYERS][pInfo];
  50.  
  51. forward LoadUser_data(playerid,name[],value[]);
  52. public LoadUser_data(playerid,name[],value[])
  53. {
  54.     INI_Int("Password",PlayerInfo[playerid][pPass]);
  55.     INI_Int("Cash",PlayerInfo[playerid][pCash]);
  56.     INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  57.     return 1;
  58. }
  59.  
  60. stock UserPath(playerid)
  61. {
  62.     new string[128],playername[MAX_PLAYER_NAME];
  63.     GetPlayerName(playerid,playername,sizeof(playername));
  64.     format(string,sizeof(string),PATH,playername);
  65.     return string;
  66. }
  67.  
  68. /*Credits to Dracoblue*/
  69. stock udb_hash(buf[]) {
  70.     new length=strlen(buf);
  71.     new s1 = 1;
  72.     new s2 = 0;
  73.     new n;
  74.     for (n=0; n<length; n++)
  75.     {
  76.        s1 = (s1 + buf[n]) % 65521;
  77.        s2 = (s2 + s1)     % 65521;
  78.     }
  79.     return (s2 << 16) + s1;
  80. }
  81.  
  82. main()
  83. {
  84.     print("\n----------------------------------");
  85.     print(" Admin system by iPrivate");
  86.     print("----------------------------------\n");
  87. }
  88.  
  89. public OnFilterScriptInit()
  90. {
  91.     return 1;
  92. }
  93.  
  94. public OnPlayerConnect(playerid)
  95. {
  96.     new name[MAX_PLAYER_NAME+1];
  97.     GetPlayerName(playerid, name, sizeof(name));
  98.  
  99.     SetPlayerCameraPos(playerid, 1061.1375, -1348.5317, 72.5953);
  100.     SetPlayerCameraLookAt(playerid, 1062.0928, -1348.8217, 72.5754);
  101.  
  102.     if(fexist(UserPath(playerid)))
  103.     {
  104.         INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  105.         ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Authentication","{FFFFFF}Welcome to {FF0000}Basic Roleplay\n{FFFFFF}Please type your password to login.","Login","Quit");
  106.     }
  107.     else
  108.     {
  109.         ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Authentication","{FFFFFF}Welcome to {FF0000}Basic Roleplay\n{FFFFFF}Please type your password to register.","Register","Quit");
  110.     }
  111.     return 1;
  112. }
  113.  
  114. public OnPlayerDisconnect(playerid, reason)
  115. {
  116.     new INI:File = INI_Open(UserPath(playerid));
  117.     INI_SetTag(File,"data");
  118.     INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  119.     INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  120.     INI_Close(File);
  121.     return 1;
  122. }
  123.  
  124. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  125. {
  126.     switch( dialogid )
  127.     {
  128.         case DIALOG_REGISTER:
  129.         {
  130.             if (!response) return Kick(playerid);
  131.             if(response)
  132.             {
  133.                 if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
  134.                 new INI:File = INI_Open(UserPath(playerid));
  135.                 INI_SetTag(File,"data");
  136.                 INI_WriteInt(File,"Password",udb_hash(inputtext));
  137.                 INI_WriteInt(File,"Cash",0);
  138.                 INI_WriteInt(File,"Admin",0);
  139.                 INI_Close(File);
  140.             }
  141.         }
  142.         case DIALOG_LOGIN:
  143.         {
  144.             if ( !response ) return Kick ( playerid );
  145.             if( response )
  146.             {
  147.                 if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
  148.                 {
  149.                     INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  150.                 }
  151.                 else
  152.                 {
  153.                     Kick(playerid);
  154.                 }
  155.                 return 1;
  156.             }
  157.         }
  158.     }
  159.     return 1;
  160. }
  161.  
  162. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  163. {
  164.     if(PlayerInfo[clickedplayerid][pAdmin] > 0)
  165.     {
  166.         new string[128];
  167.         format(string, sizeof(string), "{FFFFFF}This player is an level {FF0000}%d{FFFFFF} admin.", PlayerInfo[clickedplayerid][pAdmin]);
  168.         SendClientMessage(playerid, COLOR_RED, string);
  169.     }
  170.     return 1;
  171. }
  172.  
  173.  
  174. // ____________________ ADMIN COMMANDS _________________ //
  175.  
  176. COMMAND:skin(playerid, params[], help)
  177. {
  178.     new id;
  179.     if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, COLOR_RED, "[SREVER]You must be admin to use this commands");
  180.     if(sscanf(params,"i",id)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]{FFFFFF}Command: /skin id");
  181.     if(id<0 || id>299) return SendClientMessage(playerid, COLOR_RED, "[SERVER]{FFFFFF}Please use IDs from 0 to 299");
  182.     SetPlayerSkin(playerid,id);
  183.     new msg[50];
  184.     format(msg,sizeof(msg),"[SERVER]{FFFFFF}Your skin has been set to ID %d",id);
  185.     return SendClientMessage(playerid,COLOR_RED,msg);
  186. }
  187.  
  188. COMMAND:acmds(playerid, params[])
  189. {
  190.     if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
  191.     else if(PlayerInfo[playerid][pAdmin] == 1) return SendClientMessage(playerid, COLOR_RED, "Level 1: /kick - /armour - /health - /camera - /freeze - /unfreeze - /skin - /slap");
  192.     else if(PlayerInfo[playerid][pAdmin] == 2)
  193.     {
  194.         SendClientMessage(playerid, COLOR_RED, "Level 1: /kick - /armour - /health - /camera - /freeze - /unfreeze - /skin - /slap");
  195.         SendClientMessage(playerid, COLOR_RED, "Level 2: /get - /goto - /ban - /announce - /givecar");
  196.     }
  197.     else if(PlayerInfo[playerid][pAdmin] == 3)
  198.     {
  199.         SendClientMessage(playerid, COLOR_RED, "Level 1: /kick - /armour - /health - /camera - /freeze - /unfreeze - /skin - /slap");
  200.         SendClientMessage(playerid, COLOR_RED, "Level 2: /get - /goto - /ban - /announce - /givecar");
  201.         SendClientMessage(playerid, COLOR_RED, "Level 3: /givegun - /kickall - /resetguns");
  202.     }
  203.     else if(PlayerInfo[playerid][pAdmin] == 4)
  204.     {
  205.         SendClientMessage(playerid, COLOR_RED, "Level 1: /kick - /armour - /health - /camera - /freeze - /unfreeze - /skin - /slap");
  206.         SendClientMessage(playerid, COLOR_RED, "Level 2: /get - /goto - /ban - /announce - /givecar");
  207.         SendClientMessage(playerid, COLOR_RED, "Level 3: /givegun - /kickall - /resetguns");
  208.         SendClientMessage(playerid, COLOR_RED, "Level 4: /setlevel");
  209.     }
  210.     return 1;
  211. }
  212.  
  213. COMMAND:kick(playerid, params[])
  214. {
  215.     new id, reason[128];
  216.     if(id==playerid)SendClientMessage(playerid,COLOR_RED,"Error: You can not kick yourself!");
  217.     else if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_RED, "Usage: /kick [id/part of name][reason]");
  218.     else if(PlayerInfo[playerid][pAdmin] >= 1)
  219.     {
  220.         new Name[MAX_PLAYER_NAME], KickMessage[128];
  221.         new Name2[MAX_PLAYER_NAME];
  222.         GetPlayerName(playerid, Name, sizeof(Name));
  223.         GetPlayerName(id, Name2, sizeof(Name2));
  224.         format(KickMessage, sizeof(KickMessage), "%s(%d) has kicked player %s(%d). Reason: %s", Name, playerid, Name2, id);
  225.         SendClientMessageToAll(COLOR_RED, KickMessage);
  226.         Kick(id);
  227.     }
  228.     else SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
  229.     return 1;
  230. }
  231.  
  232. COMMAND:ban(playerid, params[])
  233. {
  234.     new id, reason[128];
  235.     if(id==playerid)SendClientMessage(playerid,COLOR_RED,"Error: You can not kick yourself!");
  236.     else if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_RED, "Usage: /kick [id/part of name][reason]");
  237.     else if(PlayerInfo[playerid][pAdmin] >= 2)
  238.     {
  239.         new Name[MAX_PLAYER_NAME], KickMessage[128];
  240.         new Name2[MAX_PLAYER_NAME];
  241.         GetPlayerName(playerid, Name, sizeof(Name));
  242.         GetPlayerName(id, Name2, sizeof(Name2));
  243.         format(KickMessage, sizeof(KickMessage), "%s(%d) has banned player %s(%d). Reason: %s", Name, playerid, Name2, id);
  244.         SendClientMessageToAll(COLOR_RED, KickMessage);
  245.         Ban(id);
  246.     }
  247.     else SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
  248.     return 1;
  249. }
  250.  
  251. COMMAND:slap(playerid, params[])
  252. {
  253.     new id, reason[128];
  254.     if(id==playerid)SendClientMessage(playerid,COLOR_RED,"Error: You can not kick yourself!");
  255.     else if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_RED, "Usage: /kick [id/part of name][reason]");
  256.     else if(PlayerInfo[playerid][pAdmin] >= 1)
  257.     {
  258.        new Float: x, Float: y, Float: z;
  259.        new string[256];
  260.        new Name[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
  261.        GetPlayerName(playerid, Name, sizeof(Name));
  262.        GetPlayerName(playerid, Name2, sizeof(Name2));
  263.        GetPlayerPos(id, x, y, z);
  264.        format(string, sizeof(string), "%s(%d) has slapped %s(%d).", Name, playerid, Name2, id);
  265.        SendClientMessageToAll(COLOR_RED, string);
  266.        SetPlayerPos(id, x, y, z+2);
  267.        GameTextForPlayer(id, "~r~SLAPPED!", 3000, 5);
  268.     }
  269.     else SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
  270.     return 1;
  271. }
  272.  
  273. COMMAND:armour(playerid, params[])
  274. {
  275.     new id,reason[128];
  276.     if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_RED, "Usage: /armour [id/part of name]");
  277.     else if(PlayerInfo[playerid][pAdmin] >= 1)
  278.     {
  279.         new Name[MAX_PLAYER_NAME], ArmourMessage[128];
  280.         new Name2[MAX_PLAYER_NAME];
  281.         GetPlayerName(playerid, Name, sizeof(Name));
  282.         GetPlayerName(id, Name2, sizeof(Name2));
  283.         format(ArmourMessage, sizeof(ArmourMessage), "%s(%d) has given player %s(%d) full armour.", Name, playerid, Name2, id);
  284.         SendClientMessageToAll(COLOR_RED, ArmourMessage);
  285.         SetPlayerArmour(id, 100);
  286.     }
  287.     else SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
  288.     return 1;
  289. }
  290.  
  291. COMMAND:health(playerid, params[])
  292. {
  293.     new id,reason[128];
  294.     if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_RED, "Usage: /armour [id/part of name]");
  295.     else if(PlayerInfo[playerid][pAdmin] >= 1)
  296.     {
  297.         new Name[MAX_PLAYER_NAME], HealthMessage[128];
  298.         new Name2[MAX_PLAYER_NAME];
  299.         GetPlayerName(playerid, Name, sizeof(Name));
  300.         GetPlayerName(id, Name2, sizeof(Name2));
  301.         format(HealthMessage, sizeof(HealthMessage), "%s(%d) has given player %s(%d) full health.", Name, playerid, Name2, id);
  302.         SendClientMessageToAll(COLOR_RED, HealthMessage);
  303.         SetPlayerHealth(id, 100);
  304.     }
  305.     else SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
  306.     return 1;
  307. }
  308.  
  309. COMMAND:camera(playerid, params[])
  310. {
  311.     new id,reason[128];
  312.     if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_RED, "Usage: /camera [id/part of name]");
  313.     else if(PlayerInfo[playerid][pAdmin] >= 1)
  314.     {
  315.         new Name[MAX_PLAYER_NAME], Message[128];
  316.         new Name2[MAX_PLAYER_NAME];
  317.         GetPlayerName(playerid, Name, sizeof(Name));
  318.         GetPlayerName(id, Name2, sizeof(Name2));
  319.         format(Message, sizeof(Message), "%s(%d) has given player %s(%d) a camera.", Name, playerid, Name2, id);
  320.         SendClientMessageToAll(COLOR_RED, Message);
  321.         SetPlayerHealth(id, 100);
  322.     }
  323.     else SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
  324.     return 1;
  325. }
  326.  
  327. COMMAND:freeze(playerid, params[])
  328. {
  329.     new id,reason[128];
  330.     if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_RED, "Usage: /freeze [id/part of name]");
  331.     else if(PlayerInfo[playerid][pAdmin] >= 1)
  332.     {
  333.         new Name[MAX_PLAYER_NAME], Message[128];
  334.         new Name2[MAX_PLAYER_NAME];
  335.         GetPlayerName(playerid, Name, sizeof(Name));
  336.         GetPlayerName(id, Name2, sizeof(Name2));
  337.         format(Message, sizeof(Message), "%s(%d) has frozen player %s(%d).", Name, playerid, Name2, id);
  338.         SendClientMessageToAll(COLOR_RED, Message);
  339.         TogglePlayerControllable(id, 0);
  340.     }
  341.     else SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
  342.     return 1;
  343. }
  344.  
  345. COMMAND:unfreeze(playerid, params[])
  346. {
  347.     new id,reason[128];
  348.     if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_RED, "Usage: /unfreeze [id/part of name]");
  349.     else if(PlayerInfo[playerid][pAdmin] >= 1)
  350.     {
  351.         new Name[MAX_PLAYER_NAME], Message[128];
  352.         new Name2[MAX_PLAYER_NAME];
  353.         GetPlayerName(playerid, Name, sizeof(Name));
  354.         GetPlayerName(id, Name2, sizeof(Name2));
  355.         format(Message, sizeof(Message), "%s(%d) has unfrozen player %s(%d).", Name, playerid, Name2, id);
  356.         SendClientMessageToAll(COLOR_RED, Message);
  357.         TogglePlayerControllable(id, 1);
  358.     }
  359.     else SendClientMessage(playerid, COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
  360.     return 1;
  361. }
  362.  
  363. COMMAND:get(playerid,params[])
  364. {
  365.     if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "Error: You have to be admin or you are not high level enoguh in order to use this command!");
  366.     new id;
  367.     new string[128];
  368.     if(sscanf(params,"i",id)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /get [playerid]");
  369.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Player not connected.");
  370.     new Float:x, Float:y, Float:z;
  371.     GetPlayerPos(playerid, x, y, z);
  372.     SetPlayerPos(id ,x,y,z);
  373.     format(string, sizeof(string), "You have been teleported to ID %d", id);
  374.     SendClientMessage(playerid, COLOR_RED, string);
  375.     return 1;
  376. }
  377.  
  378. COMMAND:goto(playerid,params[])
  379. {
  380.     if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "Error: You have to be admin or you are not high level enoguh in order to use this command!");
  381.     new id;
  382.     new string[128];
  383.     if(sscanf(params,"i",id)) return SendClientMessage(playerid, COLOR_RED,"USAGE: /goto [playerid]");
  384.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Player not connected.");
  385.     new Float:x, Float:y, Float:z;
  386.     GetPlayerPos(playerid, x, y, z);
  387.     SetPlayerPos(playerid,x,y,z);
  388.     format(string, sizeof(string), "You have been teleported to ID %d", id);
  389.     SendClientMessage(playerid, COLOR_RED, string);
  390.     return 1;
  391. }
  392.  
  393. COMMAND:setlevel(playerid,params[])
  394. {
  395.     if(PlayerInfo[playerid][pAdmin] < 4 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
  396.     new id,level, name[MAX_PLAYER_NAME+4], string[148];
  397.     GetPlayerName(id, name, sizeof(name));
  398.     if(sscanf(params,"ii",id,level)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /setlevel [playerid] [level 0-5]");
  399.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Player not connected.");
  400.     if(level > 5) return SendClientMessage(playerid,COLOR_RED,"Error! You can only pick between level 0/5 (0: Player - 1: Moderator - 2: Administrator - 3: Global Moderator - 4: Server Scripter - 5: Owner)");
  401.     if(PlayerInfo[id][pAdmin] < level)
  402.     {
  403.         PlayerInfo[id][pAdmin] = level;
  404.         format(string, sizeof(string), "You have been promoted to %d level succesfully.", level);
  405.         SendClientMessage(id, COLOR_RED, string);
  406.         format(string, sizeof(string), "You have promoted %s succesfully to level %d.", name, level);
  407.         SendClientMessage(playerid, COLOR_RED, string);
  408.     }
  409.     else
  410.     {
  411.         PlayerInfo[id][pAdmin] = level;
  412.         format(string, sizeof(string), "You have been demoted to %d level.", level);
  413.         SendClientMessage(id, COLOR_RED, string);
  414.         format(string, sizeof(string), "You have demoted %s succesfully to level %d.", name, level);
  415.         SendClientMessage(playerid, COLOR_RED, string);
  416.     }
  417.     return 1;
  418. }
  419.  
  420. COMMAND:givegun(playerid,params[])
  421. {
  422.     if(PlayerInfo[playerid][pAdmin] < 3 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"Error: You have to be admin or you are not high level enoguh in order to use this command!");
  423.     new id,weapon, name[MAX_PLAYER_NAME+4], string[148];
  424.     GetPlayerName(id, name, sizeof(name));
  425.     if(sscanf(params,"ii",id,weapon)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /givegun [playerid] [weaponid 1-45]");
  426.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Player not connected.");
  427.     if(weapon > 45 && weapon < 1) return SendClientMessage(playerid,COLOR_RED,"Error! You may only choose weapons between 1 and 45.");
  428.     if(PlayerInfo[id][pAdmin] < weapon)
  429.     {
  430.         GivePlayerWeapon(id, weapon, 50000);
  431.         format(string, sizeof(string), "You have been given weapon with ID %d succesfully by administrator %s", weapon, name);
  432.         SendClientMessage(id, COLOR_RED, string);
  433.     }
  434.     return 1;
  435. }
  436.  
  437. COMMAND:resetguns(playerid,params[])
  438. {
  439.     if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_RED, "Error: You have to be admin or you are not high level enoguh in order to use this command!");
  440.     new id;
  441.     new string[128];
  442.     if(sscanf(params,"i",id)) return SendClientMessage(playerid, COLOR_RED,"USAGE: /resetguns [playerid]");
  443.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"Player not connected.");
  444.     new Float:x, Float:y, Float:z;
  445.     GetPlayerPos(playerid, x, y, z);
  446.     SetPlayerPos(playerid,x,y,z);
  447.     format(string, sizeof(string), "You have been reseted guns for ID %d", id);
  448.     ResetPlayerWeapons(id);
  449.     return 1;
  450. }
  451.  
  452. CMD:givecar(playerid, params[])
  453. {
  454.      new id, car, string[128];
  455.      if(sscanf(params, "ud", id, car)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /givecar [playerid] [vehicleid]");
  456.      if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "Error: You must be at least admin level 2 to use this command");
  457.      if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "Error: That user ain't connected");
  458.  
  459.      new Float: x, Float: y, Float: z, Float: a;
  460.      new name[MAX_PLAYER_NAME], names[MAX_PLAYER_NAME];
  461.      GetPlayerName(playerid, name, sizeof(name));
  462.      GetPlayerName(id, names, sizeof(names));
  463.      GetPlayerPos(id, x, y, z);
  464.      GetPlayerFacingAngle(id, a);
  465.      new rd1 = random(20);
  466.      new rd2 = random(20);
  467.      format(string, sizeof(string), "You have given %s(%d) vehicle with ID %d", names, id, car);
  468.      SendClientMessage(playerid, COLOR_RED, string);
  469.      format(string, sizeof(string), "%s(%d) has given you vehicle with ID %d", name, playerid, car);
  470.      SendClientMessage(id, COLOR_RED, string);
  471.      new veh = CreateVehicle(car, x, y, z, a, rd1, rd2, -1);
  472.      PutPlayerInVehicle(id, veh, 0);
  473.      return 1;
  474. }
  475.  
  476. CMD:kickall(playerid, params[])
  477. {
  478.      if(PlayerInfo[playerid][pAdmin] >= 3)
  479.      {
  480.          new string[128], name[MAX_PLAYER_NAME];
  481.          GetPlayerName(playerid, name, sizeof(name));
  482.          format(string, sizeof(string), "%s(%d) has kicked all players on the server.", name, playerid);
  483.          SendClientMessageToAll(COLOR_RED, string);
  484.          foreach(Player, i)
  485.          {
  486.              if(IsPlayerConnected(i) && PlayerInfo[i][pAdmin] == 0)
  487.              {
  488.                  Kick(i);
  489.              }
  490.          }
  491.      }
  492.      return 1;
  493. }
  494.  
  495. CMD:announce(playerid, params[])
  496. {
  497.     new text[64], time, style, string[128];
  498.     if(sscanf(params, "s[64]dd", text, time, style)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /ann [text] [time(ms)] [style(0-5)]");
  499.  
  500.     if(strlen(text) < 0) return SendClientMessage(playerid, COLOR_RED, "Error: You didn't enter text.");
  501.     if(!time) return SendClientMessage(playerid, COLOR_RED, "Error: You didn't add lasting time.");
  502.     if(!style) return SendClientMessage(playerid, COLOR_RED, "Error: You didn't enter style.");
  503.     if(PlayerInfo[playerid][pAdmin] < 3)
  504.     {
  505.         format(string, sizeof(string), "%s", text);
  506.         foreach(Player, i)
  507.         {
  508.             if(IsPlayerConnected(i))
  509.             {
  510.                 GameTextForPlayer(i, string, time, style);
  511.             }
  512.         }
  513.     }
  514.     else  SendClientMessage(playerid, COLOR_RED, "Error: You are not an admin or your level is not high enough to use this command.");
  515.     return 1;
  516. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement