Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////////Script made by Escobar//////////////////////////////////
- #include <a_samp>
- #include <YSI\y_ini>
- #include <sscanf2>
- #include <zcmd>
- #define DIALOG_REGISTER 1
- #define DIALOG_LOGIN 2
- #define DIALOG_SUCCESS_1 3
- #define DIALOG_SUCCESS_2 4
- #define PATH "/users/%s.ini"
- #define COL_WHITE "{FFFFFF}"
- #define COL_RED "{F81414}"
- #define COL_GREEN "{00FF22}"
- #define COL_LIGHTBLUE "{00CED1}"
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_WHITE 0xFFFFFFAA
- enum pInfo
- {
- pPass,
- pCash,
- pAdmin,
- pKills,
- pDeaths,
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- forward LoadUser_data(playerid,name[],value[]);
- public LoadUser_data(playerid,name[],value[])
- {
- INI_Int("Password",PlayerInfo[playerid][pPass]);
- INI_Int("Cash",PlayerInfo[playerid][pCash]);
- INI_Int("Kills",PlayerInfo[playerid][pKills]);
- INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
- INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
- return 1;
- }
- stock UserPath(playerid)
- {
- new string[128],playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid,playername,sizeof(playername));
- format(string,sizeof(string),PATH,playername);
- return string;
- }
- /*Credits to Dracoblue*/
- stock udb_hash(buf[]) {
- new length=strlen(buf);
- new s1 = 1;
- new s2 = 0;
- new n;
- for (n=0; n<length; n++)
- {
- s1 = (s1 + buf[n]) % 65521;
- s2 = (s2 + s1) % 65521;
- }
- return (s2 << 16) + s1;
- }
- main()
- {
- print("\n----------------------------------");
- print(" Escobar's DM Loaded");
- print("----------------------------------\n");
- }
- public OnGameModeInit()
- {
- ///////////////////////////////////////////////////////
- // Don't use these lines if it's a filterscript
- SetGameModeText("E:DM V1.0.0");
- AddPlayerClass(31,-373.4418,2195.7175,42.0807,15.0124,6,1,26,100,33,100);
- AddPlayerClass(32,-389.4026,2261.2319,41.8178,195.4941,6,1,26,100,33,100);
- AddPlayerClass(33,-350.2201,2240.5601,42.4844,96.1664,6,1,26,100,33,100);
- AddPlayerClass(34,-440.3142,2229.3542,42.4297,269.7546,6,1,26,100,33,100);
- AddPlayerClass(128,-350.2201,2240.5601,42.4844,96.1664,6,1,26,100,33,100);
- AddPlayerClass(129,-373.4418,2195.7175,42.0807,15.0124,6,1,26,100,33,100);
- AddPlayerClass(130,-440.3142,2229.3542,42.4297,269.7546,6,1,26,100,33,100);
- AddPlayerClass(131,-350.2201,2240.5601,42.4844,96.1664,6,1,26,100,33,100);
- AddPlayerClass(132,-373.4418,2195.7175,42.0807,15.0124,6,1,26,100,33,100);
- AddPlayerClass(133,-440.3142,2229.3542,42.4297,269.7546,6,1,26,100,33,100);
- AddPlayerClass(157,-350.2201,2240.5601,42.4844,96.1664,6,1,26,100,33,100);
- AddPlayerClass(158,-373.4418,2195.7175,42.0807,15.0124,6,1,26,100,33,100);
- AddPlayerClass(159,-440.3142,2229.3542,42.4297,269.7546,6,1,26,100,33,100);
- AddPlayerClass(160,-350.2201,2240.5601,42.4844,96.1664,6,1,26,100,33,100);
- AddPlayerClass(161,-373.4418,2195.7175,42.0807,15.0124,6,1,26,100,33,100);
- AddPlayerClass(162,-440.3142,2229.3542,42.4297,269.7546,6,1,26,100,33,100);
- AddPlayerClass(196,-373.4418,2195.7175,42.0807,15.0124,6,1,26,100,33,100);
- AddPlayerClass(197,-440.3142,2229.3542,42.4297,269.7546,6,1,26,100,33,100);
- AddPlayerClass(198,-373.4418,2195.7175,42.0807,15.0124,6,1,26,100,33,100);
- AddPlayerClass(199,-350.2201,2240.5601,42.4844,96.1664,6,1,26,100,33,100);
- AddPlayerClass(200,-440.3142,2229.3542,42.4297,269.7546,6,1,26,100,33,100);
- AddPlayerClass(201,-373.4418,2195.7175,42.0807,15.0124,6,1,26,100,33,100);
- AddPlayerClass(202,-389.4026,2261.2319,41.8178,195.4941,6,1,26,100,33,100);
- //////////////////////////////////////////////////////////////////////////
- AddStaticVehicleEx (520, 2109.1763, 1503.0453, 32.2887, 82.2873, -1, -1, 15);
- AddStaticVehicleEx (519,1328.6196,1612.2500,11.7437,270.0001,1,1, 15);
- AddStaticVehicleEx (593,1352.1102,1779.0000,11.2880,270.0000,2,1, 15);
- AddStaticVehicleEx (593,1352.1116,1801.5000,11.2863,269.9999,36,8, 15);
- AddStaticVehicleEx (522,1676.4335,1322.1592,10.3320,87.7189,7,79, 15);
- AddStaticVehicleEx (417,1286.8724,1449.6250,10.8722,270.0000,0,0, 15);
- AddStaticVehicleEx (553,1571.4385,1487.7513,12.1685,311.1577,71,87, 15);
- AddStaticVehicleEx (553,1597.4109,1342.6935,12.1865,344.8449,71,87, 15);
- AddStaticVehicleEx (487,1655.0576,1554.5649,10.9879,64.4211,26,3, 15);
- AddStaticVehicleEx (487,1397.5690,1770.0475,10.9971,269.3060,26,3, 15);
- AddStaticVehicleEx (487,1618.4143,1357.5428,10.9893,169.4555,26,3, 15);
- AddStaticVehicleEx (469,1358.1189,1253.5436,10.8285,358.5788,1,3, 15);
- AddStaticVehicleEx (609,1341.5886,1729.4564,10.8864,91.6428,36,36, 15);
- AddStaticVehicleEx (519,1303.7971,1360.9348,11.7405,267.7907,1,1, 15);
- AddStaticVehicleEx (511,1341.3031,1682.6432,12.1967,268.5870,3,90, 15);
- AddStaticVehicleEx (512,1326.1611,1420.4333,11.1030,178.1441,17,39, 15);
- AddStaticVehicleEx (513,1280.1281,1411.8032,11.3653,223.4432,48,18, 15);
- AddStaticVehicleEx (515,1573.4801,1654.4058,11.8422,91.4976,24,77, 15);
- AddStaticVehicleEx (404,1309.7848,1279.5735,10.5544,359.2681,101,101, 15);
- AddStaticVehicleEx (411,1682.5769,1316.6561,10.5474,358.3994,123,1, 15);
- AddStaticVehicleEx (436,1663.4026,1297.1321,10.5877,359.4867,83,1, 15);
- AddStaticVehicleEx (439,1642.0035,1293.2332,10.7156,268.6615,54,38, 15);
- AddStaticVehicleEx (462,1713.8118,1319.2559,10.4165,268.4222,2,1, 15);
- AddStaticVehicleEx (474,1695.4330,1306.1843,10.5853,179.3891,110,1, 15);
- AddStaticVehicleEx (480,1682.4532,1286.9058,10.5945,179.2040,6,6, 15);
- AddStaticVehicleEx (420,1723.8730,1501.4979,10.5187,167.0140,6,1, 15);
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, -373.4418,2195.7175,42.0807);
- SetPlayerCameraPos(playerid, -373.4418,2195.7175,42.0807);
- SetPlayerCameraLookAt(playerid, -373.4418,2195.7175,42.0807);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- if(fexist(UserPath(playerid)))
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"data");
- INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
- INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
- INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
- INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
- INI_Close(File);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- PlayerInfo[killerid][pKills]++;
- PlayerInfo[playerid][pDeaths]++;
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/mycommand", cmdtext, true, 10) == 0)
- {
- // Do something here
- return 1;
- }
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch( dialogid )
- {
- case DIALOG_REGISTER:
- {
- if (!response) return Kick(playerid);
- if(response)
- {
- 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");
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"data");
- INI_WriteInt(File,"Password",udb_hash(inputtext));
- INI_WriteInt(File,"Cash",0);
- INI_WriteInt(File,"Kills",0);
- INI_WriteInt(File,"Deaths",0);
- INI_Close(File);
- SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
- SpawnPlayer(playerid);
- ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Thanks! You are registered at, "COL_LIGHTBLUE"YOUR_SERVER","Ok","");
- }
- }
- case DIALOG_LOGIN:
- {
- if ( !response ) return Kick ( playerid );
- if( response )
- {
- if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
- ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
- }
- else
- {
- 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");
- }
- return 1;
- }
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- //////////////////////////////////*ADMIN--COMMANDS*//////////////////////////////////
- CMD:setadmin(playerid, params[])
- {
- new pID, value;
- if(!IsPlayerAdmin(playerid)) return 0;
- else if(sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, -1, "Usage: /setadmin (id) (level)");
- else if(value < 0 || value > 5) return SendClientMessage(playerid, -1, "Only levels 0-5");
- else if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Player Is Not Currently Connected");
- else
- {
- new string[128], string1[128], target[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pName, sizeof(pName));
- GetPlayerName(pID, target, sizeof(target));
- format(string, sizeof(string), "You have set %s Admin level to %i", target, value);
- SendClientMessage(playerid, -1, string);
- format(string, sizeof(string), "Your Admin level has been set to %i by %s", value, pName);
- SendClientMessage(pID, -1, string1);
- PlayerInfo[pID][pAdmin] = value;
- }
- return 1;
- }
- CMD:kick(playerid,params[])
- {
- new ID,gname[MAX_PLAYER_NAME],string[125],reason[70];
- if(PlayerInfo[playerid][pAdmin] < 3 || (playerid)) return 0;
- // if(IsPlayerConnected(playerid) = asks if the player is connected
- // if(!IsPlayerConnected(playerid) = asks if the player isn't connected!
- //using sscanf now
- 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]
- GetPlayerName(ID,gname,sizeof(gname));
- 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
- SendClientMessageToAll( -1, string);
- Kick(ID); //kicking the second player!!
- return 1; // to return that the command is valid
- } // closing bracket 1
- CMD:ban(playerid, params[])
- {
- if(PlayerInfo[playerid][pAdmin] >= 5) {
- new PID; //define the playerid we wanna ban
- new reason[64]; //the reason, put into a string
- new str[128]; //a new message string
- new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
- GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
- GetPlayerName(PID, Playername, sizeof(Playername));
- 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)
- if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
- return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!");
- 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
- SendClientMessageToAll(COLOR_RED, str); //send that message to all
- Ban(PID); //Ban the playerid we've defined
- }
- else //if he has not got the permissions
- {
- SendClientMessage(playerid, COLOR_GREY, "You have to be level 5 to use that command!"); //return this message
- }
- return 1;
- }
- CMD:healme(playerid, params[])
- {
- if(PlayerInfo[playerid][pAdmin] >= 5)
- {
- SetPlayerHealth(playerid, 100); //if he's allowed, restore his health
- SendClientMessage(playerid, COLOR_GREY, "Health has been restored to 100."); // and send him the success-message
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!"); // if not, send him only the following message
- }
- return 1;
- }
- COMMAND:clearchat(playerid,params[])
- {
- if( PlayerInfo[ playerid ][ pAdmin ] < 1 ) return SendClientMessage( playerid, COLOR_RED, "ERROR: You must be level 1 to use this command!" );
- {
- for( new i = 0; i <= 100; i ++ ) SendClientMessageToAll( COLOR_WHITE, "The chat has been cleared." );
- } return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement