Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma unused ret_memcpy
- #include <a_samp>
- #include <dini>
- #include <dudb>
- #include <color>
- #define SERVER_USER_FILE "%s.ini"
- new Float:positionx;
- new Float:positiony;
- new Float:positionz;
- enum pInfo
- {
- pAdminLevel,
- pCash,
- pScore,
- pBank,
- pMaterials,
- pMaraj,
- pPackages,
- pProducts,
- pJobLevel,
- pAmmoPackage,
- pNumber,
- pBizzName,
- pYCord,
- pXCord,
- pZCord,
- pHEntrance,
- pBizzEntrance,
- pBizzStatus,
- pSkinID,
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- new gPlayerLogged[MAX_PLAYERS];
- public OnGameModeInit()
- {
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- }
- public OnPlayerConnect(playerid)
- {
- TogglePlayerSpectating(playerid, 1);
- 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, "Hey newbie, welcome", "Register with your password below (DO NOT SHARE THIS)", "Register", "Leave");
- }
- if(fexist(file))
- {
- ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "That user is already in our database.", "Thanks for coming back. Enter your password below.", "Login", "Leave");
- }
- 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)
- {
- dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
- dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
- dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel]);
- dini_IntSet(file, "Bank",PlayerInfo[playerid][pBank]);
- dini_IntSet(file, "Materials",PlayerInfo[playerid][pMaterials]);
- dini_IntSet(file, "AmmoPackage",PlayerInfo[playerid][pAmmoPackage]);
- dini_IntSet(file, "Maraj",PlayerInfo[playerid][pMaraj]);
- dini_IntSet(file, "Products",PlayerInfo[playerid][pProducts]);
- dini_IntSet(file, "PositionX", floatround(positionx));
- dini_IntSet(file, "PositionY", floatround(positiony));
- dini_IntSet(file, "PositionZ", floatround(positionz));
- dini_IntSet(file, "HEntrance",PlayerInfo[playerid][pHEntrance]);
- dini_IntSet(file, "JobLevel",PlayerInfo[playerid][pJobLevel]);
- dini_IntSet(file, "Packages",PlayerInfo[playerid][pPackages]);
- }
- gPlayerLogged[playerid] = 0;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- SetPlayerPos(playerid,PlayerInfo[playerid][positionx],PlayerInfo[playerid][positiony],PlayerInfo[playerid][positionz]);
- 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 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)
- {
- SpawnPlayer(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 == 1)
- {
- new name[MAX_PLAYER_NAME], file[256], string[128];
- 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, "Hi your not registered", "Welcome, your not registered mate, input your registration pw below", "Register", "Leave");
- 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, "Bank",PlayerInfo[playerid][pBank] = 20000);
- dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
- dini_IntSet(file, "PositionX",playerid,positionx = -1420.21);
- dini_IntSet(file, "PositionY",playerid,positiony = 2599.45);
- dini_IntSet(file, "PositionZ",playerid,positionz = 56.43);
- format(string, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext);
- SendClientMessage(playerid, _COLOR_GREEN, string);
- SpawnPlayer(playerid);
- gPlayerLogged[playerid] = 1;
- }
- if (dialogid == 2)
- {
- new name[MAX_PLAYER_NAME], file[256], string[128];
- 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, "Hi your registered", "Fucken awesome mate, your registered :D. Inpute your pw below", "Login", "Leave");
- new tmp;
- tmp = dini_Int(file, "Password");
- if(udb_hash(inputtext) != tmp) {
- SendClientMessage(playerid, _COLOR_GREEN, "Wrong Password.");
- ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Error", "Wrong password. Are you a hacker? I hope not, or I fucks you up.", "Login", "Leave");
- }
- else
- {
- gPlayerLogged[playerid] = 1;
- PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
- SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
- GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
- SendClientMessage(playerid, _COLOR_GREEN, "[SYSTEM]: Successfully logged in!");
- SpawnPlayer(playerid);
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement