- /*
- * __ __ ________ __ ______ ______
- * | |/ | | | |__| __ \ __ \
- * | <| | | |__| < __/
- * |__|\__|________|__|___|__|___|
- * Keywork Roleplay
- * v0.0.1
- */
- // [ Main Includes ]
- #include <a_samp>
- #include <a_mysql>
- #include <zcmd>
- #include <Encrypt>
- #include <sscanf2>
- // [ Main Includes ]
- // [ Server Info ]
- #define SERVER_VERSION "v0.01"
- #define SERVER_LASTUPDATED "30/06/2012"
- #define SQL_HOST "127.0.0.1"
- #define SQL_USER "samp"
- #define SQL_PASS "#############"
- #define SQL_DB "samp"
- // [ Server Info ]
- // [ Colors ]
- #define COLOR_WHITE 0xFFFFFFFF
- #define COLOR_RED 0xFF0000FF
- #define COLOR_GREEN 0x00FF00FF
- #define COLOR_BLUE 0x0000FFFF
- #define COLOR_YELLOW 0xFFFF00FF
- #define COLOR_PURPLE 0xFF00FFFF
- #define COLOR_TEAL 0x00FFFFFF
- #define COLOR_ADMIN 0x58C6E8FF
- // new special colours
- #define COL_WHITE "{FFFFFF}"
- #define COL_RED "{FF0000}"
- #define COL_GREEN "{00FF00}"
- #define COL_BLUE "{0000FF}"
- #define COL_YELLOW "{FFFF00}"
- #define COL_PURPLE "{00FFFF}"
- #define COL_ADMIN "{58C6E8}"
- // [ Colors ]
- // [ Dialogs ]
- #define DIALOG_REGISTER 0
- #define DIALOG_LOGIN 1
- #define DIALOG_SET_ADMIN_NAME 2
- #define DIALOG_TUTORIAL1 3
- #define DIALOG_TUTORIAL2 4
- #define DIALOG_TUTORIAL3 5
- #define DIALOG_TUTORIAL4 6
- #define DIALOG_TUTORIAL5 7
- #define DIALOG_CCREATION1 8
- #define DIALOG_CCREATION2 9
- #define DIALOG_CCREATION3 10
- #define DIALOG_CCREATION4 11
- #define DIALOG_CCREATION5 12
- #define DIALOG_CCREATION6 13
- // [ Dialogs ]
- // [ Player Enum ]
- enum pInfo
- {
- pId, // active session id
- pName[MAX_PLAYER_NAME], // with_underscores
- pRPName[MAX_PLAYER_NAME], // without underscores
- pLogged, // whether or not the player is logged
- pIp[15], // active session IP
- pAccountType, // 0 if player, 1 if admin
- pAdminLevel,
- pNew, // 1 if player is new
- Float:pX,
- Float:pY,
- Float:pZ,
- Float:pAngle,
- Float:pHealth,
- Float:pArmour,
- pMoney,
- pSkin,
- pAge,
- pGender,
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- // [ Player Enum ]
- // [ Forward Declarations ]
- forward ConnectMySQL();
- forward LoadPlayer(playerid);
- forward SavePlayer(playerid);
- forward ServerRestart();
- // [ Forward Declarations ]
- main()
- {
- print("\n");
- print(" __ __ ________ __ ______ ______");
- print(" | |/ | | | |__| __ \\ __ \\");
- print(" | <| | | |__| < __/");
- print(" |__|\\__|________|__|___|__|___|");
- print(" Keywork Roleplay");
- new buf[20];
- format(buf, sizeof(buf), " %s", SERVER_VERSION);
- print(" v0.0.1");
- print("\n");
- return 1;
- }
- public OnGameModeInit()
- {
- new gm[20];
- format(gm, sizeof(gm), "KW:RP %s", SERVER_VERSION);
- SetGameModeText(gm);
- new mysql = ConnectMySQL();
- if (mysql == 0)
- {
- print("Failed to make a MySQL connection.");
- return 0;
- }
- DisableInteriorEnterExits();
- ShowPlayerMarkers(0);
- EnableStuntBonusForAll(0);
- UsePlayerPedAnims();
- CreateObject(16400,-2464.60009766,2225.30004883,3.79999995,0.00000000,0.00000000,270.00000000); //taxi company hq
- CreateObject(994,-2280.30004883,2279.00000000,4.00000000,0.00000000,0.00000000,0.00000000); //sasd parking barrier(1)
- CreateObject(994,-2273.80004883,2279.00000000,4.00000000,0.00000000,0.00000000,0.00000000); //sasd parking barrier(2)
- CreateObject(994,-2267.30004883,2279.00000000,4.00000000,0.00000000,0.00000000,0.00000000); //sasd parking barrier(3)
- CreateObject(994,-2260.69995117,2279.00000000,4.00000000,0.00000000,0.00000000,0.00000000); //sasd parking barrier(4)
- CreateObject(994,-2254.10009766,2279.00000000,4.00000000,0.00000000,0.00000000,0.00000000); //sasd parking barrier(5)
- CreateObject(994,-2280.30004883,2279.50000000,4.00000000,0.00000000,0.00000000,90.00000000); //sasd parking barrier(26)
- CreateObject(994,-2280.30004883,2286.10009766,4.00000000,0.00000000,0.00000000,90.00000000); //sasd parking barrier(25)
- CreateObject(994,-2280.30004883,2292.69995117,4.00000000,0.00000000,0.00000000,90.00000000); //sasd parking barrier(24)
- CreateObject(994,-2280.30004883,2299.30004883,4.00000000,0.00000000,0.00000000,90.00000000); //sasd parking barrier(23)
- CreateObject(994,-2280.30004883,2305.89990234,4.00000000,0.00000000,0.00000000,90.00000000); //sasd parking barrier(22)
- CreateObject(994,-2280.30004883,2312.50000000,4.00000000,0.00000000,0.00000000,90.00000000); //sasd parking barrier(21)
- CreateObject(994,-2280.30004883,2319.10009766,4.00000000,0.00000000,0.00000000,90.00000000); //sasd parking barrier(20)
- CreateObject(994,-2280.30004883,2325.69995117,4.00000000,0.00000000,0.00000000,90.00000000); //sasd parking barrier(19)
- CreateObject(994,-2280.30004883,2332.30004883,4.00000000,0.00000000,0.00000000,90.00000000); //sasd parking barrier(18)
- CreateObject(994,-2280.30004883,2338.89990234,4.00000000,0.00000000,0.00000000,90.00000000); //sasd parking barrier(17)
- CreateObject(967,-2278.19995117,2348.30004883,4.00000000,0.00000000,0.00000000,145.74996948); //sasd parking gate house
- CreateObject(968,-2277.81054688,2348.99218750,4.77500105,0.00000000,90.00000000,54.24499512); //sasd parking gate
- CreateObject(994,-2247.50000000,2279.00000000,4.00000000,0.00000000,0.00000000,54.00000000); //sasd parking barrier(6)
- CreateObject(994,-2244.00000000,2310.60009766,4.00000000,0.00000000,0.00000000,89.99780273); //sasd parking barrier(7)
- CreateObject(994,-2244.00000000,2317.30004883,4.00000000,0.00000000,0.00000000,89.99450684); //sasd parking barrier(8)
- CreateObject(994,-2244.00000000,2330.00000000,4.00000000,0.00000000,0.00000000,89.99450684); //sasd parking barrier(9)
- CreateObject(994,-2244.00000000,2336.69995117,4.00000000,0.00000000,0.00000000,89.99450684); //sasd parking barrier(10)
- CreateObject(994,-2244.39990234,2343.19995117,4.00000000,0.00000000,0.00000000,143.99456787); //sasd parking barrier(11)
- CreateObject(994,-2249.80004883,2347.10009766,4.00000000,0.00000000,0.00000000,143.99230957); //sasd parking barrier(12)
- CreateObject(994,-2255.10009766,2351.00000000,4.00000000,0.00000000,0.00000000,143.99230957); //sasd parking barrier(13)
- CreateObject(994,-2260.39990234,2354.80004883,4.00000000,0.00000000,0.00000000,143.99230957); //sasd parking barrier(14)
- CreateObject(994,-2265.69921875,2358.59960938,4.00000000,0.00000000,0.00000000,187.99206543); //sasd parking barrier(15)
- CreateObject(11451,-2232.19995117,2296.50000000,4.40000010,0.00000000,0.00000000,330.00000000); //sasd hq
- CreateObject(997,-2272.19995117,2357.60009766,4.00000000,0.00000000,0.00000000,234.00000000); //sasd parking barrier(27)
- CreateObject(997,-2280.80004883,2345.39990234,4.00000000,0.00000000,0.00000000,53.99780273); //sasd parking barrier(28)
- CreateObject(11454,-2612.76147461,2258.10180664,7.21093750,0.00000000,0.00000000,0.00000000); //ems hq
- return 1;
- }
- public ConnectMySQL()
- {
- mysql_debug(1);
- mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
- if (mysql_ping() != 1)
- return 0;
- return 1;
- }
- public OnGameModeExit()
- {
- mysql_close();
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- PlayerInfo[playerid][pId] = playerid;
- GetPlayerName(playerid, PlayerInfo[playerid][pName], MAX_PLAYER_NAME);
- GetRPName(playerid, PlayerInfo[playerid][pRPName]);
- GetPlayerIp(playerid, PlayerInfo[playerid][pIp], 15);
- PlayerInfo[playerid][pLogged] = 0;
- SetSpawnInfo(playerid, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0);
- TogglePlayerSpectating(playerid, true);
- ClearChat(playerid);
- new msg[256];
- format(msg, sizeof(msg), "» Welcome to Keywork Roleplay, %s!", PlayerInfo[playerid][pRPName]);
- SendClientMessage(playerid, COLOR_YELLOW, msg);
- format(msg, sizeof(msg), "» Running KW:RP %s", SERVER_VERSION);
- SendClientMessage(playerid, COLOR_YELLOW, msg);
- format(msg, sizeof(msg), "» Last updated on: %s", SERVER_LASTUPDATED);
- SendClientMessage(playerid, COLOR_YELLOW, msg);
- SendClientMessage(playerid, COLOR_WHITE, " ");
- SendClientMessage(playerid, COLOR_YELLOW, "Looking up your account..");
- SendClientMessage(playerid, COLOR_WHITE, " ");
- new query[256];
- format(query, sizeof(query), "SELECT * FROM users WHERE name='%s'", PlayerInfo[playerid][pName]);
- mysql_store_result(mysql_query(query));
- new rows = mysql_num_rows();
- if (rows == 0)
- {
- format(msg, sizeof(msg), "No account with the name '%s' was found in our database.", PlayerInfo[playerid][pName]);
- SendClientMessage(playerid, COLOR_YELLOW, msg);
- SendClientMessage(playerid, COLOR_YELLOW, "You may now proceed to register.");
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Please enter your desired password.", "Register", "Exit");
- }
- if (rows == 1)
- {
- format(msg, sizeof(msg), "The account '%s' already exists within our database.", PlayerInfo[playerid][pName]);
- SendClientMessage(playerid, COLOR_YELLOW, msg);
- SendClientMessage(playerid, COLOR_YELLOW, "If this is you, please login. Otherwise, please choose a different name.");
- SendClientMessage(playerid, COLOR_WHITE, " ");
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Please enter your password.", "Login", "Exit");
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- if (!IsRPName(name, 2))
- {
- SendClientMessage(playerid, COLOR_RED, "Your name is not in the correct format, please change it.");
- SendClientMessage(playerid, COLOR_RED, "i.e John_Smith");
- Kick(playerid);
- return 0;
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if (PlayerInfo[playerid][pLogged] == 1)
- SavePlayer(playerid);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if (PlayerInfo[playerid][pNew] == 1)
- {
- PlayerInfo[playerid][pLogged] = 1;
- TogglePlayerSpectating(playerid, true);
- new msg[256];
- format(msg, sizeof(msg), "%sKW:RP %s\n\n%sWelcome to Keywork Roleplay, and thank you for choosing to play here.\n", COL_ADMIN, SERVER_VERSION, COL_WHITE);
- format(msg, sizeof(msg), "%sPlease follow this short tutorial sequence, and then you'll be ready to play!", msg);
- ShowPlayerDialog(playerid, DIALOG_TUTORIAL1, DIALOG_STYLE_MSGBOX, "KW:RP Tutorial", msg, "Next", "Exit");
- }
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- SendClientMessage(playerid, COLOR_ADMIN, "Why'd you have to die?");
- SendClientMessage(playerid, COLOR_ADMIN, "It's not even properly scripted in yet..");
- SendClientMessage(playerid, COLOR_WHITE, " ");
- SetPlayerHealth(playerid, 50);
- SetPlayerPos(playerid, -2615.135986, 2273.914794, 8.10937);
- SetPlayerFacingAngle(playerid, 358.635131);
- SendClientMessage(playerid, COLOR_RED, "$500 has been deducted from you due to hospital fees.");
- GivePlayerMoney(playerid, -500);
- return 0;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- 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)
- Kick(playerid);
- new hash[41];
- sha1(inputtext, hash);
- new ip[15];
- GetPlayerIp(playerid, ip, sizeof(ip));
- new query[256];
- format(query, sizeof(query), "INSERT INTO users (name, password, regip) VALUES ('%s', '%s', '%s')",
- PlayerInfo[playerid][pName], hash, PlayerInfo[playerid][pIp]);
- mysql_query("ALTER TABLE users AUTO_INCREMENT = 1;");
- mysql_query(query);
- SendClientMessage(playerid, COLOR_YELLOW, "You have successfully registered.");
- SendClientMessage(playerid, COLOR_YELLOW, "You may now log in with the password you chose.");
- SendClientMessage(playerid, COLOR_WHITE, " ");
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Please enter your password.", "Login", "Exit");
- }
- case DIALOG_LOGIN:
- {
- if (!response)
- Kick(playerid);
- new inputhash[41];
- sha1(inputtext, inputhash);
- new query[256];
- format(query, sizeof(query), "SELECT * FROM users WHERE name='%s' AND password='%s'",
- PlayerInfo[playerid][pName], inputhash);
- mysql_store_result(mysql_query(query));
- new correct = mysql_num_rows();
- if (correct == 0)
- {
- SendClientMessage(playerid, COLOR_RED, "The password you entered was incorrect.");
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Please enter your password.", "Login", "Exit");
- }
- if (correct == 1)
- {
- SendClientMessage(playerid, COLOR_GREEN, "You have successfully logged in.");
- format(query, sizeof(query), "UPDATE users SET lastip='%s' WHERE name='%s'",
- PlayerInfo[playerid][pIp], PlayerInfo[playerid][pName]);
- mysql_query(query);
- LoadPlayer(playerid);
- SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ], PlayerInfo[playerid][pAngle],
- 0, 0, 0, 0, 0, 0);
- SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
- SetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
- GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
- if (PlayerInfo[playerid][pAccountType] == 1)
- SetPlayerColor(playerid, COLOR_ADMIN);
- else
- SetPlayerColor(playerid, COLOR_WHITE);
- PlayerInfo[playerid][pLogged] = 1;
- TogglePlayerSpectating(playerid, false);
- SpawnPlayer(playerid);
- }
- }
- case DIALOG_TUTORIAL1:
- {
- if (!response)
- Kick(playerid);
- new msg[256];
- format(msg, sizeof(msg), "%sHow does our server differ from others?\n\n%s", COL_YELLOW, COL_WHITE);
- format(msg, sizeof(msg), "%sFirstly, KW:RP is based solely on an economy, and everything effects this economy.\n", msg);
- format(msg, sizeof(msg), "%sBecause of this, we can offer a truly dynamic world to roleplay within.\n", msg);
- ShowPlayerDialog(playerid, DIALOG_TUTORIAL2, DIALOG_STYLE_MSGBOX, "KW:RP Tutorial", msg, "Next", "Back");
- }
- case DIALOG_TUTORIAL2:
- {
- new msg[256];
- if (!response)
- {
- format(msg, sizeof(msg), "%sKW:RP %s\n\n%sWelcome to Keywork Roleplay, and thank you for choosing to play here.\n", COL_ADMIN, SERVER_VERSION, COL_WHITE);
- format(msg, sizeof(msg), "%sPlease follow this short tutorial sequence, and then you'll be ready to play!", msg);
- ShowPlayerDialog(playerid, DIALOG_TUTORIAL1, DIALOG_STYLE_MSGBOX, "KW:RP Tutorial", msg, "Next", "Exit");
- return 1;
- }
- format(msg, sizeof(msg), "%sThis also allows players to obtain things quicker and reap the short-term benefits.\n", COL_WHITE);
- format(msg, sizeof(msg), "%sHowever, as you might expect, over a long period of time you will start to feel the effects\n", msg);
- format(msg, sizeof(msg), "%sof the mortgage or loan you took out.", msg);
- ShowPlayerDialog(playerid, DIALOG_TUTORIAL3, DIALOG_STYLE_MSGBOX, "KW:RP Tutorial", msg, "Next", "Back");
- }
- case DIALOG_TUTORIAL3:
- {
- new msg[256];
- if (!response)
- {
- format(msg, sizeof(msg), "%sHow does our server differ from others?\n\n%s", COL_YELLOW, COL_WHITE);
- format(msg, sizeof(msg), "%sFirstly, KW:RP is based solely on an economy, and everything effects this economy.\n", msg);
- format(msg, sizeof(msg), "%sBecause of this, we can offer a truly dynamic world to roleplay within.\n", msg);
- ShowPlayerDialog(playerid, DIALOG_TUTORIAL2, DIALOG_STYLE_MSGBOX, "KW:RP Tutorial", msg, "Next", "Back");
- return 1;
- }
- format(msg, sizeof(msg), "%sServer Rules\n\n", COL_RED);
- format(msg, sizeof(msg), "%s%sAs of current, we don't have a defined ruleset.\n", msg, COL_WHITE);
- format(msg, sizeof(msg), "%sHowever, we expect you to be as realistic as possible and avoid things like metagaming & powergaming.", msg);
- ShowPlayerDialog(playerid, DIALOG_TUTORIAL4, DIALOG_STYLE_MSGBOX, "KW:RP Tutorial", msg, "Next", "Back");
- }
- case DIALOG_TUTORIAL4:
- {
- new msg[256];
- if (!response)
- {
- format(msg, sizeof(msg), "%sThis also allows players to obtain things quicker and reap the short-term benefits.\n", COL_WHITE);
- format(msg, sizeof(msg), "%sHowever, as you might expect, over a long period of time you will start to feel the effects\n", msg);
- format(msg, sizeof(msg), "%sof the mortgage or loan you took out.", msg);
- ShowPlayerDialog(playerid, DIALOG_TUTORIAL3, DIALOG_STYLE_MSGBOX, "KW:RP Tutorial", msg, "Next", "Back");
- return 1;
- }
- format(msg, sizeof(msg), "%sSo what do I do now?\n\n", COL_YELLOW);
- format(msg, sizeof(msg), "%s%sYou proceed to character creation, but most of all, you have fun =)", msg, COL_WHITE);
- ShowPlayerDialog(playerid, DIALOG_TUTORIAL5, DIALOG_STYLE_MSGBOX, "KW:RP Tutorial", msg, "Begin", "Back");
- }
- case DIALOG_TUTORIAL5:
- {
- new msg[256];
- if (!response)
- {
- format(msg, sizeof(msg), "%sServer Rules\n\n", COL_RED);
- format(msg, sizeof(msg), "%s%sAs of current, we don't have a defined ruleset.\n", msg, COL_WHITE);
- format(msg, sizeof(msg), "%sHowever, we expect you to be as realistic as possible and avoid things like metagaming & powergaming.", msg);
- ShowPlayerDialog(playerid, DIALOG_TUTORIAL4, DIALOG_STYLE_MSGBOX, "KW:RP Tutorial", msg, "Next", "Back");
- return 1;
- }
- new fname[MAX_PLAYER_NAME];
- GetFirstName(playerid, fname);
- format(msg, sizeof(msg), "%sHey there, %s!\n\n", COL_WHITE, fname);
- format(msg, sizeof(msg), "%sWelcome to our small little town, Bayside.", msg);
- ShowPlayerDialog(playerid, DIALOG_CCREATION1, DIALOG_STYLE_MSGBOX, "Character Creation", msg, "Next", "Exit");
- }
- case DIALOG_CCREATION1:
- {
- new msg[256];
- if (!response)
- Kick(playerid);
- format(msg, sizeof(msg), "%sBayside is a small town nestled in the north western corner of the state that never really got going.\n", COL_WHITE);
- format(msg, sizeof(msg), "%sIt was a meant as a suburb of San Fierro, but that was before 1905 when the great quake levelled most of the state.\n", msg);
- //format(msg, sizeof(msg), "%sIt'd be around that time when Bayside went it's own way, rejecting the new San Fierro in 1909.\n", msg);
- //format(msg, sizeof(msg), "%sThe main force of law in Bayside has always been the Sherrif's Department, formed from the Bayside citizens themselves.", msg);
- ShowPlayerDialog(playerid, DIALOG_CCREATION2, DIALOG_STYLE_MSGBOX, "Character Creation", msg, "Next", "Exit");
- }
- case DIALOG_CCREATION2:
- {
- new msg[256];
- if (!response)
- Kick(playerid);
- format(msg, sizeof(msg), "%sIt'd be around that time when Bayside went it's own way, rejecting the new San Fierro in 1909.\n", COL_WHITE);
- format(msg, sizeof(msg), "%sThe main force of law in Bayside has always been the Sherrif's Department, formed from the Bayside citizens themselves.", msg);
- ShowPlayerDialog(playerid, DIALOG_CCREATION3, DIALOG_STYLE_MSGBOX, "Character Creation", msg, "Next", "Exit");
- }
- case DIALOG_CCREATION3:
- {
- new msg[256];
- if (!response)
- Kick(playerid);
- format(msg, sizeof(msg), "%sAnyhow, enough of that.\nAre you male or female?", COL_WHITE);
- ShowPlayerDialog(playerid, DIALOG_CCREATION4, DIALOG_STYLE_INPUT, "Character Creation", msg, "Next", "Exit");
- }
- case DIALOG_CCREATION4:
- {
- new msg[256];
- if (!response)
- Kick(playerid);
- if (strcmp(inputtext, "male", true) == 0)
- {
- PlayerInfo[playerid][pGender] = 0;
- }
- else if (strcmp(inputtext, "female", true) == 0)
- {
- PlayerInfo[playerid][pGender] = 1;
- }
- else
- {
- format(msg, sizeof(msg), "%sHuh? Is that English buddy?\n", COL_WHITE);
- format(msg, sizeof(msg), "%s%s(( You must type either Male or Female ))", msg, COL_YELLOW);
- ShowPlayerDialog(playerid, DIALOG_CCREATION4, DIALOG_STYLE_INPUT, "Character Creation", msg, "Next", "Exit");
- return 1;
- }
- format(msg, sizeof(msg), "%sRight, and if you don't mind me askin', how old are ya?", COL_WHITE);
- ShowPlayerDialog(playerid, DIALOG_CCREATION5, DIALOG_STYLE_INPUT, "Character Creation", msg, "Next", "Exit");
- }
- case DIALOG_CCREATION5:
- {
- new msg[256];
- if (!response)
- Kick(playerid);
- if (!IsNumeric(inputtext))
- {
- format(msg, sizeof(msg), "%sI understand ya not wanting me to know your age, but you can't just go around with all these secrets!\n", COL_WHITE);
- format(msg, sizeof(msg), "%s%s(( The age entered must be a number, and it is your character's age - not yours. ))", msg, COL_YELLOW);
- ShowPlayerDialog(playerid, DIALOG_CCREATION5, DIALOG_STYLE_INPUT, "Character Creation", msg, "Next", "Exit");
- return 1;
- }
- new age = strval(inputtext);
- if (age > 60)
- {
- format(msg, sizeof(msg), "%s*chuckles*, you don't seem that old!\n", COL_WHITE);
- format(msg, sizeof(msg), "%s%s(( Your age must be below 60! ))", msg, COL_YELLOW);
- ShowPlayerDialog(playerid, DIALOG_CCREATION5, DIALOG_STYLE_INPUT, "Character Creation", msg, "Next", "Exit");
- return 1;
- }
- if (age < 18)
- {
- format(msg, sizeof(msg), "%sYou can't be that young, and movin' about the world!\n", COL_WHITE);
- format(msg, sizeof(msg), "%s%s(( Your age must be above 18! ))", msg, COL_YELLOW);
- ShowPlayerDialog(playerid, DIALOG_CCREATION5, DIALOG_STYLE_INPUT, "Character Creation", msg, "Next", "Exit");
- return 1;
- }
- PlayerInfo[playerid][pAge] = age;
- format(msg, sizeof(msg), "%sRighto, looks like you're ready to get settled in to Bayside!\n", COL_WHITE);
- format(msg, sizeof(msg), "%s%s(( If you messed something up during character creation, hit exit and log back in to redo it ))", msg, COL_YELLOW);
- ShowPlayerDialog(playerid, DIALOG_CCREATION6, DIALOG_STYLE_MSGBOX, "Character Creation", msg, "Start", "Exit");
- }
- case DIALOG_CCREATION6:
- {
- if (PlayerInfo[playerid][pGender] == 0)
- PlayerInfo[playerid][pSkin] = 26;
- if (PlayerInfo[playerid][pGender] == 1)
- PlayerInfo[playerid][pSkin] = 12;
- SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
- PlayerInfo[playerid][pNew] = 0;
- PlayerInfo[playerid][pLogged] = 1;
- SavePlayer(playerid);
- LoadPlayer(playerid);
- SpawnPlayer(playerid);
- TogglePlayerSpectating(playerid, false);
- if (!response)
- Kick(playerid);
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- // [ Stock Functions ]
- stock IsRPName(const name[], max_underscores = 2)
- {
- new underscores = 0;
- if (name[0] < 'A' || name[0] > 'Z') return false;
- for(new i = 1; i < strlen(name); i++)
- {
- if(name[i] != '_' && (name[i] < 'A' || name[i] > 'Z') && (name[i] < 'a' || name[i] > 'z')) return false;
- if( (name[i] >= 'A' && name[i] <= 'Z') && (name[i - 1] != '_') ) return false;
- if(name[i] == '_')
- {
- underscores++;
- if(underscores > max_underscores || i == strlen(name)) return false;
- if(name[i + 1] < 'A' || name[i + 1] > 'Z') return false;
- }
- }
- if (underscores == 0) return false;
- return true;
- }
- stock GetRPName(playerid, name[])
- {
- new buf[MAX_PLAYER_NAME];
- GetPlayerName(playerid, buf, sizeof(buf));
- for (new i = 0; i < sizeof(buf); i++)
- {
- if (buf[i] == '_')
- name[i] = ' ';
- else
- name[i] = buf[i];
- }
- }
- stock ClearChat(playerid)
- {
- for (new i = 0; i < 20; i++)
- {
- SendClientMessage(playerid, COLOR_WHITE, " ");
- }
- }
- stock GetFirstName(playerid, name[])
- {
- new name2[MAX_PLAYER_NAME];
- format(name2, sizeof(name2), "%s", PlayerInfo[playerid][pName]);
- for (new i = 0; i < MAX_PLAYER_NAME; i++)
- {
- if (name2[i] == '_')
- break;
- name[i] = name2[i];
- }
- }
- stock IsNumeric(const string[])
- {
- for (new i = 0, j = strlen(string); i < j; i++)
- {
- if (string[i] > '9' || string[i] < '0') return 0;
- }
- return 1;
- }
- // [ Stock Functions ]
- // [ Player Management ]
- public LoadPlayer(playerid)
- {
- new query[256];
- format(query, sizeof(query), "SELECT * FROM users WHERE name='%s'",
- PlayerInfo[playerid][pName]);
- mysql_store_result(mysql_query(query));
- mysql_retrieve_row();
- new buf[256];
- mysql_fetch_field_row(buf, "type");
- PlayerInfo[playerid][pAccountType] = strval(buf);
- mysql_fetch_field_row(buf, "adminlevel");
- PlayerInfo[playerid][pAdminLevel] = strval(buf);
- mysql_fetch_field_row(buf, "new");
- PlayerInfo[playerid][pNew] = strval(buf);
- mysql_fetch_field_row(buf, "x");
- PlayerInfo[playerid][pX] = floatstr(buf);
- mysql_fetch_field_row(buf, "y");
- PlayerInfo[playerid][pY] = floatstr(buf);
- mysql_fetch_field_row(buf, "z");
- PlayerInfo[playerid][pZ] = floatstr(buf);
- mysql_fetch_field_row(buf, "angle");
- PlayerInfo[playerid][pAngle] = floatstr(buf);
- mysql_fetch_field_row(buf, "health");
- PlayerInfo[playerid][pHealth] = floatstr(buf);
- mysql_fetch_field_row(buf, "armour");
- PlayerInfo[playerid][pArmour] = floatstr(buf);
- mysql_fetch_field_row(buf, "money");
- PlayerInfo[playerid][pMoney] = strval(buf);
- mysql_fetch_field_row(buf, "skin");
- PlayerInfo[playerid][pSkin] = strval(buf);
- mysql_fetch_field_row(buf, "age");
- PlayerInfo[playerid][pAge] = strval(buf);
- mysql_fetch_field_row(buf, "gender");
- PlayerInfo[playerid][pGender] = strval(buf);
- mysql_free_result();
- }
- public SavePlayer(playerid)
- {
- GetPlayerPos(playerid, PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ]);
- GetPlayerFacingAngle(playerid, PlayerInfo[playerid][pAngle]);
- GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
- GetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
- PlayerInfo[playerid][pMoney] = GetPlayerMoney(playerid);
- PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
- new query[256];
- format(query, sizeof(query), "UPDATE users SET adminlevel=%i, new=%i, x=%f, y=%f, z=%f, angle=%f, health=%f, armour=%f, money=%i, skin=%i, age=%i, gender=%i WHERE name='%s'",
- PlayerInfo[playerid][pAdminLevel], PlayerInfo[playerid][pNew], PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ],
- PlayerInfo[playerid][pAngle], PlayerInfo[playerid][pHealth], PlayerInfo[playerid][pArmour], PlayerInfo[playerid][pMoney], PlayerInfo[playerid][pSkin],
- PlayerInfo[playerid][pAge], PlayerInfo[playerid][pGender],
- PlayerInfo[playerid][pName]);
- mysql_query(query);
- }
- // [ Player Management ]
- // [ Admin Section ]
- COMMAND:ahelp(playerid, params[])
- {
- if (PlayerInfo[playerid][pLogged] == 0)
- return 0;
- if (PlayerInfo[playerid][pAdminLevel] == 0)
- return 0;
- SendClientMessage(playerid, COLOR_ADMIN, "--");
- if (PlayerInfo[playerid][pAdminLevel] >= 1)
- SendClientMessage(playerid, COLOR_ADMIN, "COMMANDS :: /(a)chat /kick /freeze /thaw /goto /get");
- if (PlayerInfo[playerid][pAdminLevel] >= 2)
- SendClientMessage(playerid, COLOR_ADMIN, "COMMANDS :: /announce /slap /ban /setskin");
- if (PlayerInfo[playerid][pAdminLevel] >= 3)
- SendClientMessage(playerid, COLOR_ADMIN, "COMMANDS :: /ainvite /apromote /afire /spectate /specoff");
- SendClientMessage(playerid, COLOR_ADMIN, "--");
- return 1;
- }
- COMMAND:achat(playerid, params[])
- {
- if (PlayerInfo[playerid][pLogged] == 0)
- return 0;
- if (PlayerInfo[playerid][pAdminLevel] == 0)
- return 0;
- new title[30];
- if (PlayerInfo[playerid][pAdminLevel] == 1)
- format(title, sizeof(title), "Moderator");
- if (PlayerInfo[playerid][pAdminLevel] == 2)
- format(title, sizeof(title), "General Moderator");
- if (PlayerInfo[playerid][pAdminLevel] == 3)
- format(title, sizeof(title), "Administrator");
- new msg[256];
- format(msg, sizeof(msg), "(( %s %s: %s ))", title, PlayerInfo[playerid][pRPName], params);
- for (new p = 0; p < MAX_PLAYERS; p++)
- {
- if (PlayerInfo[p][pAdminLevel] > 0 && PlayerInfo[p][pLogged] == 1)
- SendClientMessage(p, COLOR_ADMIN, msg);
- }
- return 1;
- }
- COMMAND:a(playerid, params[])
- {
- return cmd_achat(playerid, params);
- }
- COMMAND:kick(playerid, params[])
- {
- if (PlayerInfo[playerid][pLogged] == 0)
- return 0;
- if (PlayerInfo[playerid][pAdminLevel] == 0)
- return 0;
- if (PlayerInfo[playerid][pAdminLevel] >= 1)
- {
- new kid;
- new reason[64];
- new msg[256];
- if (sscanf(params, "us[64]", kid, reason))
- return SendClientMessage(playerid, COLOR_ADMIN, "Usage: /kick <player> <reason>");
- if (!IsPlayerConnected(kid))
- return SendClientMessage(playerid, COLOR_ADMIN, "Player is not connected!");
- format(msg, sizeof(msg), "[ADMIN] %s has been kicked from the server. Reason: %s (%s)", PlayerInfo[kid][pRPName], reason, PlayerInfo[playerid][pRPName]);
- SendClientMessageToAll(COLOR_RED, msg);
- Kick(kid);
- }
- return 1;
- }
- COMMAND:freeze(playerid, params[])
- {
- if (PlayerInfo[playerid][pLogged] == 0)
- return 0;
- if (PlayerInfo[playerid][pAdminLevel] == 0)
- return 0;
- if (PlayerInfo[playerid][pAdminLevel] >= 1)
- {
- new id;
- new msg[256];
- if (sscanf(params, "u", id))
- return SendClientMessage(playerid, COLOR_ADMIN, "Usage: /freeze <player>");
- if (!IsPlayerConnected(id))
- return SendClientMessage(playerid, COLOR_ADMIN, "Player is not connected!");
- format(msg, sizeof(msg), "You have been frozen by %s.", PlayerInfo[playerid][pRPName]);
- TogglePlayerControllable(id, false);
- SendClientMessage(id, COLOR_ADMIN, msg);
- format(msg, sizeof(msg), "You have frozen %s.", PlayerInfo[id][pRPName]);
- SendClientMessage(playerid, COLOR_ADMIN, msg);
- }
- return 1;
- }
- COMMAND:thaw(playerid, params[])
- {
- if (PlayerInfo[playerid][pLogged] == 0)
- return 0;
- if (PlayerInfo[playerid][pAdminLevel] == 0)
- return 0;
- if (PlayerInfo[playerid][pAdminLevel] >= 1)
- {
- new id;
- new msg[256];
- if (sscanf(params, "u", id))
- return SendClientMessage(playerid, COLOR_ADMIN, "Usage: /thaw <player>");
- if (!IsPlayerConnected(id))
- return SendClientMessage(playerid, COLOR_ADMIN, "Player is not connected!");
- format(msg, sizeof(msg), "You have been thawed by %s.", PlayerInfo[playerid][pRPName]);
- TogglePlayerControllable(id, true);
- SendClientMessage(id, COLOR_ADMIN, msg);
- format(msg, sizeof(msg), "You have thawed %s.", PlayerInfo[id][pRPName]);
- SendClientMessage(playerid, COLOR_ADMIN, msg);
- }
- return 1;
- }
- COMMAND:goto(playerid, params[])
- {
- if (PlayerInfo[playerid][pLogged] == 0)
- return 0;
- if (PlayerInfo[playerid][pAdminLevel] == 0)
- return 0;
- if (PlayerInfo[playerid][pAdminLevel] >= 1)
- {
- new id;
- new Float:x, Float:y, Float:z;
- new msg[256];
- if (sscanf(params, "u", id))
- return SendClientMessage(playerid, COLOR_ADMIN, "Usage: /goto <player>");
- if (!IsPlayerConnected(id))
- return SendClientMessage(playerid, COLOR_ADMIN, "Player is not connected!");
- GetPlayerPos(id, x, y, z);
- SetPlayerPos(playerid, x, y, z);
- format(msg, sizeof(msg), "%s has teleported to you!", PlayerInfo[playerid][pRPName]);
- SendClientMessage(id, COLOR_ADMIN, msg);
- format(msg, sizeof(msg), "You have teleported to %s.", PlayerInfo[id][pRPName]);
- SendClientMessage(playerid, COLOR_ADMIN, msg);
- }
- return 1;
- }
- COMMAND:get(playerid, params[])
- {
- if (PlayerInfo[playerid][pLogged] == 0)
- return 0;
- if (PlayerInfo[playerid][pAdminLevel] == 0)
- return 0;
- if (PlayerInfo[playerid][pAdminLevel] >= 1)
- {
- new id;
- new Float:x, Float:y, Float:z;
- new msg[256];
- if (sscanf(params, "u", id))
- return SendClientMessage(playerid, COLOR_ADMIN, "Usage: /get <player>");
- if (!IsPlayerConnected(id))
- return SendClientMessage(playerid, COLOR_ADMIN, "Player is not connected!");
- GetPlayerPos(playerid, x, y, z);
- SetPlayerPos(id, x, y, z);
- format(msg, sizeof(msg), "%s has teleported you to them!", PlayerInfo[playerid][pRPName]);
- SendClientMessage(id, COLOR_ADMIN, msg);
- format(msg, sizeof(msg), "You have teleported %s to you", PlayerInfo[id][pRPName]);
- SendClientMessage(playerid, COLOR_ADMIN, msg);
- }
- return 1;
- }
- COMMAND:announce(playerid, params[])
- {
- if (PlayerInfo[playerid][pLogged] == 0)
- return 0;
- if (PlayerInfo[playerid][pAdminLevel] == 0)
- return 0;
- if (PlayerInfo[playerid][pAdminLevel] >= 2)
- {
- new msg[256];
- format(msg, sizeof(msg), "(( Announcement by %s: %s ))", PlayerInfo[playerid][pRPName], params);
- SendClientMessageToAll(COLOR_ADMIN, msg);
- }
- return 1;
- }
- COMMAND:slap(playerid, params[])
- {
- return 0;
- }
- COMMAND:ban(playerid, params[])
- {
- return 0;
- }
- COMMAND:setskin(playerid, params[])
- {
- if (PlayerInfo[playerid][pLogged] == 0)
- return 0;
- if (PlayerInfo[playerid][pAdminLevel] == 0)
- return 0;
- if (PlayerInfo[playerid][pAdminLevel] >= 2)
- {
- new id;
- new skin;
- if (sscanf(params, "ui", id, skin))
- return SendClientMessage(playerid, COLOR_ADMIN, "Usage: /setskin <player> <skin>");
- if (!IsPlayerConnected(id))
- return SendClientMessage(playerid, COLOR_ADMIN, "Player is not connected!");
- SetPlayerSkin(id, skin);
- PlayerInfo[playerid][pSkin] = skin;
- new msg[256];
- format(msg, sizeof(msg), "Your skin was changed by %s.", PlayerInfo[playerid][pRPName]);
- SendClientMessage(id, COLOR_ADMIN, msg);
- }
- return 1;
- }
- COMMAND:v(playerid, params[])
- {
- new id;
- if (sscanf(params, "i", id))
- return SendClientMessage(playerid, COLOR_ADMIN, "Usage: /v <vehicle id>");
- new Float:x, Float:y, Float:z, Float:angle;
- GetPlayerPos(playerid, x, y, z);
- GetPlayerFacingAngle(playerid, angle);
- AddStaticVehicle(id, x, y, z, angle, 0, 0);
- return 1;
- }
- // [ Admin Section ]