Advertisement
Guest User

Esobar's DM

a guest
Sep 6th, 2017
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 15.65 KB | None | 0 0
  1. ///////////////////////Script made by Escobar//////////////////////////////////
  2.  
  3. #include <a_samp>
  4. #include <YSI\y_ini>
  5. #include <sscanf2>
  6. #include <zcmd>
  7.  
  8. #define DIALOG_REGISTER 1
  9. #define DIALOG_LOGIN 2
  10. #define DIALOG_SUCCESS_1 3
  11. #define DIALOG_SUCCESS_2 4
  12.  
  13. #define PATH "/users/%s.ini"
  14.  
  15. #define COL_WHITE "{FFFFFF}"
  16. #define COL_RED "{F81414}"
  17. #define COL_GREEN "{00FF22}"
  18. #define COL_LIGHTBLUE "{00CED1}"
  19. #define COLOR_GREY 0xAFAFAFAA
  20. #define COLOR_RED 0xAA3333AA
  21. #define COLOR_WHITE 0xFFFFFFAA
  22.  
  23.  
  24.  
  25. enum pInfo
  26. {
  27.     pPass,
  28.     pCash,
  29.     pAdmin,
  30.     pKills,
  31.     pDeaths,
  32.    
  33.  
  34. }
  35. new PlayerInfo[MAX_PLAYERS][pInfo];
  36.  
  37.  
  38. forward LoadUser_data(playerid,name[],value[]);
  39. public LoadUser_data(playerid,name[],value[])
  40. {
  41.     INI_Int("Password",PlayerInfo[playerid][pPass]);
  42.     INI_Int("Cash",PlayerInfo[playerid][pCash]);
  43.     INI_Int("Kills",PlayerInfo[playerid][pKills]);
  44.     INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
  45.     INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  46.     return 1;
  47. }
  48.  
  49. stock UserPath(playerid)
  50. {
  51.     new string[128],playername[MAX_PLAYER_NAME];
  52.     GetPlayerName(playerid,playername,sizeof(playername));
  53.     format(string,sizeof(string),PATH,playername);
  54.     return string;
  55. }
  56.  
  57. /*Credits to Dracoblue*/
  58. stock udb_hash(buf[]) {
  59.     new length=strlen(buf);
  60.     new s1 = 1;
  61.     new s2 = 0;
  62.     new n;
  63.     for (n=0; n<length; n++)
  64.     {
  65.        s1 = (s1 + buf[n]) % 65521;
  66.        s2 = (s2 + s1)     % 65521;
  67.     }
  68.     return (s2 << 16) + s1;
  69. }
  70. main()
  71. {
  72.     print("\n----------------------------------");
  73.     print(" Escobar's DM Loaded");
  74.     print("----------------------------------\n");
  75. }
  76.  
  77.  
  78. public OnGameModeInit()
  79. {
  80.  
  81.  ///////////////////////////////////////////////////////
  82.     // Don't use these lines if it's a filterscript
  83.     SetGameModeText("E:DM V1.0.0");
  84.     AddPlayerClass(31,-373.4418,2195.7175,42.0807,15.0124,6,1,26,100,33,100);
  85.     AddPlayerClass(32,-389.4026,2261.2319,41.8178,195.4941,6,1,26,100,33,100);
  86.     AddPlayerClass(33,-350.2201,2240.5601,42.4844,96.1664,6,1,26,100,33,100);
  87.     AddPlayerClass(34,-440.3142,2229.3542,42.4297,269.7546,6,1,26,100,33,100);
  88.     AddPlayerClass(128,-350.2201,2240.5601,42.4844,96.1664,6,1,26,100,33,100);
  89.     AddPlayerClass(129,-373.4418,2195.7175,42.0807,15.0124,6,1,26,100,33,100);
  90.     AddPlayerClass(130,-440.3142,2229.3542,42.4297,269.7546,6,1,26,100,33,100);
  91.     AddPlayerClass(131,-350.2201,2240.5601,42.4844,96.1664,6,1,26,100,33,100);
  92.     AddPlayerClass(132,-373.4418,2195.7175,42.0807,15.0124,6,1,26,100,33,100);
  93.     AddPlayerClass(133,-440.3142,2229.3542,42.4297,269.7546,6,1,26,100,33,100);
  94.     AddPlayerClass(157,-350.2201,2240.5601,42.4844,96.1664,6,1,26,100,33,100);
  95.     AddPlayerClass(158,-373.4418,2195.7175,42.0807,15.0124,6,1,26,100,33,100);
  96.     AddPlayerClass(159,-440.3142,2229.3542,42.4297,269.7546,6,1,26,100,33,100);
  97.     AddPlayerClass(160,-350.2201,2240.5601,42.4844,96.1664,6,1,26,100,33,100);
  98.     AddPlayerClass(161,-373.4418,2195.7175,42.0807,15.0124,6,1,26,100,33,100);
  99.     AddPlayerClass(162,-440.3142,2229.3542,42.4297,269.7546,6,1,26,100,33,100);
  100.     AddPlayerClass(196,-373.4418,2195.7175,42.0807,15.0124,6,1,26,100,33,100);
  101.     AddPlayerClass(197,-440.3142,2229.3542,42.4297,269.7546,6,1,26,100,33,100);
  102.     AddPlayerClass(198,-373.4418,2195.7175,42.0807,15.0124,6,1,26,100,33,100);
  103.     AddPlayerClass(199,-350.2201,2240.5601,42.4844,96.1664,6,1,26,100,33,100);
  104.     AddPlayerClass(200,-440.3142,2229.3542,42.4297,269.7546,6,1,26,100,33,100);
  105.     AddPlayerClass(201,-373.4418,2195.7175,42.0807,15.0124,6,1,26,100,33,100);
  106.     AddPlayerClass(202,-389.4026,2261.2319,41.8178,195.4941,6,1,26,100,33,100);
  107.    
  108. //////////////////////////////////////////////////////////////////////////
  109.     AddStaticVehicleEx (520, 2109.1763, 1503.0453, 32.2887, 82.2873, -1, -1, 15);
  110.     AddStaticVehicleEx (519,1328.6196,1612.2500,11.7437,270.0001,1,1, 15);
  111.     AddStaticVehicleEx (593,1352.1102,1779.0000,11.2880,270.0000,2,1, 15);
  112.     AddStaticVehicleEx (593,1352.1116,1801.5000,11.2863,269.9999,36,8, 15);
  113.     AddStaticVehicleEx (522,1676.4335,1322.1592,10.3320,87.7189,7,79, 15);
  114.     AddStaticVehicleEx (417,1286.8724,1449.6250,10.8722,270.0000,0,0, 15);
  115.     AddStaticVehicleEx (553,1571.4385,1487.7513,12.1685,311.1577,71,87, 15);
  116.     AddStaticVehicleEx (553,1597.4109,1342.6935,12.1865,344.8449,71,87, 15);
  117.     AddStaticVehicleEx (487,1655.0576,1554.5649,10.9879,64.4211,26,3, 15);
  118.     AddStaticVehicleEx (487,1397.5690,1770.0475,10.9971,269.3060,26,3, 15);
  119.     AddStaticVehicleEx (487,1618.4143,1357.5428,10.9893,169.4555,26,3, 15);
  120.     AddStaticVehicleEx (469,1358.1189,1253.5436,10.8285,358.5788,1,3, 15);
  121.     AddStaticVehicleEx (609,1341.5886,1729.4564,10.8864,91.6428,36,36, 15);
  122.     AddStaticVehicleEx (519,1303.7971,1360.9348,11.7405,267.7907,1,1, 15);
  123.     AddStaticVehicleEx (511,1341.3031,1682.6432,12.1967,268.5870,3,90, 15);
  124.     AddStaticVehicleEx (512,1326.1611,1420.4333,11.1030,178.1441,17,39, 15);
  125.     AddStaticVehicleEx (513,1280.1281,1411.8032,11.3653,223.4432,48,18, 15);
  126.     AddStaticVehicleEx (515,1573.4801,1654.4058,11.8422,91.4976,24,77, 15);
  127.     AddStaticVehicleEx (404,1309.7848,1279.5735,10.5544,359.2681,101,101, 15);
  128.     AddStaticVehicleEx (411,1682.5769,1316.6561,10.5474,358.3994,123,1, 15);
  129.     AddStaticVehicleEx (436,1663.4026,1297.1321,10.5877,359.4867,83,1, 15);
  130.     AddStaticVehicleEx (439,1642.0035,1293.2332,10.7156,268.6615,54,38, 15);
  131.     AddStaticVehicleEx (462,1713.8118,1319.2559,10.4165,268.4222,2,1, 15);
  132.     AddStaticVehicleEx (474,1695.4330,1306.1843,10.5853,179.3891,110,1, 15);
  133.     AddStaticVehicleEx (480,1682.4532,1286.9058,10.5945,179.2040,6,6, 15);
  134.     AddStaticVehicleEx (420,1723.8730,1501.4979,10.5187,167.0140,6,1, 15);
  135.    
  136.     return 1;
  137. }
  138.  
  139. public OnGameModeExit()
  140. {
  141.     return 1;
  142. }
  143.  
  144. public OnPlayerRequestClass(playerid, classid)
  145. {
  146.     SetPlayerPos(playerid, -373.4418,2195.7175,42.0807);
  147.     SetPlayerCameraPos(playerid, -373.4418,2195.7175,42.0807);
  148.     SetPlayerCameraLookAt(playerid, -373.4418,2195.7175,42.0807);
  149.     return 1;
  150. }
  151.  
  152. public OnPlayerConnect(playerid)
  153. {
  154.     if(fexist(UserPath(playerid)))
  155.     {
  156.         INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  157.         ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
  158.     }
  159.     else
  160.     {
  161.         ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
  162.     }
  163.     return 1;
  164. }
  165.  
  166. public OnPlayerDisconnect(playerid, reason)
  167. {
  168.     new INI:File = INI_Open(UserPath(playerid));
  169.     INI_SetTag(File,"data");
  170.     INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  171.     INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
  172.     INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  173.     INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
  174.     INI_Close(File);
  175.     return 1;
  176. }
  177.  
  178. public OnPlayerSpawn(playerid)
  179. {
  180.     return 1;
  181. }
  182.  
  183. public OnPlayerDeath(playerid, killerid, reason)
  184. {
  185.     PlayerInfo[killerid][pKills]++;
  186.     PlayerInfo[playerid][pDeaths]++;
  187.     return 1;
  188. }
  189.  
  190. public OnVehicleSpawn(vehicleid)
  191. {
  192.     return 1;
  193. }
  194.  
  195. public OnVehicleDeath(vehicleid, killerid)
  196. {
  197.     return 1;
  198. }
  199.  
  200. public OnPlayerText(playerid, text[])
  201. {
  202.     return 1;
  203. }
  204.  
  205. public OnPlayerCommandText(playerid, cmdtext[])
  206. {
  207.     if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  208.     {
  209.         // Do something here
  210.         return 1;
  211.     }
  212.     return 0;
  213. }
  214.  
  215. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  216. {
  217.     return 1;
  218. }
  219.  
  220. public OnPlayerExitVehicle(playerid, vehicleid)
  221. {
  222.     return 1;
  223. }
  224.  
  225. public OnPlayerStateChange(playerid, newstate, oldstate)
  226. {
  227.     return 1;
  228. }
  229.  
  230. public OnPlayerEnterCheckpoint(playerid)
  231. {
  232.     return 1;
  233. }
  234.  
  235. public OnPlayerLeaveCheckpoint(playerid)
  236. {
  237.     return 1;
  238. }
  239.  
  240. public OnPlayerEnterRaceCheckpoint(playerid)
  241. {
  242.     return 1;
  243. }
  244.  
  245. public OnPlayerLeaveRaceCheckpoint(playerid)
  246. {
  247.     return 1;
  248. }
  249.  
  250. public OnRconCommand(cmd[])
  251. {
  252.     return 1;
  253. }
  254.  
  255. public OnPlayerRequestSpawn(playerid)
  256. {
  257.     return 1;
  258. }
  259.  
  260. public OnObjectMoved(objectid)
  261. {
  262.     return 1;
  263. }
  264.  
  265. public OnPlayerObjectMoved(playerid, objectid)
  266. {
  267.     return 1;
  268. }
  269.  
  270. public OnPlayerPickUpPickup(playerid, pickupid)
  271. {
  272.     return 1;
  273. }
  274.  
  275. public OnVehicleMod(playerid, vehicleid, componentid)
  276. {
  277.     return 1;
  278. }
  279.  
  280. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  281. {
  282.     return 1;
  283. }
  284.  
  285. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  286. {
  287.     return 1;
  288. }
  289.  
  290. public OnPlayerSelectedMenuRow(playerid, row)
  291. {
  292.     return 1;
  293. }
  294.  
  295. public OnPlayerExitedMenu(playerid)
  296. {
  297.     return 1;
  298. }
  299.  
  300. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  301. {
  302.     return 1;
  303. }
  304.  
  305. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  306. {
  307.     return 1;
  308. }
  309.  
  310. public OnRconLoginAttempt(ip[], password[], success)
  311. {
  312.     return 1;
  313. }
  314.  
  315. public OnPlayerUpdate(playerid)
  316. {
  317.     return 1;
  318. }
  319.  
  320. public OnPlayerStreamIn(playerid, forplayerid)
  321. {
  322.     return 1;
  323. }
  324.  
  325. public OnPlayerStreamOut(playerid, forplayerid)
  326. {
  327.     return 1;
  328. }
  329.  
  330. public OnVehicleStreamIn(vehicleid, forplayerid)
  331. {
  332.     return 1;
  333. }
  334.  
  335. public OnVehicleStreamOut(vehicleid, forplayerid)
  336. {
  337.     return 1;
  338. }
  339.  
  340. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  341. {
  342.     switch( dialogid )
  343.     {
  344.         case DIALOG_REGISTER:
  345.         {
  346.             if (!response) return Kick(playerid);
  347.             if(response)
  348.             {
  349.                 if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
  350.                 new INI:File = INI_Open(UserPath(playerid));
  351.                 INI_SetTag(File,"data");
  352.                 INI_WriteInt(File,"Password",udb_hash(inputtext));
  353.                 INI_WriteInt(File,"Cash",0);
  354.                 INI_WriteInt(File,"Kills",0);
  355.                 INI_WriteInt(File,"Deaths",0);
  356.                 INI_Close(File);
  357.  
  358.                 SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
  359.                 SpawnPlayer(playerid);
  360.                 ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Thanks! You are registered at, "COL_LIGHTBLUE"YOUR_SERVER","Ok","");
  361.             }
  362.         }
  363.  
  364.         case DIALOG_LOGIN:
  365.         {
  366.             if ( !response ) return Kick ( playerid );
  367.             if( response )
  368.             {
  369.                 if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
  370.                 {
  371.                     INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  372.                     GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
  373.                     ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
  374.                 }
  375.                 else
  376.                 {
  377.                     ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
  378.                 }
  379.                 return 1;
  380.             }
  381.         }
  382.     }
  383.     return 1;
  384. }
  385.  
  386. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  387. {
  388.     return 1;
  389. }
  390.  
  391. //////////////////////////////////*ADMIN--COMMANDS*//////////////////////////////////
  392.  
  393.  
  394. CMD:setadmin(playerid, params[])
  395. {
  396.     new pID, value;
  397.     if(!IsPlayerAdmin(playerid)) return 0;
  398.     else if(sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, -1, "Usage: /setadmin (id) (level)");
  399.     else if(value < 0 || value > 5) return SendClientMessage(playerid, -1, "Only levels 0-5");
  400.     else if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Player Is Not Currently Connected");
  401.     else
  402.     {
  403.         new string[128], string1[128], target[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME];
  404.         GetPlayerName(playerid, pName, sizeof(pName));
  405.         GetPlayerName(pID, target, sizeof(target));
  406.         format(string, sizeof(string), "You have set %s Admin level to %i", target, value);
  407.         SendClientMessage(playerid, -1, string);
  408.         format(string, sizeof(string), "Your Admin level has been set to %i by %s", value, pName);
  409.         SendClientMessage(pID, -1, string1);
  410.         PlayerInfo[pID][pAdmin] = value;
  411.     }
  412.     return 1;
  413. }
  414.  
  415. CMD:kick(playerid,params[])
  416. {
  417.          new ID,gname[MAX_PLAYER_NAME],string[125],reason[70];
  418.          if(PlayerInfo[playerid][pAdmin] < 3 || (playerid)) return 0;
  419. // if(IsPlayerConnected(playerid) = asks if the player is connected
  420. // if(!IsPlayerConnected(playerid) = asks if the player isn't connected!
  421.          //using sscanf now
  422.          if(sscanf(params,"us[70]",ID,reason)) return SendClientMessage(playerid,-1," (ERROR) : /kick [playerid] [reason]"); //u parameter =  username/id[example:vassilis,1], "s" parameter = string[example : this is string]
  423.  
  424.  
  425.         GetPlayerName(ID,gname,sizeof(gname));
  426.         format(string, sizeof(string), "SERVER SYSTEM: %s has been kicked from the server Reason: %s", gname,reason);  //anouncing level %d = to get the admin level
  427.         SendClientMessageToAll( -1, string);
  428.  
  429.         Kick(ID); //kicking the second player!!
  430.         return 1; // to return that the command is valid
  431. } // closing bracket 1
  432.  
  433. CMD:ban(playerid, params[])
  434.     {
  435.         if(PlayerInfo[playerid][pAdmin] >= 5) {
  436.             new PID; //define the playerid we wanna ban
  437.             new reason[64]; //the reason, put into a string
  438.             new str[128]; //a new message string
  439.             new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
  440.             GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
  441.             GetPlayerName(PID, Playername, sizeof(Playername));
  442.             if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /kick [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)
  443.  
  444.             if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
  445.                 return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!");
  446.  
  447.             format(str, sizeof(str), "'%s' has been banned by administrator '%s'. Reason: %s ", Playername, Adminname, reason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names
  448.         SendClientMessageToAll(COLOR_RED, str); //send that message to all
  449.         Ban(PID); //Ban the playerid we've defined
  450.  
  451.         }
  452.         else //if he has not got the permissions
  453.         {
  454.             SendClientMessage(playerid, COLOR_GREY, "You have to be level 5 to use that command!"); //return this message
  455.         }
  456.         return 1;
  457. }
  458.    
  459. CMD:healme(playerid, params[])
  460. {
  461.         if(PlayerInfo[playerid][pAdmin] >= 5)
  462.         {
  463.             SetPlayerHealth(playerid, 100); //if he's allowed, restore his health
  464.             SendClientMessage(playerid, COLOR_GREY, "Health has been restored to 100."); // and send him the success-message
  465.         }
  466.         else
  467.         {
  468.             SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!"); // if not, send him only the following message
  469.         }
  470.         return 1;
  471. }
  472.  
  473.    
  474. COMMAND:clearchat(playerid,params[])
  475. {
  476.    if( PlayerInfo[ playerid ][ pAdmin ] < 1 ) return SendClientMessage( playerid, COLOR_RED, "ERROR: You must be level 1 to use this command!" );
  477. {
  478.      for( new i = 0; i <= 100; i ++ ) SendClientMessageToAll( COLOR_WHITE, "The chat has been cleared." );
  479. }   return 1;
  480. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement