Scarred

Carson Takeover - Scarred

Aug 4th, 2011
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 20.29 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_commands>
  3. #include <YSI\y_ini>
  4. #include <YSI\y_foreach>
  5. #include <sscanf2>
  6.  
  7. forward UserDataLoad(playerid, name[], value[]);
  8.    
  9. enum player_Information {
  10.  
  11.         Password[128],
  12.         Kills,
  13.         Deaths,
  14.         AuthLvl,
  15.         Cash,
  16.         CustomSkin,
  17.         CustomCarID,
  18.         CustomCarC1,
  19.         CustomCarC2,
  20.         CustomCarPlate[33],
  21.         Score,
  22.         VIP
  23.     }
  24.         //Setting up the player information (what is inside of the user files, basically)
  25.  
  26. new
  27.     cInfo[MAX_PLAYERS][player_Information],
  28.     HealTimer[MAX_PLAYERS] = 0;
  29.  
  30.  
  31.     //#define     DEBUGMODE
  32.                 //Uncomment this if you don't want the debug commands; Recommended to leave commented!
  33.  
  34.     #define     SCRIPT_VERSION      "0.1"
  35.                                     //Supports letters aswell to allow for revisions to be monitored; Example: "0.1 R3"
  36.     #define     FLOAT_INFINITY      (Float:0x7F800000)
  37.                                     //Actual infinity - Not 999,999.
  38.     #define     USER_DIRECTORY      "Accounts/%s.ini"
  39.                                     //Account directory - Change if needed - Make sure this directory is created!
  40.     #define     REGISTER_DIALOG     1
  41.     #define     LOGIN_DIALOG        2
  42.  
  43.     main() {
  44.    
  45.         printf("[Carson Takeover -- Version %s]",   SCRIPT_VERSION);
  46.     }
  47.  
  48.     public OnGameModeInit() {
  49.  
  50.         new
  51.             GamemodeText[40];
  52.             //Supports up to 40 characters; Of course, it's easily changeable.
  53.            
  54.         format(GamemodeText, sizeof(GamemodeText), "V%s", SCRIPT_VERSION);
  55.         SetGameModeText(GamemodeText);
  56.        
  57.                                 /* TEAM ONE - POLICE (medic included) */
  58.        
  59.         AddPlayerClass(282, -216.1157977.8385,   19.4922,    268.8744, 22, 150, 31, 100, 33, 150);
  60.                       //Police - "Heavy" gunner
  61.                      
  62.         AddPlayerClass(280, -216.1157977.8385,   19.4922,    268.8744, 24, 50, 29, 100, 0, 0);
  63.                       //Police - "Light" patrol
  64.        
  65.         AddPlayerClass(275, -319.29931051.093420.3403,    358.0302, 33, 150, 42, 100, 0, 0);
  66.                       //Police - Medic
  67.  
  68.                                 /* TEAM TWO - INVADERS (medic included) */
  69.                                
  70.         AddPlayerClass(34-164.60951059.661719.7422,    267.0699,   22, 150, 31, 100, 33, 150);
  71.                       //"Rebel" - "Heavy" gunner
  72.  
  73.         AddPlayerClass(15-168.02311031.471419.7344,    178.8775,   24, 50, 29, 100, 0, 0);
  74.                       //"Rebel" - "Light" invader
  75.                      
  76.         AddPlayerClass(14-258.95971083.174120.9399,    353.9203,   33, 150, 42, 100, 0, 0);
  77.                       //"Rebel" - Medic
  78.                                
  79.                                 /*   VEHICLES FOR THE WHOLE SERVER   */
  80.                                
  81.         AddStaticVehicle(598,   -211.2230994.2327,   19.3020,    89.9457,    01); // LVPD1
  82.         AddStaticVehicle(598,   -211.2466999.6469,   19.4083,    89.9753,    01); // LVPD2
  83.         AddStaticVehicle(598,   -227.3858999.4583,   19.3383,    270.2986,   01); // LVPD3
  84.         AddStaticVehicle(598,   -227.2980993.9480,   19.2911,    270.2558,   01); // LVPD4
  85.        
  86.         return true;
  87.     }
  88.  
  89.     public OnGameModeExit() {
  90.  
  91.         return true;
  92.        
  93.     }
  94.  
  95.     public OnPlayerRequestClass(playerid, classid) {
  96.  
  97.         if(classid == 0) {
  98.             GameTextForPlayer(playerid, "~b~Local Police", 2000, 3);
  99.             SetPlayerPos(playerid, -216.1157,977.8385,19.4922);
  100.             SetPlayerFacingAngle(playerid, 268.8744);
  101.             SetPlayerCameraPos(playerid, -212.6229,977.9282,19.3258);
  102.             SetPlayerCameraLookAt(playerid, -216.5273,978.0528,19.4949);
  103.             SetPVarInt(playerid, "Medic", 0);
  104.         }
  105.         else if(classid == 1) {
  106.             GameTextForPlayer(playerid, "~b~Local Police", 2000, 3);
  107.             SetPlayerPos(playerid, -215.5698,980.6157,19.4947);
  108.             SetPlayerFacingAngle(playerid, 269.9826);
  109.             SetPlayerCameraPos(playerid, -214.0886,980.7875,19.3382);
  110.             SetPlayerCameraLookAt(playerid, -215.5698,980.6157,19.4947);
  111.             SetPVarInt(playerid, "Medic", 0);
  112.         }
  113.         else if(classid == 2) { //medic
  114.             GameTextForPlayer(playerid, "~b~Local Police", 2000, 3);
  115.             SetPlayerPos(playerid, -319.2871,1051.4486,20.3403);
  116.             SetPlayerFacingAngle(playerid, 358.0302);
  117.             SetPlayerCameraPos(playerid, -319.5100,1056.7614,19.7422);
  118.             SetPlayerCameraLookAt(playerid,-319.2871,1051.4486,20.3403);
  119.             SetPVarInt(playerid, "Medic", 1);
  120.         }
  121.         else if(classid == 3) {
  122.             GameTextForPlayer(playerid, "~r~Invaders", 2000, 3);
  123.             SetPlayerPos(playerid, -164.6095,1059.6617,19.7422);
  124.             SetPlayerFacingAngle(playerid, 267.0699);
  125.             SetPlayerCameraPos(playerid, -160.0465,1059.4253,19.7596);
  126.             SetPlayerCameraLookAt(playerid,-164.6095,1059.6617,19.7422);
  127.             SetPVarInt(playerid, "Medic", 0);
  128.         }
  129.         else if(classid == 4) {
  130.             GameTextForPlayer(playerid, "~r~Invaders", 2000, 3);
  131.             SetPlayerPos(playerid, -168.0231,1031.4714,19.7344);
  132.             SetPlayerFacingAngle(playerid, 178.8775);
  133.             SetPlayerCameraPos(playerid, -168.2652,1026.6465,19.7344);
  134.             SetPlayerCameraLookAt(playerid, -168.0231,1031.4714,19.7344);
  135.             SetPVarInt(playerid, "Medic", 0);
  136.         }
  137.         else if(classid == 5) { //medic
  138.             GameTextForPlayer(playerid, "~r~Invaders", 2000, 3);
  139.             SetPlayerPos(playerid, -258.9597,1083.1741,20.9399);
  140.             SetPlayerFacingAngle(playerid, 353.9203);
  141.             SetPlayerCameraPos(playerid, -258.7643,1086.7354,19.8927);
  142.             SetPlayerCameraLookAt(playerid,-258.9597,1083.1741,20.9399);
  143.             SetPVarInt(playerid, "Medic", 1);
  144.         }
  145.         return true;
  146.     }
  147.  
  148.     public OnPlayerConnect(playerid) {
  149.  
  150.         new
  151.             player_Name[MAX_PLAYER_NAME],
  152.             uFile[50];
  153.  
  154.         GetPlayerName(playerid, player_Name, sizeof(player_Name));
  155.         format(uFile, 50, USER_DIRECTORY, player_Name);
  156.  
  157.         if(!fexist(uFile))
  158.         {
  159.             ShowPlayerDialog(playerid, REGISTER_DIALOG, DIALOG_STYLE_INPUT, "Welcome!", "You do not appear to have an account on this server!\nPlease register by typing in your password below:", "Submit", "Quit");
  160.         }
  161.         else
  162.         {
  163.             ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "Welcome back!", "You appear to have an account on this server!\nPlease login by typing in your password below:", "Submit", "Quit");
  164.         }
  165.         return true;
  166.     }
  167.  
  168.     public OnPlayerDisconnect(playerid, reason) {
  169.  
  170.         if(GetPVarInt(playerid, "Logged") == 1) {
  171.  
  172.             new
  173.                 uFile[50],
  174.                 player_Name[MAX_PLAYER_NAME];
  175.  
  176.             GetPlayerName(playerid, player_Name, sizeof(player_Name));
  177.             format(uFile, 50, USER_DIRECTORY, player_Name);
  178.  
  179.             new
  180.                 INI:playerFile = INI_Open(uFile);
  181.  
  182.             INI_WriteInt(playerFile, "Authorization", cInfo[playerid][AuthLvl]);
  183.             INI_WriteInt(playerFile, "VIP", cInfo[playerid][VIP]);
  184.             INI_WriteInt(playerFile, "Cash", GetPlayerMoney(playerid));
  185.             INI_WriteInt(playerFile, "Score", GetPlayerScore(playerid));
  186.             INI_WriteInt(playerFile, "Kills", cInfo[playerid][Kills]);
  187.             INI_WriteInt(playerFile, "Skin", cInfo[playerid][CustomSkin]);
  188.             INI_WriteInt(playerFile, "Deaths", cInfo[playerid][Deaths]);
  189.  
  190.             INI_Close(playerFile);
  191.         }
  192.         return true;
  193.     }
  194.  
  195.     public OnPlayerSpawn(playerid) {
  196.  
  197.         if(cInfo[playerid][CustomSkin] != 0) {
  198.             SetPlayerSkin(playerid, cInfo[playerid][CustomSkin]);
  199.             SendClientMessage(playerid, -1, "{FFFFFF}Custom skin has been set.");
  200.         }
  201.        
  202.         return true;
  203.     }
  204.  
  205.     public OnPlayerDeath(playerid, killerid, reason) {
  206.  
  207.         return true;
  208.        
  209.     }
  210.  
  211.     public OnVehicleSpawn(vehicleid) {
  212.  
  213.         return true;
  214.        
  215.     }
  216.  
  217.     public OnVehicleDeath(vehicleid, killerid) {
  218.    
  219.         return true;
  220.        
  221.     }
  222.  
  223.     public OnPlayerText(playerid, text[]) {
  224.    
  225.         return true;
  226.        
  227.     }
  228.  
  229.     public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) {
  230.    
  231.         return true;
  232.        
  233.     }
  234.  
  235.     public OnPlayerExitVehicle(playerid, vehicleid) {
  236.    
  237.         return true;
  238.        
  239.     }
  240.  
  241.     public OnPlayerStateChange(playerid, newstate, oldstate) {
  242.    
  243.         return true;
  244.        
  245.     }
  246.  
  247.     public OnPlayerEnterCheckpoint(playerid) {
  248.    
  249.         return true;
  250.        
  251.     }
  252.  
  253.     public OnPlayerLeaveCheckpoint(playerid) {
  254.    
  255.         return true;
  256.        
  257.     }
  258.  
  259.     public OnPlayerEnterRaceCheckpoint(playerid) {
  260.    
  261.         return true;
  262.        
  263.     }
  264.  
  265.     public OnPlayerLeaveRaceCheckpoint(playerid) {
  266.    
  267.         return true;
  268.        
  269.     }
  270.  
  271.     public OnRconCommand(cmd[]) {
  272.  
  273.         return true;
  274.        
  275.     }
  276.  
  277.     public OnPlayerRequestSpawn(playerid) {
  278.    
  279.         return true;
  280.        
  281.     }
  282.  
  283.     public OnObjectMoved(objectid) {
  284.    
  285.         return true;
  286.        
  287.     }
  288.  
  289.     public OnPlayerObjectMoved(playerid, objectid) {
  290.    
  291.         return true;
  292.        
  293.     }
  294.  
  295.     public OnPlayerPickUpPickup(playerid, pickupid) {
  296.    
  297.         return true;
  298.        
  299.     }
  300.  
  301.     public OnVehicleMod(playerid, vehicleid, componentid) {
  302.    
  303.         return true;
  304.        
  305.     }
  306.  
  307. public OnVehiclePaintjob(playerid, vehicleid, paintjobid) {
  308.  
  309.     return true;
  310.    
  311. }
  312.  
  313. public OnVehicleRespray(playerid, vehicleid, color1, color2) {
  314.  
  315.     return true;
  316.    
  317. }
  318.  
  319. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid) {
  320.  
  321.     return true;
  322.    
  323. }
  324.  
  325. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
  326.  
  327.     return true;
  328.    
  329. }
  330.  
  331. public OnRconLoginAttempt(ip[], password[], success) {
  332.  
  333.     return true;
  334.    
  335. }
  336.  
  337. public OnPlayerUpdate(playerid) {
  338.  
  339.     return true;
  340.    
  341. }
  342.  
  343. public OnPlayerStreamIn(playerid, forplayerid) {
  344.  
  345.     return true;
  346.    
  347. }
  348.  
  349. public OnPlayerStreamOut(playerid, forplayerid) {
  350.  
  351.     return true;
  352.    
  353. }
  354.  
  355. public OnVehicleStreamIn(vehicleid, forplayerid) {
  356.  
  357.     return true;
  358.    
  359. }
  360.  
  361. public OnVehicleStreamOut(vehicleid, forplayerid) {
  362.  
  363.     return true;
  364.    
  365. }
  366.  
  367.     public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  368.  
  369.         switch(dialogid) {
  370.             case REGISTER_DIALOG: {
  371.            
  372.                 if(response) {
  373.                
  374.                     if(strlen(inputtext) <= 128) {
  375.                    
  376.                         return OnPlayerRegister(playerid, inputtext);
  377.                        
  378.                     }
  379.                    
  380.                     else {
  381.                    
  382.                         ShowPlayerDialog(playerid, REGISTER_DIALOG, DIALOG_STYLE_INPUT, "Welcome!", "You do not appear to have an account on this server!\nPlease register by typing in your password below:", "Submit", "Quit");
  383.  
  384.                     }
  385.                 }
  386.                 else return Kick(playerid);
  387.             }
  388.  
  389.             case LOGIN_DIALOG: {
  390.            
  391.                 if(response) {
  392.                
  393.                     new
  394.                         uFile[50],
  395.                         player_Name[MAX_PLAYER_NAME];
  396.  
  397.                     GetPlayerName(playerid, player_Name, sizeof(player_Name));
  398.                     format(uFile, 50, USER_DIRECTORY, player_Name);
  399.  
  400.                     INI_ParseFile(uFile, "UserDataLoad", .bExtra = true, .extra = playerid);
  401.  
  402.                     new string[128];
  403.                     format(string, sizeof(string), "%s", inputtext);
  404.  
  405.                     if(strcmp(string, cInfo[playerid][Password], true) == 0) {
  406.                    
  407.                         new
  408.                             Year, Month, Day,
  409.                             Hour, Minute, Second;
  410.                         //printf("inputtext: %s", string);
  411.                         getdate(Year, Month, Day);
  412.                         gettime(Hour, Minute, Second);
  413.                         printf("<User:%s> Logged in. [%d/%d/%d @ %d:%d]", player_Name, Month, Day, Year, Hour, Minute);
  414.                         SetPVarInt(playerid, "Logged", 1);
  415.                         return true;
  416.                        
  417.                     }
  418.                     else return ShowPlayerDialog(playerid, LOGIN_DIALOG, DIALOG_STYLE_INPUT, "Welcome back!", "You appear to have an account on this server!\nPlease login by typing in your password below:", "Submit", "Quit");
  419.                 }
  420.                 else Kick(playerid);
  421.                 return 0;
  422.             }
  423.         }
  424.         return true;
  425.     }
  426.  
  427.     public OnPlayerClickPlayer(playerid, clickedplayerid, source) {
  428.    
  429.         return true;
  430.        
  431.     }
  432.  
  433.                                             /* SSCANF SPECIFIERS | COMMANDS BELOW!
  434.                                                         - Y_Less
  435.                                            
  436.                             SPECIFIER           |           NAME          |         EXAMPLE
  437.                             ______________________________________________________________________
  438.                            
  439.                             i, d                |           Integer       |         1, 42, -10
  440.                             c                   |           Character     |         a, o, *
  441.                             l                   |           Logical       |         true, false
  442.                             b                   |           Binary        |         01001, 0b1100
  443.                             h, x                |           Hex           |         1A, 0x23
  444.                             o                   |           Octal         |         045 12
  445.                             n                   |           Number        |         42, 0b010, 0xAC, 045
  446.                             f                   |           Float         |         0.7, -99.5
  447.                             g                   |           IEEE Float    |         0.7, -99.5, INFINITY, -INFINITY, NAN
  448.                             u                   |           User name/id  |         Y_Less, 0
  449.                             q                   |           Bot name/id   |         ShopBot, 27
  450.                             r                   |           Player name/id|         Y_Less, 42
  451.                             _______________________________________________________________________
  452.                                             http://forum.sa-mp.com/showthread.php?t=120356 */
  453.                            
  454.  
  455.     CMD:spawnvehicle(playerid, params[])
  456.     {
  457.         new
  458.             ModelID,
  459.             Float:Pos[4],
  460.             Vehicle,
  461.             C1, C2;
  462.  
  463.         if(sscanf(params, "iI(-1)I(-1)", ModelID, C1, C2))
  464.             return SendClientMessage(playerid, -1, "{FFFFFF}Usage: /spawnvehicle [model id]");
  465.  
  466.         if(cInfo[playerid][AuthLvl] >= 2) {
  467.             GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  468.             GetPlayerFacingAngle(playerid, Pos[3]);
  469.  
  470.             Vehicle = CreateVehicle(ModelID, Pos[0], Pos[1], Pos[2], Pos[3], C1, C2, -1);
  471.             PutPlayerInVehicle(playerid, Vehicle, 0);
  472.         }
  473.         return true;
  474.     }
  475.    
  476.     CMD:restart(playerid, params[])
  477.     {
  478.         #pragma unused params
  479.         #pragma unused playerid
  480.         new
  481.             uFile[50],
  482.             player_Name[MAX_PLAYER_NAME];
  483.  
  484.         if(cInfo[playerid][AuthLvl] >= 3) {
  485.             foreach(Player, i)
  486.             {
  487.                 GetPlayerName(i, player_Name, sizeof(player_Name));
  488.                 format(uFile, 50, USER_DIRECTORY, player_Name);
  489.  
  490.                 new
  491.                     INI:playerFile = INI_Open(uFile);
  492.  
  493.                 INI_WriteInt(playerFile, "Authorization", cInfo[i][AuthLvl]);
  494.                 INI_WriteInt(playerFile, "VIP", cInfo[i][VIP]);
  495.                 INI_WriteInt(playerFile, "Cash", GetPlayerMoney(i));
  496.                 INI_WriteInt(playerFile, "Score", GetPlayerScore(i));
  497.                 INI_WriteInt(playerFile, "Kills", cInfo[i][Kills]);
  498.                 INI_WriteInt(playerFile, "Skin", cInfo[i][CustomSkin]);
  499.                 INI_WriteInt(playerFile, "Deaths", cInfo[i][Deaths]);
  500.  
  501.                 printf("<User: System> Saved ID %d", i);
  502.  
  503.                 INI_Close(playerFile);
  504.             }
  505.             GameModeExit();
  506.         }
  507.         else return SendClientMessage(playerid, -1, "Invalid Authorization Level.");
  508.         return true;
  509.     }
  510.    
  511.     CMD:heal(playerid, params[]) {
  512.         #pragma unused params
  513.  
  514.         if(GetPVarInt(playerid, "Medic") == 1) {
  515.        
  516.             if(HealTimer[playerid] == 0) {
  517.  
  518.                 new
  519.                     Float:Health;
  520.  
  521.                 GetPlayerHealth(GetClosestPlayer(playerid, 3), Health);
  522.                 if(Health <= 80) {
  523.                     SetPlayerHealth(GetClosestPlayer(playerid, 3), Health+20);
  524.                     SetTimerEx("HealPlayer", 15000, 0, "i", playerid);
  525.                     HealTimer[playerid] = 1;
  526.                     if(GetClosestPlayer(playerid, 3) == -1) { SendClientMessage(playerid, -1, "Nobody's close enough to be healed!"); }
  527.                 }
  528.                 else return SendClientMessage(playerid, -1, "They have too much health to be healed!");
  529.             }
  530.             else return SendClientMessage(playerid, -1, "Please wait 15 seconds!");
  531.         }
  532.         else return SendClientMessage(playerid, -1, "You're not a medic!");
  533.         return true;
  534.     }
  535.    
  536.     CMD:sethealth(playerid, params[]) {
  537.         new
  538.             Health,
  539.             Player;
  540.  
  541.         if(cInfo[playerid][AuthLvl] >= 1) {
  542.            
  543.             if(sscanf(params, "ui", Player, Health))
  544.                 return SendClientMessage(playerid, -1, "Usage: /sethealth [playerid] [amount of health]");
  545.  
  546.             SetPlayerHealth(Player, Health);
  547.         }
  548.         else return SendClientMessage(playerid, -1, "Invalid Authorization Level.");
  549.         return true;
  550.  
  551.     }
  552.    
  553.     CMD:setarmour(playerid, params[]) {
  554.         new
  555.             Armour,
  556.             Player;
  557.            
  558.         if(cInfo[playerid][AuthLvl] >= 1) {
  559.        
  560.             if(sscanf(params, "ui", Player, Armour))
  561.                 return SendClientMessage(playerid, -1, "Usage: /setarmour [playerid] [amount of armour]");
  562.                
  563.             SetPlayerArmour(Player, Armour);
  564.        
  565.         }
  566.         else return SendClientMessage(playerid, -1, "Invalid Authorization Level.");
  567.         return true;
  568.  
  569.     }
  570.    
  571.     CMD:kick(playerid, params[]) {
  572.         new
  573.             Player,
  574.             Reason[50],
  575.             string[128];
  576.            
  577.         if(cInfo[playerid][AuthLvl] >= 1) {
  578.        
  579.             if(sscanf(params, "us[128]", Player, Reason))
  580.                 return SendClientMessage(playerid, -1, "Usage: /kick [playerid] [reason]");
  581.                
  582.             new
  583.                 admin_Name[MAX_PLAYER_NAME],
  584.                 player_Name[MAX_PLAYER_NAME];
  585.  
  586.             GetPlayerName(playerid, admin_Name, sizeof(admin_Name));
  587.             GetPlayerName(Player, player_Name, sizeof(player_Name));
  588.                
  589.             if(strlen(Reason) > 50)
  590.                 return SendClientMessage(playerid, -1, "\"Reason\" parameter too long! Keep it below 50 characters!");
  591.                
  592.             format(string, sizeof(string), "<ACMD> Administrator %s has booted %s from the server, Reason: %s", admin_Name, player_Name, Reason);
  593.             SendClientMessageToAll(-1, string);
  594.             Kick(Player);
  595.         }
  596.         else return SendClientMessage(playerid, -1, "Invalid Authorization Level.");
  597.         return true;
  598.  
  599.     }
  600.    
  601.     CMD:ban(playerid, params[]) {
  602.         new
  603.             Player,
  604.             Reason[50],
  605.             string[128];
  606.  
  607.         if(cInfo[playerid][AuthLvl] >= 2) {
  608.  
  609.             if(sscanf(params, "us[128]", Player, Reason))
  610.                 return SendClientMessage(playerid, -1, "Usage: /ban [playerid] [reason]");
  611.  
  612.             new
  613.                 admin_Name[MAX_PLAYER_NAME],
  614.                 player_Name[MAX_PLAYER_NAME];
  615.  
  616.             GetPlayerName(playerid, admin_Name, sizeof(admin_Name));
  617.             GetPlayerName(Player, player_Name, sizeof(player_Name));
  618.  
  619.             if(strlen(Reason) > 50)
  620.                 return SendClientMessage(playerid, -1, "\"Reason\" parameter too long! Keep it below 50 characters!");
  621.  
  622.             format(string, sizeof(string), "<ACMD> Administrator %s has banned %s from the server, Reason: %s", admin_Name, player_Name, Reason);
  623.             SendClientMessageToAll(-1, string);
  624.             BanEx(Player, Reason);
  625.         }
  626.         else return SendClientMessage(playerid, -1, "Invalid Authorization Level.");
  627.         return true;
  628.  
  629.     }
  630.    
  631.     #if defined DEBUGMODE //Debug commands!
  632.    
  633.     CMD:getinfo(playerid, params[]) {
  634.     #pragma unused params
  635.  
  636.         new
  637.             string[128],
  638.             Float:Position[4];
  639.  
  640.         GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
  641.         GetPlayerFacingAngle(playerid, Position[3]);
  642.         format(string, sizeof(string), "{FFFFFF}XPos: %f, YPos: %f, ZPos: %f, FPos: %f, Int: %d, VW: %d", Position[0], Position[1], Position[2], Position[3], GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid));
  643.         SendClientMessage(playerid, -1, string);
  644.         return true;
  645.     }
  646.    
  647.     CMD:a(playerid, params[])
  648.     {
  649.         #pragma unused params
  650.         return cInfo[playerid][AuthLvl] = 5;
  651.     }
  652.    
  653.     #endif
  654.    
  655.     OnPlayerRegister(playerid, password[]) {
  656.    
  657.         new
  658.             uFile[50],
  659.             player_Name[MAX_PLAYER_NAME];
  660.  
  661.         GetPlayerName(playerid, player_Name, sizeof(player_Name));
  662.         format(uFile, 50, USER_DIRECTORY, player_Name);
  663.  
  664.         new
  665.             INI:playerFile = INI_Open(uFile);
  666.  
  667.         INI_WriteString(playerFile, "Password", password);
  668.         INI_WriteInt(playerFile, "Authorization", 0);
  669.         INI_WriteInt(playerFile, "VIP", 0);
  670.         INI_WriteInt(playerFile, "Cash", 1);
  671.         INI_WriteInt(playerFile, "Skin", 0);
  672.         INI_WriteInt(playerFile, "Score", 0);
  673.         INI_WriteInt(playerFile, "Kills", 0);
  674.         INI_WriteInt(playerFile, "Deaths", 0);
  675.  
  676.         INI_Close(playerFile);
  677.  
  678.         SetPVarInt(playerid, "Logged", 1);
  679.         return true;
  680.     }
  681.    
  682.     public UserDataLoad(playerid,name[],value[]) {
  683.    
  684.         INI_String("Password", cInfo[playerid][Password], 128);
  685.         INI_Int("Authorization", cInfo[playerid][AuthLvl]);
  686.         INI_Int("VIP", cInfo[playerid][VIP]);
  687.         INI_Int("Cash", cInfo[playerid][Cash]);
  688.         INI_Int("Skin", cInfo[playerid][CustomSkin]);
  689.         INI_Int("Score", cInfo[playerid][Score]);
  690.         INI_Int("Kills", cInfo[playerid][Kills]);
  691.         INI_Int("Deaths", cInfo[playerid][Deaths]);
  692.         return true;
  693.     }
  694.    
  695.     forward HealPlayer(playerid);
  696.     public HealPlayer(playerid) {
  697.  
  698.         HealTimer[playerid] = 0;
  699.         return true;
  700.  
  701.     }
  702.    
  703.     stock IsNumeric(const string[]) {
  704.  
  705.         for (new i = 0, j = strlen(string); i < j; i++)
  706.         {
  707.                 if (string[i] > '9' || string[i] < '0') return 0;
  708.         }
  709.         return true;
  710.     }
  711.    
  712.     stock Float:GetDistanceBetweenPoints(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2) {
  713.         x1 -= x2;
  714.         y1 -= y2;
  715.         z1 -= z2;
  716.         return floatsqroot((x1 * x1) + (y1 * y1) + (z1 * z1));
  717.     }
  718.    
  719.     stock GetClosestPlayer(playerid,Float:limit) { //By cessil
  720.         new Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2;
  721.         GetPlayerPos(playerid,x1,y1,z1);
  722.         new Float:Range = 999.9;
  723.         new id = -1;
  724.         foreach(Player,i)
  725.         {
  726.             if(playerid != i)
  727.             {
  728.                 GetPlayerPos(i,x2,y2,z2);
  729.                 new Float:Dist = GetDistanceBetweenPoints(x1,y1,z1,x2,y2,z2);
  730.                 if(floatcmp(Range,Dist) == 1 && floatcmp(limit,Range) == 1)
  731.                 {
  732.                     Range = Dist;
  733.                     id = i;
  734.                 }
  735.             }
  736.         }
  737.         return id;
  738.     }
Advertisement
Add Comment
Please, Sign In to add comment