Scarred

Carson Takeover - Scarred

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