Guest User

freeRoam by Jack Robinson

a guest
Aug 31st, 2012
540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 25.50 KB | None | 0 0
  1. /* freeRoam BETA coded by Jack Robinson. */
  2.  
  3.  
  4. #include <a_samp>
  5. #include <dini>
  6. #include <sscanf2>
  7. #include <zcmd>
  8.  
  9. #define webURL      "www.sa-mp.com"
  10. #define gameMode    "freeRoam"
  11.  
  12. #define messageOfTheDay     "Thanks for trying the server out!\nAdd us to your favourites if you enjoyed our script."
  13.  
  14. #define killsForKillstreak  (3)
  15.  
  16. #define playerFileLoc       "Accounts/%s.ini"
  17.  
  18. // If you wish to change the sa-mp map name, please check under OnGameModeInit.
  19. #define mapName     "freeRoam Map"
  20. #define gmName      "freeRoam GM"
  21.  
  22. // Colours
  23. #define colourWhite         0xFFFFFFFF
  24. #define colourGrey          0x666666FF
  25.  
  26. #define colourBlue          0x0000FFFF
  27. #define colourLightBlue     0x0099FFFF
  28.  
  29. #define colourRed           0xCC0000FF
  30. #define colourLightRed      0xFF0000FF
  31.  
  32. #define colourGreen         0x009900FF
  33. #define colourLightGreen    0x00FF00FF
  34.  
  35. #define colourOrange        0xFF6600FF
  36. #define colourYellow        0xFFFF00FF
  37.  
  38. // Enumerations
  39. enum playerStuff
  40. {
  41.     playerPass[256],
  42.     playerFailedLoginAttempts,
  43.  
  44.     playerBanned,
  45.    
  46.     playerKills,
  47.     playerDeaths,
  48.     playerScore,
  49.    
  50.     playerAdmin,
  51.    
  52.     playerPolice,
  53.     playerCuffed,
  54.     playerTazed,
  55.    
  56.    
  57.     playerWeaponSlot[13],
  58. };
  59.  
  60.  
  61. new playerInfo[MAX_PLAYERS][playerStuff];
  62.  
  63. new playerFile[256];
  64.  
  65. new globalAntiHack;
  66.  
  67.  
  68. stock getName(playerid)
  69. {
  70.     new Name[MAX_PLAYER_NAME];
  71.  
  72.  
  73.     if(IsPlayerConnected(playerid))
  74.     {
  75.         GetPlayerName(playerid, Name, sizeof(Name));
  76.     }
  77.     else
  78.     {
  79.         Name = "(null)";
  80.     }
  81.     return Name;
  82. }
  83.  
  84. stock initAndSpawn(playerid)
  85. {
  86.     ResetPlayerMoney(playerid);
  87.     GivePlayerMoney(playerid, 5000);
  88.     new randSpawn = random(6);
  89.     switch(randSpawn)
  90.     {
  91.         case 0:
  92.         {
  93.             SetSpawnInfo(playerid, 0, random(299), 1295.8590,-1424.8643,14.9531, 0, 0, 0, 0, 0, 0, 0);
  94.         }
  95.         case 1:
  96.         {
  97.             SetSpawnInfo(playerid, 0, random(299), 1545.5078,-1675.5112,13.5605, 0, 0, 0, 0, 0, 0, 0);
  98.         }
  99.         case 2:
  100.         {
  101.             SetSpawnInfo(playerid, 0, random(299), 1742.7448,-1864.3312,13.5740, 0, 0, 0, 0, 0, 0, 0);
  102.         }
  103.         case 3:
  104.         {
  105.             SetSpawnInfo(playerid, 0, random(299), 2495.1143,-1688.6969,13.9679, 0, 0, 0, 0, 0, 0, 0);
  106.         }
  107.         case 4:
  108.         {
  109.             SetSpawnInfo(playerid, 0, random(299), 2421.4343,-1224.3558,25.2236, 0, 0, 0, 0, 0, 0, 0);
  110.         }
  111.         case 5:
  112.         {
  113.             SetSpawnInfo(playerid, 0, random(299), 1459.2562,-1010.4940,26.8438, 0, 0, 0, 0, 0, 0, 0);
  114.         }
  115.         case 6:
  116.         {
  117.             SetSpawnInfo(playerid, 0, random(299), 825.0764,-1102.8118,25.7891, 0, 0, 0, 0, 0, 0, 0);
  118.         }
  119.  
  120.     }
  121.     SpawnPlayer(playerid);
  122. }
  123.  
  124.  
  125. stock loadPlayer(playerid)
  126. {
  127.     format(playerFile, 256, playerFileLoc, getName(playerid));
  128.     if(!fexist(playerFile))
  129.     {
  130.         dini_Create(playerFile);
  131.         printf(""playerFileLoc" has been created.", getName(playerid));
  132.        
  133.         dini_Set(playerFile, "playerPass", "None");
  134.        
  135.         dini_IntSet(playerFile, "playerBanned", 0);
  136.        
  137.         dini_IntSet(playerFile, "playerKills", 0);
  138.         dini_IntSet(playerFile, "playerScore", 0);
  139.         dini_IntSet(playerFile, "playerDeaths", 0);
  140.        
  141.         dini_IntSet(playerFile, "playerAdmin", 0);
  142.  
  143.         dini_IntSet(playerFile, "playerWeaponSlot", 0);
  144.         dini_IntSet(playerFile, "playerWeaponSlot1", 0);
  145.         dini_IntSet(playerFile, "playerWeaponSlot2", 0);
  146.         dini_IntSet(playerFile, "playerWeaponSlot3", 0);
  147.         dini_IntSet(playerFile, "playerWeaponSlot4", 0);
  148.         dini_IntSet(playerFile, "playerWeaponSlot5", 0);
  149.         dini_IntSet(playerFile, "playerWeaponSlot6", 0);
  150.         dini_IntSet(playerFile, "playerWeaponSlot7", 0);
  151.         dini_IntSet(playerFile, "playerWeaponSlot8", 0);
  152.         dini_IntSet(playerFile, "playerWeaponSlot9", 0);
  153.         dini_IntSet(playerFile, "playerWeaponSlot10", 0);
  154.         dini_IntSet(playerFile, "playerWeaponSlot11", 0);
  155.         dini_IntSet(playerFile, "playerWeaponSlot12", 0);
  156.  
  157.         dini_IntSet(playerFile, "playerPolice", 0);
  158.  
  159.         ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Registeration", "Welcome to the server!\nPlease enter your desired password!", "Register", "");
  160.  
  161.     }
  162.     else
  163.     {
  164.         format(playerInfo[playerid][playerPass], 256, dini_Get(playerFile, "playerPass"));
  165.        
  166.         playerInfo[playerid][playerBanned] = dini_Int(playerFile, "playerBanned");
  167.         playerInfo[playerid][playerKills] = dini_Int(playerFile, "playerKills");
  168.         playerInfo[playerid][playerScore] = dini_Int(playerFile, "playerScore");
  169.         playerInfo[playerid][playerDeaths] = dini_Int(playerFile, "playerDeaths");
  170.        
  171.         playerInfo[playerid][playerAdmin] = dini_Int(playerFile, "playerAdmin");
  172.        
  173.         playerInfo[playerid][playerPolice] = dini_Int(playerFile, "playerPolice");
  174.        
  175.         playerInfo[playerid][playerWeaponSlot][0] = dini_Int(playerFile, "playerWeaponSlot");
  176.         playerInfo[playerid][playerWeaponSlot][1] = dini_Int(playerFile, "playerWeaponSlot1");
  177.         playerInfo[playerid][playerWeaponSlot][2] = dini_Int(playerFile, "playerWeaponSlot2");
  178.         playerInfo[playerid][playerWeaponSlot][3] = dini_Int(playerFile, "playerWeaponSlot3");
  179.         playerInfo[playerid][playerWeaponSlot][4] = dini_Int(playerFile, "playerWeaponSlot4");
  180.         playerInfo[playerid][playerWeaponSlot][5] = dini_Int(playerFile, "playerWeaponSlot5");
  181.         playerInfo[playerid][playerWeaponSlot][6] = dini_Int(playerFile, "playerWeaponSlot6");
  182.         playerInfo[playerid][playerWeaponSlot][7] = dini_Int(playerFile, "playerWeaponSlot7");
  183.         playerInfo[playerid][playerWeaponSlot][8] = dini_Int(playerFile, "playerWeaponSlot8");
  184.         playerInfo[playerid][playerWeaponSlot][9] = dini_Int(playerFile, "playerWeaponSlot9");
  185.         playerInfo[playerid][playerWeaponSlot][10] = dini_Int(playerFile, "playerWeaponSlot10");
  186.         playerInfo[playerid][playerWeaponSlot][11] = dini_Int(playerFile, "playerWeaponSlot11");
  187.         playerInfo[playerid][playerWeaponSlot][12] = dini_Int(playerFile, "playerWeaponSlot12");
  188.        
  189.         if(playerInfo[playerid][playerBanned] == 0)
  190.         {
  191.             ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "Welcome back to the server!\nPlease enter your password", "Login", "");
  192.         }
  193.         else
  194.         {
  195.             new String[256];
  196.             format(String, sizeof(String), "You are banned from this server. Please contact an administrator  at %s to appeal your ban.", getName(playerid));
  197.             SendClientMessage(playerid, colourRed, String);
  198.             Kick(playerid);
  199.         }
  200.     }
  201. }
  202.  
  203. stock givePlayerValidWeapon(playerid, weaponid)
  204. {
  205.     if(IsPlayerConnected(playerid))
  206.     {
  207.         switch(weaponid)
  208.         {
  209.             case 0, 1:
  210.             {
  211.                 playerInfo[playerid][playerWeaponSlot][0] = weaponid;
  212.                 GivePlayerWeapon(playerid, weaponid, 1);
  213.             }
  214.             case 2, 3, 4, 5, 6, 7, 8, 9:
  215.             {
  216.                 playerInfo[playerid][playerWeaponSlot][1] = weaponid;
  217.                 GivePlayerWeapon(playerid, weaponid, 1);
  218.             }
  219.             case 22, 23, 24:
  220.             {
  221.                 playerInfo[playerid][playerWeaponSlot][2] = weaponid;
  222.                 GivePlayerWeapon(playerid, weaponid, 100);
  223.             }
  224.             case 25, 26, 27:
  225.             {
  226.                 playerInfo[playerid][playerWeaponSlot][3] = weaponid;
  227.                 GivePlayerWeapon(playerid, weaponid, 52);
  228.             }
  229.             case 28, 29, 32:
  230.             {
  231.                 playerInfo[playerid][playerWeaponSlot][4] = weaponid;
  232.                 GivePlayerWeapon(playerid, weaponid, 50);
  233.             }
  234.             case 30, 31:
  235.             {
  236.                 playerInfo[playerid][playerWeaponSlot][5] = weaponid;
  237.                 GivePlayerWeapon(playerid, weaponid, 50);
  238.  
  239.             }
  240.             case 33, 34:
  241.             {
  242.                 playerInfo[playerid][playerWeaponSlot][6] = weaponid;
  243.                 GivePlayerWeapon(playerid, weaponid, 50);
  244.             }
  245.             case 35, 36, 37, 38:
  246.             {
  247.                 playerInfo[playerid][playerWeaponSlot][7] = weaponid;
  248.                 GivePlayerWeapon(playerid, weaponid, 50);
  249.             }
  250.             case 39:
  251.             {
  252.                 playerInfo[playerid][playerWeaponSlot][8] = weaponid;
  253.                 GivePlayerWeapon(playerid, weaponid, 50);
  254.             }
  255.             case 41, 42, 43:
  256.             {
  257.                 playerInfo[playerid][playerWeaponSlot][9] = weaponid;
  258.                 GivePlayerWeapon(playerid, weaponid, 50);
  259.             }
  260.             case 11, 12, 13, 14, 15:
  261.             {
  262.                 playerInfo[playerid][playerWeaponSlot][10] = weaponid;
  263.                 GivePlayerWeapon(playerid, weaponid, 50);
  264.             }
  265.             case 44, 45:
  266.             {
  267.                 playerInfo[playerid][playerWeaponSlot][11] = weaponid;
  268.                 GivePlayerWeapon(playerid, weaponid, 50);
  269.             }
  270.             case 40:
  271.             {
  272.                 playerInfo[playerid][playerWeaponSlot][12] = weaponid;
  273.                 GivePlayerWeapon(playerid, weaponid, 50);
  274.             }
  275.         }
  276.     }
  277.  
  278. }
  279.  
  280.  
  281. stock sendAutoBan(playerid, string[])
  282. {
  283.     new Message[256];
  284.     if(globalAntiHack == 1)
  285.     {
  286.         format(Message, 256, "Anti-Ban: %s has been auto banned for hacking. (%s)", getName(playerid), string);
  287.         SendClientMessageToAll(colourRed, Message);
  288.  
  289.         format(playerFile, 256, playerFileLoc, getName(playerid));
  290.         dini_IntSet(playerFile, "Banned", 1);
  291.         playerInfo[playerid][playerBanned] = 1;
  292.         print(Message);
  293.         Kick(playerid);
  294.     }
  295.     else printf("Anti-Ban: %s has been caught hacking (%s) but has not been banned, due to the anti-hack being disabled.", getName(playerid), string);
  296. }
  297.  
  298. stock enableAntiHack()
  299. {
  300.     if(globalAntiHack == 0)
  301.         globalAntiHack = 1;
  302.     else return print("The antihack is already enabled.");
  303.  
  304.     return 1;
  305. }
  306.  
  307. stock disableAntiHack()
  308. {
  309.     if(globalAntiHack == 1)
  310.         globalAntiHack = 0;
  311.     else return print("The antihack is already disabled.");
  312.  
  313.     return 1;
  314. }
  315. // Global Variables
  316. main()
  317. {
  318. }
  319.  
  320. forward OneSecond();
  321. public OneSecond()
  322. {
  323.     for(new i = 0; i < MAX_PLAYERS; i++)
  324.     {
  325.         if(gettime() >= GetPVarInt(i, "Tazed") && GetPVarInt(i, "Tazed") > 1)
  326.         {
  327.             TogglePlayerControllable(i, true);
  328.             SendClientMessage(i, colourYellow, "The taze effect on you has worn off.");
  329.             DeletePVar(i, "Tazed");
  330.             playerInfo[i][playerTazed] = 0;
  331.         }
  332.         new Weapon = GetPlayerWeapon(i);
  333.         switch(Weapon)
  334.         {
  335.             case 0, 1:
  336.             {
  337.                 if(playerInfo[i][playerWeaponSlot][0] != Weapon)
  338.                 {
  339.                     sendAutoBan(i, "Weapon Hacking");
  340.                 }
  341.             }
  342.             case 2, 3, 4, 5, 6, 7, 8, 9:
  343.             {
  344.                 if(playerInfo[i][playerWeaponSlot][1] != Weapon)
  345.                 {
  346.                     sendAutoBan(i, "Weapon Hacking");
  347.                 }
  348.             }
  349.             case 22, 23, 24:
  350.             {
  351.                 if(playerInfo[i][playerWeaponSlot][2] != Weapon)
  352.                 {
  353.                     sendAutoBan(i, "Weapon Hacking");
  354.                 }
  355.             }
  356.             case 25, 26, 27:
  357.             {
  358.                 if(playerInfo[i][playerWeaponSlot][3] != Weapon)
  359.                 {
  360.                     sendAutoBan(i, "Weapon Hacking");
  361.                 }
  362.             }
  363.             case 28, 29, 32:
  364.             {
  365.                 if(playerInfo[i][playerWeaponSlot][4] != Weapon)
  366.                 {
  367.                     sendAutoBan(i, "Weapon Hacking");
  368.                 }
  369.             }
  370.             case 30, 31:
  371.             {
  372.                 if(playerInfo[i][playerWeaponSlot][5] != Weapon)
  373.                 {
  374.                     sendAutoBan(i, "Weapon Hacking");
  375.                 }
  376.             }
  377.             case 33, 34:
  378.             {
  379.                 if(playerInfo[i][playerWeaponSlot][6] != Weapon)
  380.                 {
  381.                     sendAutoBan(i, "Weapon Hacking");
  382.                 }
  383.             }
  384.             case 35, 36, 37, 38:
  385.             {
  386.                 if(playerInfo[i][playerWeaponSlot][7] != Weapon)
  387.                 {
  388.                     sendAutoBan(i, "Weapon Hacking");
  389.                 }
  390.             }
  391.             case 39:
  392.             {
  393.                 if(playerInfo[i][playerWeaponSlot][8] != Weapon)
  394.                 {
  395.                     sendAutoBan(i, "Weapon Hacking");
  396.                 }
  397.             }
  398.             case 41, 42, 43:
  399.             {
  400.                 if(playerInfo[i][playerWeaponSlot][9] != Weapon)
  401.                 {
  402.                     sendAutoBan(i, "Weapon Hacking");
  403.                 }
  404.             }
  405.             case 11, 12, 13, 14, 15:
  406.             {
  407.                 if(playerInfo[i][playerWeaponSlot][10] != Weapon)
  408.                 {
  409.                     sendAutoBan(i, "Weapon Hacking");
  410.                 }
  411.             }
  412.             case 44, 45:
  413.             {
  414.                 if(playerInfo[i][playerWeaponSlot][11] != Weapon)
  415.                 {
  416.                     sendAutoBan(i, "Weapon Hacking");
  417.                 }
  418.             }
  419.             case 40:
  420.             {
  421.                 if(playerInfo[i][playerWeaponSlot][12] != Weapon)
  422.                 {
  423.                     sendAutoBan(i, "Weapon Hacking");
  424.                 }
  425.             }
  426.         }
  427.     }
  428.     return 1;
  429. }
  430.  
  431. public OnGameModeInit()
  432. {
  433.     SendRconCommand("mapname freeRoam");
  434.     print(""gameMode" has been loaded bsuccessfully! [SYSTEM]");
  435.     enableAntiHack();
  436.     print("The antihack has been successfully loaded.");
  437.    
  438.     EnableStuntBonusForAll(0);
  439.     DisableInteriorEnterExits();
  440.     SetGameModeText(gmName);
  441.     SetTimer("OneSecond", 6000, true);
  442.     return 1;
  443. }
  444.  
  445.  
  446. /* *************************** COMMANDS *************************************** */
  447. command(givemegun, playerid, params[])
  448. {
  449.     new weaponid, string[256], weaponname[26];
  450.     if(sscanf(params, "d", weaponid))
  451.     {
  452.         SendClientMessage(playerid, colourWhite, "SYTNAX: /givemegun [weapon name]");
  453.     }
  454.     else
  455.     {
  456.         if(weaponid > 0 && weaponid < 44 || weaponid == 46)
  457.         {
  458.             givePlayerValidWeapon(playerid, weaponid);
  459.             GetWeaponName(weaponid, weaponname, 26);
  460.             format(string, sizeof(string), "You have given yourself a %s.", weaponname);
  461.         }
  462.         else SendClientMessage(playerid, colourGrey, "Invalid weapon ID. (Cannot be NV Goggles, IR goggles or Fists.)");
  463.     }
  464.     return 1;
  465. }
  466.  
  467. command(spawncar, playerid, params[])
  468. {
  469.     new vehicleid, colour1, colour2;
  470.     if(sscanf(params, "ddd", vehicleid))
  471.     {
  472.         SendClientMessage(playerid, colourWhite, "SYNTAX: /spawncar [model id] [color 1] [color 2]");
  473.     }
  474.     else
  475.     {
  476.         if(vehicleid > 399 && vehicleid < 612)
  477.         {
  478.             new Float:x, Float:y, Float:z;
  479.             GetPlayerPos(playerid, x, y, z);
  480.             new veh = CreateVehicle(vehicleid, x-2, y, z, 0, colour1, colour2, 20);
  481.             SendClientMessage(playerid, colourWhite, "Vehicle spawned.");
  482.             PutPlayerInVehicle(playerid, veh, 0);
  483.         }
  484.         else SendClientMessage(playerid, colourGrey, "Invalid vehicle ID.");
  485.     }
  486.     return 1;
  487. }
  488.  
  489.  
  490.  
  491. command(togantihack, playerid, params[])
  492. {
  493.     if(IsPlayerAdmin(playerid))
  494.     {
  495.         new string[256];
  496.        
  497.         switch(globalAntiHack)
  498.         {
  499.             case 0:
  500.             {
  501.                 globalAntiHack = 1;
  502.                 format(string, 256, "AdminCMD: The Anti-Hack has been enabled by Administrator %s.", getName(playerid));
  503.                 SendClientMessageToAll(colourRed, string);
  504.                 print(string);
  505.             }
  506.             case 1:
  507.             {
  508.                 globalAntiHack = 0;
  509.                 format(string, 256, "AdminCMD: The Anti-Hack has been disabled by Administrator %s.", getName(playerid));
  510.                 SendClientMessageToAll(colourRed, string);
  511.                 print(string);
  512.             }
  513.         }
  514.     }
  515.     else SendClientMessage(playerid, colourGrey, "You do not have sufficient permissions to toggle the anti-cheat.");
  516.     return 1;
  517. }
  518. command(cuff, playerid, params[])
  519. {
  520.     if(playerInfo[playerid][playerPolice] == 1)
  521.     {
  522.         new Float:playerX, Float:playerY, Float:playerZ, string[256];
  523.        
  524.         GetPlayerPos(playerid, playerX, playerY, playerZ);
  525.        
  526.         for(new i = 0; i < MAX_PLAYERS; i++)
  527.         {
  528.             if(IsPlayerInRangeOfPoint(i, 5, playerX, playerY, playerZ))
  529.             {
  530.                 if(playerInfo[i][playerTazed] == 1)
  531.                 {
  532.                     SetPlayerSpecialAction(i, SPECIAL_ACTION_CUFFED);
  533.                     playerInfo[i][playerCuffed] = 1;
  534.                     DeletePVar(i, "Tazed");
  535.                     playerInfo[i][playerTazed] = 0;
  536.                     TogglePlayerControllable(i, false);
  537.                     format(string, 256, "Police Officer %s has cuffed you, until uncuff.", getName(playerid));
  538.                     SendClientMessage(i, colourYellow, string);
  539.                     format(string, 256, "You have cuffed %s, until uncuff.", getName(playerid));
  540.                     SendClientMessage(i, colourYellow, string);
  541.                 }
  542.                 else SendClientMessage(playerid, colourGrey, "That user is not tazed, and you are unable to cuff them.");
  543.             }
  544.         }
  545.     }
  546.     else SendClientMessage(playerid, colourGrey, "You do not have sufficient permission to cuff a player.");
  547.     return 1;
  548. }
  549.  
  550.  
  551. command(taze, playerid, params[])
  552. {
  553.     if(playerInfo[playerid][playerPolice] == 1)
  554.     {
  555.         new tazedPlayers = 0;
  556.         new Float:playerX, Float:playerY, Float:playerZ;
  557.        
  558.         GetPlayerPos(playerid, playerX, playerY, playerZ);
  559.        
  560.         for(new i = 0; i < MAX_PLAYERS; i++)
  561.         {
  562.             if(IsPlayerInRangeOfPoint(i, 5, playerX, playerY, playerZ))
  563.             {
  564.                 tazedPlayers++;
  565.                 if(tazedPlayers > 1)
  566.                 {
  567.                     SendClientMessage(playerid, colourGrey, "There is more than one person in-range of the tazer.");
  568.                 }
  569.                 else if(playerInfo[i][playerTazed] == 0)
  570.                 {
  571.                     TogglePlayerControllable(i, false);
  572.                     SendClientMessage(i, colourYellow, "You have been tazed by a Police Officer. This will wear off in 10 seconds.");
  573.                     SetPVarInt(i, "Tazed", gettime()+10);
  574.                     playerInfo[i][playerTazed] = 1;
  575.                 }
  576.                 else SendClientMessage(playerid, colourGrey, "That user is already cuffed.");
  577.             }
  578.         }
  579.     }
  580.     else SendClientMessage(playerid, colourGrey, "You do not have sufficient permissions to taze a player.");
  581.     return 1;
  582. }
  583.  
  584.  
  585.  
  586.  
  587. command(makecop, playerid, params[])
  588. {
  589.     if(playerInfo[playerid][playerAdmin] >= 4)
  590.     {
  591.         new targetID, string[256];
  592.        
  593.         if(sscanf(params, "u", targetID))
  594.         {
  595.             SendClientMessage(playerid, colourWhite, "SYNTAX: /makecop [playerid]");
  596.         }
  597.         else
  598.         {
  599.             if(IsPlayerConnected(targetID))
  600.             {
  601.                 if(playerInfo[targetID][playerPolice] == 0)
  602.                 {
  603.                     format(string, sizeof(string), "AdminCMD: %s has been made a Police Officer by Administrator %s.", getName(targetID), getName(playerid));
  604.                     SendClientMessageToAll(colourRed, string);
  605.  
  606.                     format(playerFile, 256, playerFileLoc, getName(targetID));
  607.                     dini_IntSet(playerFile, "playerPolice", 1);
  608.                     playerInfo[targetID][playerPolice] = 1;
  609.                 }
  610.                 else SendClientMessage(playerid, colourGrey, "This user is already a Police Officer!");
  611.             }
  612.             else SendClientMessage(playerid, colourGrey, "This user is not connected.");
  613.         }
  614.     }
  615.     else SendClientMessage(playerid, colourGrey, "You do not have sufficient permission to make somebody a Police Officer.");
  616.     return 1;
  617. }
  618.  
  619.  
  620. command(kick, playerid, params[])
  621. {
  622.     if(playerInfo[playerid][playerAdmin] >= 1)
  623.     {
  624.         new targetID, reason[155], string[256];
  625.        
  626.         if(sscanf(params, "us", targetID, reason))
  627.         {
  628.             SendClientMessage(playerid, colourWhite, "SYNTAX: /kick [playerid] [reason]");
  629.         }
  630.         else
  631.         {
  632.             if(IsPlayerConnected(targetID))
  633.             {
  634.                 format(string, sizeof(string), "AdminCMD: %s has been kicked from the server by Administrator %s. Reason: %s", getName(targetID), getName(playerid), reason);
  635.                 SendClientMessageToAll(colourRed, string);
  636.                 Kick(targetID);
  637.             }
  638.             else SendClientMessage(playerid, colourGrey, "That user is not connected.");
  639.         }
  640.     }
  641.     else SendClientMessage(playerid, colourGrey, "You do not have sufficient permission to kick a user from the server.");
  642.     return 1;
  643. }
  644.  
  645. command(heal, playerid, params[])
  646. {
  647.     new Float:hp;
  648.     GetPlayerHealth(playerid, hp);
  649.     if(hp < 100)
  650.     {
  651.         SetPlayerHealth(playerid, 100);
  652.         SendClientMessage(playerid, colourWhite, "You have healed yourself!");
  653.     }
  654.     else SendClientMessage(playerid, colourWhite, "You already have full health!");
  655.     return 1;
  656. }
  657.                
  658.  
  659. command(makeadmin, playerid, params[])
  660. {
  661.     if(playerInfo[playerid][playerAdmin] >= 4)
  662.     {
  663.         new targetID, level, string[256];
  664.        
  665.         if(sscanf(params, "ud", targetID, level))
  666.         {
  667.             SendClientMessage(playerid, colourWhite, "SYNTAX: /makeadmin [playerid] [level]");
  668.         }
  669.         else
  670.         {
  671.             if(IsPlayerConnected(targetID))
  672.             {
  673.                 if(playerInfo[playerid][playerAdmin] > playerInfo[targetID][playerAdmin])
  674.                 {
  675.                     if(playerInfo[playerid][playerAdmin] == 0 && level == 1)
  676.                     {
  677.                         format(string, sizeof(string), "AdminCMD: %s has been hired to the administrator team by Administrator %s.", getName(targetID), getName(playerid));
  678.                         SendClientMessageToAll(colourRed, string);
  679.  
  680.                         playerInfo[targetID][playerAdmin] = level;
  681.                         format(playerFile, 256, playerFileLoc, getName(targetID));
  682.                         dini_IntSet(playerFile, "playerAdmin", level);
  683.                     }
  684.                     else if(level == 0 && playerInfo[targetID][playerAdmin])
  685.                     {
  686.                         format(string, sizeof(string), "AdminCMD: %s has been removed from the administrator team by Administrator %s.", getName(targetID), getName(playerid));
  687.                         SendClientMessageToAll(colourRed, string);
  688.  
  689.                         playerInfo[targetID][playerAdmin] = level;
  690.                         format(playerFile, 256, playerFileLoc, getName(targetID));
  691.                         dini_IntSet(playerFile, "playerAdmin", level);
  692.                     }
  693.                     else if(level == playerInfo[playerid][playerAdmin])
  694.                     {
  695.                         SendClientMessage(playerid, colourGrey, "That user is already that level! Please choose a value higher or lower than their current level.");
  696.                     }
  697.                     else if(level < playerInfo[playerid][playerAdmin] && level > 0)
  698.                     {
  699.                         format(string, sizeof(string), "AdminCMD: %s has been demoted to level %d by Administrator %s.", getName(targetID), level, getName(playerid));
  700.                         SendClientMessageToAll(colourRed, string);
  701.  
  702.                         playerInfo[targetID][playerAdmin] = level;
  703.                         format(playerFile, 256, playerFileLoc, getName(targetID));
  704.                         dini_IntSet(playerFile, "playerAdmin", level);
  705.  
  706.                     }
  707.                     else if(level > playerInfo[playerid][playerAdmin] && level > 0)
  708.                     {
  709.                         format(string, sizeof(string), "AdminCMD: %s has been promoted to level %d by Administrator %s.", getName(targetID), level, getName(playerid));
  710.                         SendClientMessageToAll(colourRed, string);
  711.  
  712.                         playerInfo[targetID][playerAdmin] = level;
  713.                         format(playerFile, 256, playerFileLoc, getName(targetID));
  714.                         dini_IntSet(playerFile, "playerAdmin", level);
  715.  
  716.                     }
  717.                     else if(level < 0)
  718.                     {
  719.                         SendClientMessage(playerid, colourGrey, "You can not change an administrator's level to less than 0!");
  720.                     }
  721.                     print(string);
  722.                 }
  723.                 else SendClientMessage(playerid, colourGrey, "You can not change a higher level administrator's level!");
  724.             }
  725.             else SendClientMessage(playerid, colourGrey, "You cannot change an offline user's administrator level.");
  726.         }
  727.     }
  728.     else SendClientMessage(playerid, colourGrey, "You don't have sufficient permissions to change an administrator's rank.");
  729.     return 1;
  730. }
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737. /* *************************** COMMANDS *************************************** */
  738. public OnGameModeExit()
  739. {
  740.     return 1;
  741. }
  742.  
  743.  
  744. public OnPlayerConnect(playerid)
  745. {
  746.     loadPlayer(playerid);
  747.     return 1;
  748. }
  749.  
  750. public OnPlayerDisconnect(playerid, reason)
  751. {
  752.     return 1;
  753. }
  754.  
  755. public OnPlayerSpawn(playerid)
  756. {
  757.     return 1;
  758. }
  759.  
  760. public OnPlayerDeath(playerid, killerid, reason)
  761. {
  762.     GivePlayerMoney(killerid, 1000);
  763.     GivePlayerMoney(playerid, -1000);
  764.     SendDeathMessage(playerid, killerid, reason);
  765.     new randSpawn = random(6);
  766.     switch(randSpawn)
  767.     {
  768.         case 0:
  769.         {
  770.             SetSpawnInfo(playerid, 0, random(299), 1295.8590,-1424.8643,14.9531, 0, 0, 0, 0, 0, 0, 0);
  771.         }
  772.         case 1:
  773.         {
  774.             SetSpawnInfo(playerid, 0, random(299), 1545.5078,-1675.5112,13.5605, 0, 0, 0, 0, 0, 0, 0);
  775.         }
  776.         case 2:
  777.         {
  778.             SetSpawnInfo(playerid, 0, random(299), 1742.7448,-1864.3312,13.5740, 0, 0, 0, 0, 0, 0, 0);
  779.         }
  780.         case 3:
  781.         {
  782.             SetSpawnInfo(playerid, 0, random(299), 2495.1143,-1688.6969,13.9679, 0, 0, 0, 0, 0, 0, 0);
  783.         }
  784.         case 4:
  785.         {
  786.             SetSpawnInfo(playerid, 0, random(299), 2421.4343,-1224.3558,25.2236, 0, 0, 0, 0, 0, 0, 0);
  787.         }
  788.         case 5:
  789.         {
  790.             SetSpawnInfo(playerid, 0, random(299), 1459.2562,-1010.4940,26.8438, 0, 0, 0, 0, 0, 0, 0);
  791.         }
  792.         case 6:
  793.         {
  794.             SetSpawnInfo(playerid, 0, random(299), 825.0764,-1102.8118,25.7891, 0, 0, 0, 0, 0, 0, 0);
  795.         }
  796.  
  797.     }
  798.     SpawnPlayer(playerid);
  799.     return 1;
  800. }
  801.  
  802. public OnVehicleSpawn(vehicleid)
  803. {
  804.     return 1;
  805. }
  806.  
  807. public OnVehicleDeath(vehicleid, killerid)
  808. {
  809.     return 1;
  810. }
  811.  
  812. public OnPlayerText(playerid, text[])
  813. {
  814.     return 1;
  815. }
  816.  
  817.  
  818. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  819. {
  820.     return 1;
  821. }
  822.  
  823. public OnPlayerExitVehicle(playerid, vehicleid)
  824. {
  825.     return 1;
  826. }
  827.  
  828. public OnPlayerStateChange(playerid, newstate, oldstate)
  829. {
  830.     return 1;
  831. }
  832.  
  833. public OnPlayerEnterCheckpoint(playerid)
  834. {
  835.     return 1;
  836. }
  837.  
  838. public OnPlayerLeaveCheckpoint(playerid)
  839. {
  840.     return 1;
  841. }
  842.  
  843.  
  844. public OnObjectMoved(objectid)
  845. {
  846.     return 1;
  847. }
  848.  
  849. public OnPlayerObjectMoved(playerid, objectid)
  850. {
  851.     return 1;
  852. }
  853.  
  854. public OnPlayerPickUpPickup(playerid, pickupid)
  855. {
  856.     return 1;
  857. }
  858.  
  859. public OnVehicleMod(playerid, vehicleid, componentid)
  860. {
  861.     return 1;
  862. }
  863.  
  864. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  865. {
  866.     return 1;
  867. }
  868.  
  869. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  870. {
  871.     return 1;
  872. }
  873.  
  874. public OnPlayerSelectedMenuRow(playerid, row)
  875. {
  876.     return 1;
  877. }
  878.  
  879. public OnPlayerExitedMenu(playerid)
  880. {
  881.     return 1;
  882. }
  883.  
  884. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  885. {
  886.     return 1;
  887. }
  888.  
  889. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  890. {
  891.     return 1;
  892. }
  893.  
  894. public OnRconLoginAttempt(ip[], password[], success)
  895. {
  896.     return 1;
  897. }
  898.  
  899. public OnPlayerUpdate(playerid)
  900. {
  901.     return 1;
  902. }
  903.  
  904. public OnPlayerStreamIn(playerid, forplayerid)
  905. {
  906.     return 1;
  907. }
  908.  
  909. public OnPlayerStreamOut(playerid, forplayerid)
  910. {
  911.     return 1;
  912. }
  913.  
  914. public OnVehicleStreamIn(vehicleid, forplayerid)
  915. {
  916.     return 1;
  917. }
  918.  
  919. public OnVehicleStreamOut(vehicleid, forplayerid)
  920. {
  921.     return 1;
  922. }
  923.  
  924. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  925. {
  926.     if(dialogid == 1)
  927.     {
  928.         if(strlen(inputtext) > 2 && strlen(inputtext) < 16)
  929.         {
  930.             format(playerFile, 256, playerFileLoc, getName(playerid));
  931.             dini_Set(playerFile, "playerPass", inputtext);
  932.             format(playerInfo[playerid][playerPass], 256, inputtext);
  933.  
  934.             ShowPlayerDialog(playerid, 3, DIALOG_STYLE_MSGBOX, "Message of the day!", messageOfTheDay, "Spawn", "");
  935.         }
  936.         else ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Registeration", "Welcome to the server!\nYour password is an invalid length. (Must be over 2 and under 16)", "Register", "Cancel");
  937.     }
  938.    
  939.     if(dialogid == 2)
  940.     {
  941.         if(!isnull(inputtext))
  942.         {
  943.             format(playerFile, 256, playerFileLoc, getName(playerid));
  944.            
  945.             if(strcmp(dini_Get(playerFile, "playerPass"), inputtext, true) == 0)
  946.             {
  947.                 ShowPlayerDialog(playerid, 3, DIALOG_STYLE_MSGBOX, "Message of the day!", messageOfTheDay, "Spawn", "");
  948.             }
  949.             else ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "Welcome back to the server!\nPlease enter your password", "Login", "");
  950.         }
  951.     }
  952.     if(dialogid == 3)
  953.     {
  954.         initAndSpawn(playerid);
  955.     }
  956.    
  957.  
  958.     return 1;
  959. }
  960.  
  961. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  962. {
  963.     return 1;
  964. }
Add Comment
Please, Sign In to add comment