Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //============================================================================//
- // Basic GameMode Script //
- //----------------------------------------------------------------------------//
- // By SaNeLSANY //
- //============================================================================//
- //============================================================================// INCLUDE
- #include <a_samp>
- #include <sscanf2>
- #include <streamer>
- #include <YSI\y_ini>
- #include <zcmd>
- #include <foreach>
- //============================================================================//
- //============================================================================// DEFINE
- // COLORS
- #define COLOR_PINK 0xFFC0CBFF
- #define COLOR_RED 0xFF0000FF
- #define COLOR_GREEN 0x008000FF
- #define COLOR_DARKBLUE 0x00008BFF
- #define COLOR_CADETBLUE 0x5F9EA0FF
- #define COLOR_LIGHTBLUE 0xADD8E6FF
- #define COLOR_YELLOW 0xECD400F6
- #define COLOR_LIGHTGREEN 0x90EE90FF
- #define COLOR_PEACHPUFF 0xFFDAB9FF
- #define LIGHTBLUE2 0xF6BB0AA
- #define COLOR_GREY 0x808080FF
- #define COLOR_ORANGE 0xFFA500FF
- #define COLOR_BISQUE 0xFFE4C4FF
- #define COLOR_BLANCHEDALMOND 0xFFEBCDFF
- #define COLOR_BLACK 0x000000AA
- #define CYELLOW "{9DBD1E}"
- #define CORANGE "{E68C0E}"
- #define CBLUE "{39AACC}"
- #define CLGREEN "{30DB52}"
- #define CDGREEN "{6FA828}"
- #define CWHITE "{FFFFFF}"
- #define CREDISH "{CF0C43}"
- #define CRED "{FF0000}"
- #define CLBLUE "{55C2CF}"
- #define CCADET "{5F9EA0}"
- #define CPINK "{FC08CB}"
- #define CDBLUE "{1500FF}"
- #define CAQUA "{5CFFE9}"
- #define CGREY "{7D8584}"
- #define CMAROON "{912514}"
- #define CCORAL "{FF7F50}"
- #define CRACE "{F2DDC4}"
- #define CRACE2 "{2CC900}"
- #define CGAME1 "{E8DB20}"
- #define CGAME2 "{BA80BA}"
- #define CMINIG1 "{648832}"
- #define CMINIG2 "{4F927F}"
- // DIALOGS
- #define DIALOG_REGISTER 0
- #define DIALOG_LOGIN 1
- // OTHER
- #define SCM SendClientMessage
- #define USER_PATH "/Players/%s.ini"
- #define INI_Exists(%0) fexist(%0)
- //============================================================================//
- //============================================================================// NEW
- //============================================================================//
- //============================================================================// FORWARD
- //============================================================================//
- //============================================================================// ENUM
- enum pInfo
- {
- pPassword[124],
- pKills,
- pDeaths,
- pAdmin,
- pLevel,
- pSkin,
- pMoney,
- pLogged
- };
- new PlayerInfo[MAX_PLAYERS][pInfo];
- //============================================================================//
- main()
- {
- print("\n----------------------------------");
- print(" Blank GameMode Script By SaNeLSANY ");
- print("----------------------------------\n");
- }
- public OnGameModeInit()
- {
- UsePlayerPedAnims();
- SetGameModeText("| Blank GameMode |");
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- PlayerInfo[playerid][pLogged] = 0;
- new text[1024], strText[104];
- format(strText, 35, USER_PATH, PlayerName(playerid));
- if(!INI_Exists(strText))
- {
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""#CCADET"Account Registration", ""CYELLOW"Hello! "CBLUE"You must register to play on this server!", "Register", "Leave");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- }
- else
- {
- format(text, sizeof(text)," {0095FF}________________________________________________\n\n{FFFFFF}Welcome to {0095FF}Basic GameMode {FFFFFF}server!\n\n\n{0095FF}%s\n{FFFFFF}Your Account are finded\n\n\nPlease enter your password to enter to this server:\n\n{0095FF}________________________________________________", PlayerName(playerid));
- ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT, "Login",text, "Logiraj","Odustani");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- SCM(playerid, COLOR_BLACK, "");
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(PlayerInfo[playerid][pLogged] == 1)
- {
- SavePlayer(playerid);
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- 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)
- {
- if(PlayerInfo[playerid][pLogged] == 0)
- {
- SCM(playerid,COLOR_RED,"You must be logged in before spawn");
- SetTimerEx("KickPlayer", 300, 0, "d", 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[])
- {
- if(dialogid == DIALOG_REGISTER)
- {
- if(!response)
- {
- SCM(playerid, COLOR_LIGHTBLUE, "Hey you, you must register to play on this server !");
- SetTimerEx("KickPlayer", 300, 0, "d", playerid);
- return 1;
- }
- if(response)
- {
- if(!strlen(inputtext))
- {
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""#CCADET"Account Registration", ""CYELLOW"You must enter a password below to continue!", "Register", "Leave");
- return 1;
- }
- SCM(playerid, COLOR_GREEN, "All right, you are now registered!");
- new uFile[35];
- format(uFile, 35, USER_PATH, PlayerName(playerid));
- new INI:playerFile = INI_Open(uFile);
- INI_WriteInt(playerFile,"Password",udb_hash(inputtext));
- INI_WriteInt(playerFile, "AdminLVL", PlayerInfo[playerid][pAdmin]);
- INI_WriteInt(playerFile, "Money", PlayerInfo[playerid][pMoney]);
- INI_WriteInt(playerFile, "Level", PlayerInfo[playerid][pLevel]);
- INI_WriteInt(playerFile, "Skin", PlayerInfo[playerid][pSkin]);
- INI_Close(playerFile);
- PlayerInfo[playerid][pLevel] = 3;
- PlayerInfo[playerid][pLogged] = 1;
- PlayerInfo[playerid][pMoney] = 1000;
- GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
- SetPlayerSkin(playerid, 1);
- SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
- SetSpawnInfo(playerid, 0,PlayerInfo[playerid][pSkin], 1154.0653,-1458.0643,15.7969, 0,0,0,0,0,0,0);
- SpawnPlayer(playerid);
- }
- }
- if(dialogid == DIALOG_LOGIN)
- {
- if(!response)
- {
- SCM(playerid, COLOR_LIGHTBLUE, "Hey you, you must LogIn to play on this server !");
- SetTimerEx("KickPlayer", 300, 0, "d", playerid);
- return 1;
- }
- if(response)
- {
- new uFile[35];
- format(uFile, 35, USER_PATH, PlayerName(playerid));
- INI_ParseFile(uFile, "LoadUserData", .bExtra = true, .extra = playerid);
- if(udb_hash(inputtext) == PlayerInfo[playerid][pPassword])
- {
- new coordsstring[124];
- format(uFile, 35, USER_PATH, PlayerName(playerid));
- INI_ParseFile(uFile, "LoadUserData", .bExtra = true, .extra = playerid);
- format(coordsstring, sizeof(coordsstring), "*Welcome %s on the server",PlayerName(playerid));
- SCM(playerid, 0x33CCFFAA,coordsstring);
- format(coordsstring,sizeof coordsstring,"~n~~n~~n~~n~~n~~n~~w~WELCOME~n~~r~%s!",PlayerName(playerid));
- GameTextForPlayer(playerid, coordsstring, 6000, 3);
- SetPlayerColor(playerid,0xFFFFFFFF);
- PlayerInfo[playerid][pLogged] = 1;
- SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
- GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
- SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
- SetSpawnInfo(playerid, 0,PlayerInfo[playerid][pSkin], 1154.0653,-1458.0643,15.7969, 0,0,0,0,0,0,0);
- SpawnPlayer(playerid);
- }
- else
- {
- ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT, "Login","Wrong password", "Logiraj","Odustani");
- }
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- //============================================================================//
- forward LoadUserData(playerid, name[], value[]);
- public LoadUserData(playerid, name[], value[])
- {
- INI_Int("Password",PlayerInfo[playerid][pPassword]);
- INI_Int("Level",PlayerInfo[playerid][pLevel]);
- INI_Int("Money",PlayerInfo[playerid][pMoney]);
- INI_Int("AdminLVL",PlayerInfo[playerid][pAdmin]);
- INI_Int("Skin",PlayerInfo[playerid][pSkin]);
- return 1;
- }
- forward KickPlayer(playerid);
- public KickPlayer(playerid)
- {
- Kick(playerid);
- }
- //============================================================================// STOCKS
- stock SavePlayer(playerid)
- {
- new uFile[35];
- format(uFile, 35, USER_PATH, PlayerName(playerid));
- new INI:playerFile = INI_Open(uFile);
- INI_WriteInt(playerFile, "AdminLVL", PlayerInfo[playerid][pAdmin]);
- INI_WriteInt(playerFile, "Money", PlayerInfo[playerid][pMoney]);
- INI_WriteInt(playerFile, "Level", PlayerInfo[playerid][pLevel]);
- INI_WriteInt(playerFile, "Skin", PlayerInfo[playerid][pSkin]);
- INI_Close(playerFile);
- 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;
- }
- stock PlayerName(playerid)
- {
- new pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
- return pName;
- }
- 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