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 <a_mysql>
- #include <zcmd>
- #include <Float>
- #define WHITE 0xFFFFFFF
- #define SQL_HOST "64.120.14.202"
- #define SQL_USER "tkz227_rvrp"
- #define SQL_PASS "tyler5240"
- #define SQL_DB "tkz227_rvrp"
- #define mysql_fetch_row(%1) mysql_fetch_row_format(%1,"|")
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 40 // Put this as low as you could!
- new PlayerLogged[MAX_PLAYERS];
- #define DIALOG_REGISTER 1
- #define DIALOG_LOGIN 2
- main()
- {
- print("\n----------------------------------");
- print(" Blank Gamemode by your name here");
- print("----------------------------------\n");
- }
- forward ConnectMySQL();
- public ConnectMySQL()
- {
- if(mysql_connect(SQL_HOST,SQL_USER,SQL_DB,SQL_PASS))
- {
- mysql_debug(1);
- printf("[MYSQL]: Connection to `%s` succesful!",SQL_DB);
- }
- else
- {
- printf("[MYSQL]: [ERROR]: Connection to `%s` failed!",SQL_DB);
- }
- return 1;
- }
- CheckMySQL()
- {
- if(mysql_ping() == -1)
- mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
- }
- enum Player
- {
- AdminLevel,
- Cash,
- Skin
- }
- new PlayerInfo[MAX_PLAYERS][Player];
- CheckAccountExists(account[])
- {
- new string[128];
- format(string, sizeof(string), "SELECT * FROM user WHERE user = '%s'", account);
- mysql_query(string);
- mysql_store_result();
- new value;
- value = mysql_num_rows();
- mysql_free_result();
- return value;
- }
- public OnGameModeInit()
- {
- ConnectMySQL();
- // 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);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername, sizeof(playername));
- if(CheckAccountExists(playername))
- {
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please input your password in the box below:", "Login", "Cancel");
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register", "This account is not registered. Please input your desired\npassword in the box below:", "Register", "Cancel");
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new user[MAX_PLAYER_NAME];
- GetPlayerName(playerid,user,sizeof(user));
- new string[128];
- PlayerInfo[playerid][Skin] = GetPlayerSkin(playerid);
- PlayerInfo[playerid][Cash] = GetPlayerMoney(playerid);
- format(string, sizeof(string), "UPDATE user WHERE username = '%s' SET admin='%i' cash='%i' skin '%i'", user, PlayerInfo[playerid][AdminLevel], PlayerInfo[playerid][Cash], PlayerInfo[playerid][Skin]);
- mysql_query(string);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
- 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)
- {
- 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 == 1)
- {
- CheckMySQL();
- new string[128];
- new playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername, sizeof(playername));
- format(string, sizeof(string), "INSERT INTO user (username, pass) VALUES ('%s', '%s')", playername, inputtext);
- mysql_query(string);
- SendClientMessage(playerid, 0xFFFFFFFF, "Thank you for registering. Now you must log in.");
- ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please input your password in the box below:", "Login", "Cancel");
- }
- }
- if(dialogid == DIALOG_LOGIN)
- {
- if(response == 1)
- {
- new playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername, sizeof(playername));
- new string[128];
- format(string, sizeof(string), "SELECT * FROM user WHERE username = '%s' AND pass = '%s'", playername, inputtext);
- mysql_query(string);
- mysql_store_result();
- if(!mysql_num_rows()) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: That password is incorrect!");
- new row[128];
- new field[4][32];
- mysql_fetch_row_format(row, "|");
- explode(row, field, "|");
- mysql_free_result();
- PlayerInfo[playerid][AdminLevel] = strval(field[1]);
- PlayerInfo[playerid][Cash] = strval(field[2]);
- PlayerInfo[playerid][Skin] = strval(field[3]);
- SendClientMessage(playerid, 0xFFFFFFFF, "Thank you for logging in!");
- GivePlayerMoney(playerid, PlayerInfo[playerid][Cash]);
- PlayerLogged[playerid] = 1;
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- explode(const sSource[], aExplode[][], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[]) // Created by Westie
- {
- new
- iNode,
- iPointer,
- iPrevious = -1,
- iDelimiter = strlen(sDelimiter);
- while(iNode < iVertices)
- {
- iPointer = strfind(sSource, sDelimiter, false, iPointer);
- if(iPointer == -1)
- {
- strmid(aExplode[iNode], sSource, iPrevious, strlen(sSource), iLength);
- break;
- }
- else
- {
- strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength);
- }
- iPrevious = (iPointer += iDelimiter);
- ++iNode;
- }
- return iPrevious;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement