Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is a comment
- // uncomment the line below if you want to write a filterscript
- //#define FILTERSCRIPT
- #include <a_samp>
- #include <YSI\y_ini>
- #include <zcmd>
- #include <sscanf2>
- //Dialog Defines//
- #define DIALOG_REGISTER 1
- #define DIALOG_LOGIN 2
- #define DIALOG_SUCCESS_1 3
- #define DIALOG_SUCCESS_2 4
- #define DIALOG_EMAIL 5
- #define DIALOG_CP1 6
- #define DIALOG_STATS 7
- //Color Defines//
- #define COL_WHITE "{FFFFFF}"
- #define COL_RED "{F81414}"
- #define COL_GREEN "{00FF22}"
- #define COL_LIGHTBLUE "{00CED1}"
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_YELLOW 0xFFFF00AA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_BLUE 0x0000BBAA
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COLOR_ORANGE 0xFF9900AA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_LIME 0x10F441AA
- #define COLOR_MAGENTA 0xFF00FFFF
- #define COLOR_NAVY 0x000080AA
- #define COLOR_AQUA 0xF0F8FFAA
- #define COLOR_CRIMSON 0xDC143CAA
- #define COLOR_FLBLUE 0x6495EDAA
- #define COLOR_BISQUE 0xFFE4C4AA
- #define COLOR_BLACK 0x000000AA
- #define COLOR_CHARTREUSE 0x7FFF00AA
- #define COLOR_BROWN 0XA52A2AAA
- #define COLOR_CORAL 0xFF7F50AA
- #define COLOR_GOLD 0xB8860BAA
- //Path Defines//
- #define PATH "/Users/%s.ini"
- //Enums//
- enum pInfo
- {
- pPass,
- pCash,
- pAdmin,
- pKills,
- pDeaths,
- pEmail,
- pCpUse
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- //news//
- new Name[MAX_PLAYER_NAME];
- new String[260];
- //Forwards//
- forward LoadUser_data(playerid,name[],value[]);
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Blank Filterscript by your name here");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- #else
- main()
- {
- print("\n----------------------------------");
- print(" Blank Gamemode by your name here");
- print("----------------------------------\n");
- }
- #endif
- public OnGameModeInit()
- {
- // Don't use these lines if it's a filterscript
- SetGameModeText("Blank Script");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- SetPlayerCameraPos(playerid, 2042.5273,-1195.7321,28.4404);
- SetPlayerCameraLookAt(playerid, 1959.6987,-1200.5483,27.2866);
- 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"..Register..",""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,"Admin",PlayerInfo[playerid][pAdmin]);
- INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
- INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
- INI_WriteInt(File,"pCpUse",PlayerInfo[playerid][pCpUse]);
- INI_Close(File);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- SetPlayerPos(playerid,1742.9871,-1860.6019,13.5785);
- SetPlayerFacingAngle(playerid,1742.8663);
- 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[])
- {
- return 0;
- }
- //Player Commands//
- COMMAND:cp(playerid,params[])
- {
- if(PlayerInfo[playerid][pCpUse] == 0)
- {
- SendClientMessage(playerid,COLOR_WHITE,"______________________________________________________________");
- SendClientMessage(playerid,COLOR_WHITE,"It seems that this is your first time using the {00CED1}CP.");
- SendClientMessage(playerid,COLOR_WHITE,"This is the control panel of your account.");
- SendClientMessage(playerid,COLOR_WHITE,"You can use it for different things.");
- SendClientMessage(playerid,COLOR_WHITE,"You can see your stats, change your name/password and more.");
- SendClientMessage(playerid,COLOR_WHITE,"______________________________________________________________");
- }
- ShowPlayerDialog(playerid,DIALOG_CP1,DIALOG_STYLE_LIST,"Control Panel","Stats\nChange Name\nReset Password","Ok","Cancel");
- GetPlayerName(playerid, Name, sizeof(Name));
- format(String,sizeof(String),"*%s is checking his {00CED1}CP",Name);
- SendClientMessageToAll(COLOR_WHITE,String);
- PlayerInfo[playerid][pCpUse] ++;
- return 1;
- }
- //Admin Commands//
- COMMAND:cvec(playerid,params[])
- {
- new vehid,Float:X,Float:Y,Float:Z;
- if(sscanf(params,"d",vehid)) return SendClientMessage(playerid,0xFFFFFFAA,"USAGE: /cvec [vehid]");
- GetPlayerPos(playerid,X,Y,Z);
- CreateVehicle(vehid,X,Y,Z,1,1,1,10000);
- return 1;
- }
- 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,"Admin",0);
- INI_WriteInt(File,"Kills",0);
- INI_WriteInt(File,"Deaths",0);
- INI_WriteInt(File,"pCpUse",0);
- INI_Close(File);
- ShowPlayerDialog(playerid,DIALOG_EMAIL, DIALOG_STYLE_INPUT,""COL_WHITE"Email",""COL_WHITE"Please fill in your email to activate your account.\nYour email will be privat and we will not use it.","Activate","Quit");
- }
- return 1; // added this return
- }
- 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_WHITE"You have {00FF22}successfully{FFFFFF} 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; // added this return
- }
- case DIALOG_EMAIL:
- {
- if (!response) return Kick(playerid);
- if(response)
- {
- if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, ""COL_WHITE"Email",""COL_RED"You have entered an invalid email.\n"COL_WHITE"Please fill in your email to activate your account.","Activate","Quit");
- new INI:File = INI_Open(UserPath(playerid));
- INI_WriteString(File,"Email",inputtext);
- INI_Close(File);
- ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_WHITE"You are {00FF22}successfully{FFFFFF} registered to our database","Ok","");
- }
- return 1;
- }
- case DIALOG_SUCCESS_2:
- {
- if(response)
- {
- SpawnPlayer(playerid);
- SendClientMessage(playerid,COLOR_WHITE,"________________________________________________________");
- SendClientMessage(playerid,COLOR_WHITE,"Welcome back to {00CED1} Servername.");
- SendClientMessage(playerid,COLOR_WHITE,"Mind your behaviour and follow our rules.");
- SendClientMessage(playerid,COLOR_WHITE,"You can read our rules at any time by typing {00CED1}/help.");
- SendClientMessage(playerid,COLOR_WHITE,"________________________________________________________");
- }
- return 1;
- }
- case DIALOG_SUCCESS_1:
- {
- if(response)
- {
- SpawnPlayer(playerid);
- SendClientMessage(playerid,COLOR_WHITE,"________________________________________________________");
- SendClientMessage(playerid,COLOR_WHITE,"Welcome to {00CED1} Servername.");
- SendClientMessage(playerid,COLOR_WHITE,"Since you're new, we strongly recommend you to read the rules.");
- SendClientMessage(playerid,COLOR_WHITE,"You can read our rules at any time by typing {00CED1}/help.");
- SendClientMessage(playerid,COLOR_WHITE,"________________________________________________________");
- }
- return 1;
- }
- case DIALOG_CP1:
- {
- if(response)
- {
- format(String,sizeof(String),"\nMoney: %d\nControl Panel Used: %d",PlayerInfo[playerid][pCash],PlayerInfo[playerid][pCpUse]);
- ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_MSGBOX,""COL_WHITE"Stats",String,"Ok","");
- }
- return 1;
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- //Non-Official publics//
- public LoadUser_data(playerid,name[],value[])
- {
- INI_Int("Password",PlayerInfo[playerid][pPass]);
- INI_Int("Cash",PlayerInfo[playerid][pCash]);
- INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
- INI_Int("Kills",PlayerInfo[playerid][pKills]);
- INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
- INI_Int("pCpUse",PlayerInfo[playerid][pCpUse]);
- return 1;
- }
- //Stocks//
- stock UserPath(playerid)
- {
- new string[128],playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid,playername,sizeof(playername));
- format(string,sizeof(string),PATH,playername);
- return string;
- }
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement