Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=========================================================================================================================================//
- //===|INCLUDE|===
- #include <a_samp>
- #include <dini>
- //===|DEFINE|===
- #define COLOR_ORANGE 0xffcc00FF
- #define COLOR_GRAD1 0xB4B5B7FF
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_BASIC 0x0066FFAA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_RED 0xAA3333AA
- #define COLOR_YELLOW 0xFFFF00AA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_LIGHTBLUE 0x6DC5F3FF
- #define COLOR_BLACK 0x000000FF
- //Chat
- #define COLOR_FADE1 0xFFFFFFFF
- #define COLOR_FADE2 0xC8C8C8C8
- #define COLOR_FADE3 0xAAAAAAAA
- #define COLOR_FADE4 0x8C8C8C8C
- #define COLOR_FADE5 0x6E6E6E6E
- #define SERVER_USER_FILE "SERVER/Accounts/%s.ini"
- //===|ENUM|===
- enum pInfo
- {
- pAdminLevel,
- pCash,
- pSkin,
- }
- //===|NEW|===
- new PlayerInfo[MAX_PLAYERS][pInfo];
- new gPlayerLogged[MAX_PLAYERS];
- new gLoginAttempts[MAX_PLAYERS];
- new timer[MAX_PLAYERS];
- //==============================================================================//
- //==============================================================================//
- main()
- {
- print("\n----------------------------------");
- print(" Mod je uspjesno ucitan. ");
- print("----------------------------------\n");
- }
- //==============================================================================//
- public OnGameModeInit()
- {
- SetGameModeText("1.0.0|By Notix");
- ShowPlayerMarkers(PLAYER_MARKERS_MODE_GLOBAL);
- ShowNameTags(1);
- SetNameTagDrawDistance(30.0);
- EnableStuntBonusForAll(0);
- DisableInteriorEnterExits();
- SetWeather(1);
- SetWorldTime(11);
- UsePlayerPedAnims();
- ShowPlayerMarkers(0);
- AddPlayerClass(0,1240.5282,-1639.7385,13.5469,86.2016,0,0,0,0,0,0); //Civilian Spawn
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- if(PlayerInfo[playerid][pSkin] != 0)
- {
- return SpawnPlayer(playerid);
- }
- SetPlayerPos(playerid, 2426.8420, 1821.9703, 16.3222);
- SetPlayerCameraPos(playerid, 2422.4617, 1821.9310, 17.2204);
- SetPlayerCameraLookAt(playerid, 2426.8420, 1821.9703, 16.3222);
- SetPlayerFacingAngle(playerid, 92.0174);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- gPlayerLogged[playerid] = 0;
- new name[MAX_PLAYER_NAME], file[256];
- GetPlayerName(playerid, name, sizeof(name));
- format(file, sizeof(file), SERVER_USER_FILE, name);
- if (!dini_Exists(file))
- {
- ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{0x33AA33AAA}REGISTER", "Vas profil nije registriran,unesite zeljenu lozinku da se registrirate", "{0x33AA33AAA}Register", "Quit");
- }
- if(fexist(file))
- {
- ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Account is registered!", "This account is registered, please your password to login!", "Enter", "Quit");
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if (dialogid == 1)
- {
- new name[MAX_PLAYER_NAME], file[256];
- GetPlayerName(playerid, name, sizeof(name));
- format(file, sizeof(file), SERVER_USER_FILE, name);
- if(!response) return Kick(playerid);
- if (!strlen(inputtext)) return
- ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Account not found!", "This account has not been registered yet, please enter a password below to register it:", "Register", "Quit");
- dini_Create(file);
- dini_IntSet(file, "Password", udb_hash(inputtext));
- dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
- dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 10000);
- dini_IntSet(file, "Skin",PlayerInfo[playerid][pSkin] = 0);
- dini_FloatSet(file, "Health", 100);
- dini_FloatSet(file, "Armour", 0);
- gPlayerLogged[playerid] = 1;
- }
- if (dialogid == 2)
- {
- new name[MAX_PLAYER_NAME], file[256];
- GetPlayerName(playerid, name, sizeof(name));
- format(file, sizeof(file), SERVER_USER_FILE, name);
- if(!response) return Kick(playerid);
- if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Account is registered!", "This account is registered, please your password to login!", "Enter", "Quit");
- new tmp;
- tmp = dini_Int(file, "Password");
- if(udb_hash(inputtext) != tmp) {
- if(gLoginAttempts[playerid] > 1)
- {
- gLoginAttempts[playerid] = 0;
- return Kick(playerid);
- }
- else
- {
- new string[128];
- format(string, sizeof(string), "You have entered an incorrect password, you have %i attempts left before you get kicked.", 2 - gLoginAttempts[playerid]);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- gLoginAttempts[playerid]++;
- ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Account is registered!", "This account is registered, please your password to login!", "Enter", "Quit");
- }
- }
- else
- {
- gPlayerLogged[playerid] = 1;
- timer[playerid] = SetTimerEx("SavePlayer", 30000, true, "i", playerid);
- PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
- PlayerInfo[playerid][pSkin] = dini_Int(file, "Skin");
- PlayerInfo[playerid][pCash] = dini_Int(file, "Money");
- }
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new name[MAX_PLAYER_NAME], file[256];
- GetPlayerName(playerid, name, sizeof(name));
- format(file, sizeof(file), SERVER_USER_FILE, name);
- if(gPlayerLogged[playerid] == 1)
- {
- SavePlayer(playerid);
- }
- KillTimer(timer[playerid]);
- gPlayerLogged[playerid] = 0;
- 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[])
- {
- new pname[MAX_PLAYER_NAME], str[128];
- GetPlayerName(playerid, pname, sizeof(pname));
- strreplace(pname, '_', ' ');
- format(str, sizeof(str), "%s kaze: %s", pname, text);
- ProxDetector(30.0, playerid, str, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
- return 0;
- }
- 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 OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
- {
- if(IsPlayerConnected(playerid))
- {
- new Float:posx, Float:posy, Float:posz;
- new Float:oldposx, Float:oldposy, Float:oldposz;
- new Float:tempposx, Float:tempposy, Float:tempposz;
- GetPlayerPos(playerid, oldposx, oldposy, oldposz);
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- GetPlayerPos(i, posx, posy, posz);
- tempposx = (oldposx -posx);
- tempposy = (oldposy -posy);
- tempposz = (oldposz -posz);
- if(GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
- {
- if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
- {
- SendClientMessage(i, col1, string);
- }
- else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
- {
- SendClientMessage(i, col2, string);
- }
- else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
- {
- SendClientMessage(i, col3, string);
- }
- else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
- {
- SendClientMessage(i, col4, string);
- }
- else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
- {
- SendClientMessage(i, col5, string);
- }
- }
- }
- }
- }
- return 1;
- }
- //
- 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;
- }
- forward SavePlayer(playerid);
- public SavePlayer(playerid)
- {
- new name[MAX_PLAYER_NAME], file[256];
- GetPlayerName(playerid, name, sizeof(name));
- format(file, sizeof(file), SERVER_USER_FILE, name);
- if(gPlayerLogged[playerid] == 1)
- {
- new Float:x, Float:y, Float:z, Float:angle, Float:health, Float:armour, playerskin;
- GetPlayerPos(playerid, x, y, z);
- GetPlayerHealth(playerid,health);
- GetPlayerArmour(playerid, armour);
- GetPlayerFacingAngle(playerid, angle);
- dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
- dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][pAdminLevel]);
- dini_FloatSet(file, "Health",health);
- dini_FloatSet(file, "Armour",armour);
- playerskin = GetPlayerSkin(playerid);
- dini_IntSet(file, "Skin", playerskin);
- return 1;
- }
- gPlayerLogged[playerid] = 0;
- return 0;
- }
- stock SetPlayerMoney(playerid, cash)
- {
- ResetPlayerMoney(playerid);
- return GivePlayerMoney(playerid, cash);
- }
- stock strreplace(string[], find, replace)
- {
- for(new i=0; string[i]; i++)
- {
- if(string[i] == find)
- {
- string[i] = replace;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment