Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //iBot's colour: 0x7D7D7FFF
- //US team's colour: {669900} 0x006D00FF
- //Russia team's colour: {CC0033} 0xBD0000FF
- #include <a_samp>
- #include <string>
- #include <a_mysql>
- #include <streamer>
- #include <sscanf2>
- #include <uf>
- #define mysql_host "SQL09.FREEMYSQL.NET" //Has to be a string
- #define mysql_user "shazz" //Has to be a string
- #define mysql_password "trololololololol" //There is none for wamp unless you set one.
- #define mysql_database "shazzsampserv" //Has to be a string
- #define iBot 0x7D7D7FFF
- #define retMessPl "iBot: You have made ID %d a moderator. If this was a mistake, please use /makeregular."
- #define retMessBt "iBot: You are now a moderator! /moderator to view your commands."
- new IsRegistered[MAX_PLAYERS];
- new MoneyGiven[MAX_PLAYERS];
- new Logged[MAX_PLAYERS]; //The variable to check if the player is logged.
- //NOTE:Passwordstring has already been escaped. If you want to use
- //this in another script, make sure that you escape the passwordstring
- //before you
- stock MySQL_Register(playerid, passwordstring[])
- {
- new query[200], pname[24], IP[16];
- GetPlayerName(playerid, pname, 24);
- GetPlayerIp(playerid, IP, 16);
- format(query, sizeof(query), "INSERT INTO playerdata (user, password, score, money, IP) VALUES('%s', SHA1('%s'), 0, 0, '%s', 1)", pname, passwordstring, IP);
- mysql_query(query);
- //We do not need to store or free a result as it
- //is not a select statement. We can now send the
- //client a registration success message and set the
- //Login variable to 1.
- SendClientMessage(playerid, iBot, "iBot: You have been registered on this server!");
- Logged[playerid] = 1; //Sets the login variable
- return 1;
- }
- stock MySQL_Login(playerid)
- {
- new query[300], pname[24], savingstring[20];
- GetPlayerName(playerid, pname, 24);
- format(query, sizeof(query), "SELECT * FROM playerdata WHERE user = '%s'", pname);
- //We only select the variables that we want to use.
- //We don't need things like the password string or the user string.
- mysql_query(query); //Queries the result
- mysql_store_result(); //Store a result because it's a SELECT statement.
- while(mysql_fetch_row_format(query,"|"))
- {
- //We use while so that it does a single query, not multiple
- //Especially when we have more variables. If there is more
- //Variables, you should just split the line with sscanf. To
- //Make it easier.
- mysql_fetch_field_row(savingstring, "score"); SetPlayerScore(playerid, strval(savingstring));
- mysql_fetch_field_row(savingstring, "money"); MoneyGiven[playerid] = strval(savingstring);
- mysql_fetch_field_row(savingstring, "adminlevel"); SetPVarInt(playerid, "AdminLevel", strval(savingstring));
- //If you are wondering why I'm using savingstring instead
- //Of a variable like using MoneyGiven right away, it's because
- //mysql_fetch_field_row requires a string.
- }
- mysql_free_result(); //We must always free a stored result
- SendClientMessage(playerid, iBot, "iBot: You have been logged in!"); //Sends the client a message.
- Logged[playerid] = 1; //Sets our logged in variable to one
- return 1;
- }
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Blank Filterscript by your name here");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- #else
- main()
- {
- print("\n----------------------------------");
- print("Battlefield 3 by Shazz");
- print("----------------------------------\n");
- }
- #endif
- public OnGameModeInit()
- {
- SendRconCommand("mapname Caspian Border");
- SetGameModeText("Battlefield 3");
- DisableInteriorEnterExits();
- UsePlayerPedAnims();
- mysql_connect(mysql_host, mysql_user, mysql_database, mysql_password);
- mysql_query("CREATE TABLE IF NOT EXISTS playerdata(user VARCHAR(24), password VARCHAR(41), score INT(20), money INT(20), IP VARCHAR(16), adminlevel INT(2) )");
- //Fields:
- //Field Name - Use - Type
- //user- Player Name - String
- //password- Players password - String
- //score - Players score - int
- //money - Players Cash - int
- //IP - Players IP - int
- //AdminLevel - Player's Admin Level - int - (0 = regular player; 1 = supervisors; 2 = moderators; 3 = admins)
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetSpawnInfo(playerid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- SpawnPlayer(playerid);
- TogglePlayerControllable(playerid, 0);
- ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Choose a Team:","{669900}US\n{CC0033}Russia","Select", ""); //team_choose
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- SendClientMessage(playerid, 0x7D7D7FFF, "iBot: {663399}Welcome to Battlefield 3 Server!");
- SendClientMessage(playerid, 0x7D7D7FFF, "iBot: {663399}Scripted by: {336600}Shazz!");
- new string[64], pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
- format(string,sizeof string,"iBot: %s has joined the server.",pName);
- SendClientMessageToAll(0x7D7D7FFF,string);
- MoneyGiven[playerid] = -1; //Resets the variable that you will discover later in the tutorial.
- SetPVarInt(playerid, "AdminLevel", 1);
- new query[200], pname[24]; //Creates our variables.
- GetPlayerName(playerid, pname, 24); //Gets the players name
- format(query, sizeof(query), "SELECT IP FROM `playerdata` WHERE user = '%s' LIMIT 1", pname); //Formats the query, view above the code for a explanation
- mysql_query(query); //This is our query function to query the string
- mysql_store_result(); //We store the result.
- new rows = mysql_num_rows(); //We get how many rows the query returned.
- if(!rows)
- {
- //If the rows are equal to 0. This means that the query did not find
- //anyone under the name we connected under in the database.
- //So here we send the player the register dialog.
- ShowPlayerDialog(playerid,6,DIALOG_STYLE_INPUT,"Register","Enter a password below:","Register","");
- }
- if(rows == 1)
- {
- //If the rows are equal to 1, this means there is a player already registered
- //so we can initiate the login dialog to the player or check if the players
- //current IP is the same one as in the database.
- new IP[2][16]; //We create a variable with two IP strings, one for retrieving the mysql field and one for GetPlayerIP.
- mysql_fetch_field_row(IP[0],"IP");
- GetPlayerIp(playerid, IP[1], 16);
- if(strlen(IP[0]) != 0 && !strcmp(IP[0], IP[1], true)) //Checks that the MySQL IP has a value and that they are the same.
- {
- ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!","Login",""); //Shows our login dialog :).
- IsRegistered[playerid] = 1; //Sets the registered variable to 1 (Shows that the player is registered).
- }
- else if(!strlen(IP[0]) || strcmp(IP[0], IP[1], true))
- {
- ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!","Login",""); //Shows our login dialog :).
- IsRegistered[playerid] = 1; //Sets the registered variable to 1 (Shows that the player is registered).
- }
- }
- mysql_free_result();
- //You must always free the mysql result to avoid
- //there being massive memory usage.
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- SetPVarInt(playerid, "AdminLevel", 1);
- new string[64],
- name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,MAX_PLAYER_NAME);
- switch(reason)
- {
- case 0: format(string,sizeof string,"iBot: %s left the server. (Reason: Timed Out)",name);
- case 1: format(string,sizeof string,"iBot: %s left the server. (Reason: Left)",name);
- case 2: format(string,sizeof string,"iBot: %s left the server. (Reason: Kicked/Banned)",name);
- }
- SendClientMessageToAll(0x7D7D7FFF,string);
- if(Logged[playerid] == 1)
- {
- //If the player disconnects before registering,
- //we want to make sure it doesn't try update
- //so we check if the player is logged in.
- new score = GetPlayerScore(playerid); //Gets players score
- new money = GetPlayerMoney(playerid); //Gets players money
- new query[200], pname[24]; //Creates the variables
- GetPlayerName(playerid, pname, 24); //Gets the players name.
- format(query, sizeof(query), "UPDATE playerdata SET score=%d, money=%d adminlevel = %d WHERE user='%s'", score, money, GetPVarInt(playerid, "AdminLevel"), pname);
- mysql_query(query);
- //No need to store a result for a update string
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/makemoderator", cmdtext, true, 10) == 0)
- {
- if (IsPlayerAdmin(playerid))
- {
- ShowPlayerDialog(playerid, 8, DIALOG_STYLE_INPUT, "Make someone a moderator","Put in the playerid of the person you want to make a moderator.","GO!","Cancel");
- }
- else
- {
- SendClientMessage(playerid, 0xFFFFFFAA, "SERVER: Unknown command.");
- }
- return 1;
- }
- if (strcmp("/makeadmin", cmdtext, true, 10) == 0)
- {
- if (IsPlayerAdmin(playerid))
- {
- ShowPlayerDialog(playerid, 9, DIALOG_STYLE_INPUT, "Make someone an administrator","Put in the playerid of the person you want to make an administrator.","GO!","Cancel");
- }
- else
- {
- SendClientMessage(playerid, 0xFFFFFFAA, "SERVER: Unknown command.");
- }
- return 1;
- }
- if (strcmp("/makesupervisor", cmdtext, true, 10) == 0)
- {
- if (IsPlayerAdmin(playerid))
- {
- ShowPlayerDialog(playerid, 10, DIALOG_STYLE_INPUT, "Make someone a supervisor.","Put in the playerid of the person you want to make a supervisor.","GO!","Cancel");
- }
- else
- {
- SendClientMessage(playerid, 0xFFFFFFAA, "SERVER: Unknown command.");
- }
- return 1;
- }
- if (strcmp("/makeregular", cmdtext, true, 10) == 0)
- {
- if (IsPlayerAdmin(playerid))
- {
- ShowPlayerDialog(playerid, 11, DIALOG_STYLE_INPUT, "Make someone a regular player","Put in the playerdid of the person you want to make a regular player.","GO!","Cancel");
- }
- else
- {
- SendClientMessage(playerid, 0xFFFFFFAA, "SERVER: Unknown command.");
- }
- return 1;
- }
- if (strcmp("/checkadminlevel", cmdtext, true, 10) == 0)
- {
- printf("AdminLevel: %d", GetPVarInt(playerid, "AdminLevel"));
- 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(response){
- switch(dialogid){
- case 1:{
- switch(listitem){
- case 0: //US
- {
- SendClientMessage(playerid, 0x7D7D7FFF, "iBot: {669900}You have joined the US Team.");
- SetPlayerColor(playerid, 0x006D00FF);
- ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Choose your class:", "Assault\nEngineer\nSupport\nSniper","Select", ""); //us_class_choose
- SetPlayerSkin(playerid, 287);
- SetPlayerTeam(playerid, 1);
- }
- case 1: //Russia
- {
- SendClientMessage(playerid, 0x7D7D7FFF, "iBot: {CC0033}You have joined the Russian Team.");
- SetPlayerColor(playerid, 0xBD0000FF);
- ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "Choose your class:", "Assault\nEngineer\nSupport\nSniper","Select", ""); //russia_class_choose
- SetPlayerSkin(playerid, 73);
- SetPlayerTeam(playerid, 2);
- }
- }
- }
- }
- }
- if(response){
- switch(dialogid){
- case 2:{
- switch(listitem){
- case 0: //Assault
- {
- SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You have chosen the Assault class.");
- GivePlayerWeapon(playerid, 31, 1000);
- GivePlayerWeapon(playerid, 24, 50);
- GivePlayerWeapon(playerid, 16, 1);
- ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "Choose your spawn:", "Base\nSatellite\nGas Station\nVillage\nTown","Select", ""); //us_choose_spawn
- }
- case 1: //Engineer
- {
- SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You have chosen the Engineer class.");
- GivePlayerWeapon(playerid, 28, 1000);
- GivePlayerWeapon(playerid, 35, 4);
- GivePlayerWeapon(playerid, 16, 1);
- ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "Choose your spawn:", "Base\nSatellite\nGas Station\nVillage\nTown","Select", ""); //us_choose_spawn
- }
- case 2: //Support
- {
- SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You have chosen the Support class.");
- GivePlayerWeapon(playerid, 27, 500);
- GivePlayerWeapon(playerid, 33, 30);
- GivePlayerWeapon(playerid, 16, 1);
- ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "Choose your spawn:", "Base\nSatellite\nGas Station\nVillage\nTown","Select", ""); //us_choose_spawn
- }
- case 3: //Sniper
- {
- SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You have chosen the Sniper class.");
- GivePlayerWeapon(playerid, 34, 300);
- GivePlayerWeapon(playerid, 23, 85);
- GivePlayerWeapon(playerid, 16, 1);
- ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "Choose your spawn:", "Base\nSatellite\nGas Station\nVillage\nTown","Select", ""); //us_choose_spawn
- }
- }
- }
- }
- }
- if(response){
- switch(dialogid){
- case 3:{
- switch(listitem){
- case 0: //Assault
- {
- SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You have chosen the Assault class.");
- GivePlayerWeapon(playerid, 30, 1500);
- GivePlayerWeapon(playerid, 22, 120);
- GivePlayerWeapon(playerid, 16, 1);
- ShowPlayerDialog(playerid, 5, DIALOG_STYLE_LIST, "Choose your spawn:", "Base\nSatellite\nGas Station\nVillage\nTown","Select", ""); //russia_choose_spawn
- }
- case 1: //Engineer
- {
- SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You have chosen the Engineer class.");
- GivePlayerWeapon(playerid, 32, 800);
- GivePlayerWeapon(playerid, 35, 4);
- GivePlayerWeapon(playerid, 16, 1);
- ShowPlayerDialog(playerid, 5, DIALOG_STYLE_LIST, "Choose your spawn:", "Base\nSatellite\nGas Station\nVillage\nTown","Select", ""); //russia_choose_spawn
- }
- case 2: //Support
- {
- SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You have chosen the Support class.");
- GivePlayerWeapon(playerid, 26, 800);
- GivePlayerWeapon(playerid, 33, 35);
- GivePlayerWeapon(playerid, 16, 1);
- ShowPlayerDialog(playerid, 5, DIALOG_STYLE_LIST, "Choose your spawn:", "Base\nSatellite\nGas Station\nVillage\nTown","Select", ""); //russia_choose_spawn
- }
- case 3: //Sniper
- {
- SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You have chosen the Sniper class.");
- GivePlayerWeapon(playerid, 34, 300);
- GivePlayerWeapon(playerid, 23, 85);
- GivePlayerWeapon(playerid, 16, 1);
- ShowPlayerDialog(playerid, 5, DIALOG_STYLE_LIST, "Choose your spawn:", "Base\nSatellite\nGas Station\nVillage\nTown","Select", ""); //russia_choose_spawn
- }
- }
- }
- }
- }
- if(response){
- switch(dialogid){
- case 4:{
- switch(listitem){
- case 0: //US Base
- {
- SetPlayerPos(playerid,285.5240,2037.3401,17.6406);
- TogglePlayerControllable(playerid, 1);
- if(MoneyGiven[playerid] != -1)
- {
- GivePlayerMoney(playerid, MoneyGiven[playerid]);
- MoneyGiven[playerid] = -1;
- }
- //Gives the player money if they haven't received it yet
- if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
- {
- if(!IsRegistered[playerid]) //If the player isn't registered
- {
- ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
- return 0; //Prevents the player from spawning
- }
- if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
- {
- ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
- return 0; //Prevents the player from spawning
- }
- }
- }
- case 1: //Sattelite
- {
- SetPlayerPos(playerid,-314.0954,1544.5754,75.5625);
- TogglePlayerControllable(playerid, 1);
- if(MoneyGiven[playerid] != -1)
- {
- GivePlayerMoney(playerid, MoneyGiven[playerid]);
- MoneyGiven[playerid] = -1;
- }
- //Gives the player money if they haven't received it yet
- if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
- {
- if(!IsRegistered[playerid]) //If the player isn't registered
- {
- ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
- return 0; //Prevents the player from spawning
- }
- if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
- {
- ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
- return 0; //Prevents the player from spawning
- }
- }
- }
- case 2: //Gas Station
- {
- SetPlayerPos(playerid,663.0021,1694.6088,7.1875);
- TogglePlayerControllable(playerid, 1);
- if(MoneyGiven[playerid] != -1)
- {
- GivePlayerMoney(playerid, MoneyGiven[playerid]);
- MoneyGiven[playerid] = -1;
- }
- //Gives the player money if they haven't received it yet
- if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
- {
- if(!IsRegistered[playerid]) //If the player isn't registered
- {
- ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
- return 0; //Prevents the player from spawning
- }
- if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
- {
- ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
- return 0; //Prevents the player from spawning
- }
- }
- }
- case 3: //Village
- {
- SetPlayerPos(playerid,-59.1335,920.0255,21.9530);
- TogglePlayerControllable(playerid, 1);
- if(MoneyGiven[playerid] != -1)
- {
- GivePlayerMoney(playerid, MoneyGiven[playerid]);
- MoneyGiven[playerid] = -1;
- }
- //Gives the player money if they haven't received it yet
- if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
- {
- if(!IsRegistered[playerid]) //If the player isn't registered
- {
- ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
- return 0; //Prevents the player from spawning
- }
- if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
- {
- ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
- return 0; //Prevents the player from spawning
- }
- }
- }
- case 4: //Town
- {
- SetPlayerPos(playerid,-156.3550,1176.6068,19.7422);
- TogglePlayerControllable(playerid, 1);
- if(MoneyGiven[playerid] != -1)
- {
- GivePlayerMoney(playerid, MoneyGiven[playerid]);
- MoneyGiven[playerid] = -1;
- }
- //Gives the player money if they haven't received it yet
- if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
- {
- if(!IsRegistered[playerid]) //If the player isn't registered
- {
- ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
- return 0; //Prevents the player from spawning
- }
- if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
- {
- ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
- return 0; //Prevents the player from spawning
- }
- }
- }
- }
- }
- }
- }
- if(response){
- switch(dialogid){
- case 5:{
- switch(listitem){
- case 0: //Russia Base
- {
- SetPlayerPos(playerid,405.0172,2535.2886,16.5460);
- TogglePlayerControllable(playerid, 1);
- if(MoneyGiven[playerid] != -1)
- {
- GivePlayerMoney(playerid, MoneyGiven[playerid]);
- MoneyGiven[playerid] = -1;
- }
- //Gives the player money if they haven't received it yet
- if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
- {
- if(!IsRegistered[playerid]) //If the player isn't registered
- {
- ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
- return 0; //Prevents the player from spawning
- }
- if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
- {
- ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
- return 0; //Prevents the player from spawning
- }
- }
- }
- case 1: //Sattelite
- {
- SetPlayerPos(playerid,-314.0954,1544.5754,75.5625);
- TogglePlayerControllable(playerid, 1);
- if(MoneyGiven[playerid] != -1)
- {
- GivePlayerMoney(playerid, MoneyGiven[playerid]);
- MoneyGiven[playerid] = -1;
- }
- //Gives the player money if they haven't received it yet
- if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
- {
- if(!IsRegistered[playerid]) //If the player isn't registered
- {
- ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
- return 0; //Prevents the player from spawning
- }
- if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
- {
- ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
- return 0; //Prevents the player from spawning
- }
- }
- }
- case 2: //Gas Station
- {
- SetPlayerPos(playerid,663.0021,1694.6088,7.1875);
- TogglePlayerControllable(playerid, 1);
- if(MoneyGiven[playerid] != -1)
- {
- GivePlayerMoney(playerid, MoneyGiven[playerid]);
- MoneyGiven[playerid] = -1;
- }
- //Gives the player money if they haven't received it yet
- if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
- {
- if(!IsRegistered[playerid]) //If the player isn't registered
- {
- ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
- return 0; //Prevents the player from spawning
- }
- if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
- {
- ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
- return 0; //Prevents the player from spawning
- }
- }
- }
- case 3: //Village
- {
- SetPlayerPos(playerid,-59.1335,920.0255,21.9530);
- TogglePlayerControllable(playerid, 1);
- if(MoneyGiven[playerid] != -1)
- {
- GivePlayerMoney(playerid, MoneyGiven[playerid]);
- MoneyGiven[playerid] = -1;
- }
- //Gives the player money if they haven't received it yet
- if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
- {
- if(!IsRegistered[playerid]) //If the player isn't registered
- {
- ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
- return 0; //Prevents the player from spawning
- }
- if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
- {
- ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
- return 0; //Prevents the player from spawning
- }
- }
- }
- case 4: //Town
- {
- SetPlayerPos(playerid,-156.3550,1176.6068,19.7422);
- TogglePlayerControllable(playerid, 1);
- if(MoneyGiven[playerid] != -1)
- {
- GivePlayerMoney(playerid, MoneyGiven[playerid]);
- MoneyGiven[playerid] = -1;
- }
- //Gives the player money if they haven't received it yet
- if(!Logged[playerid]) //If the player isn't logged in and (s)he tries to spawn.
- {
- if(!IsRegistered[playerid]) //If the player isn't registered
- {
- ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:You must register before spawning!","Register","Cancel"); //Shows our register dialog :).
- return 0; //Prevents the player from spawning
- }
- if(IsRegistered[playerid] == 1) //Our handy variable comes into use now
- {
- ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
- return 0; //Prevents the player from spawning
- }
- }
- }
- }
- }
- }
- }
- {
- }
- if(dialogid == 6) //If Dialog is our register dialog
- {
- if(response) //If they click the button register
- {
- if(!strlen(inputtext) || strlen(inputtext) > 100) //Password is not 1 to 100 characters
- {
- SendClientMessage(playerid, 0x7D7D7FFF, "iBot: You must insert a password between 1-100 characters!"); //Sends the client a error message
- ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Register","Your user is not registered! Please register with a password below!\n {FF0000}ERROR:Please enter a password between 1-100 characters!","Register",""); //Shows our register dialog :).
- }
- else if(strlen(inputtext) > 0 && strlen(inputtext) < 100)
- {
- new escpass[100];
- mysql_real_escape_string(inputtext, escpass);
- MySQL_Register(playerid, escpass);
- new password[128];
- format(password, sizeof(password), "iBot: You registered with password: %s", inputtext);
- }
- //If the password is between 1 and 100 characters then we will
- //call our MySQL_register function which will register the player.
- }
- }
- if(dialogid == 7) //Dialog login
- {
- if(response) //If the player clicked login
- {
- new query[200], pname[24], escapepass[100]; //
- GetPlayerName(playerid, pname, 24); //Gets the players name
- mysql_real_escape_string(inputtext, escapepass); //We escape the inputtext to avoid SQL injections.
- format(query, sizeof(query), "SELECT `user` FROM playerdata WHERE user = '%s' AND password = SHA1('%s')", pname, escapepass);
- mysql_query(query);
- mysql_store_result();
- new numrows = mysql_num_rows();
- if(numrows == 1) MySQL_Login(playerid);
- //This means that there is a user in the database with the same
- //password that we typed, we now proceed by using the login function.
- if(!numrows)
- {
- //This means that the password that the player
- //typed was incorrect and we will resend the dialog.
- //ShowPlayerDialog(playerid, 7, DIALOG_STYLE_INPUT, "Login","Your user is registered! Please login with your password below!\n{FF0000} The password you typed was incorrect!","Login","Cancel"); //Shows our login dialog :).
- SendClientMessage(playerid, 0x7D7D7FFF, "iBot: Incorrect password!"); //Sends the client a error message
- Kick(playerid);
- }
- mysql_free_result(); //Remember to always free a result if you stored one!
- }
- }
- if(dialogid == 8) //Make Moderator
- {
- if(response) //If the player clicked GO!
- {
- /*new string[4] = (inputtext[8]);
- new Iplayerid = strval(string);
- SetPVarInt(Iplayerid, "AdminLevel", 3);
- new string1[24];
- format(string1, sizeof(string1), "iBot: You have made ID %d a moderator. If this was a mistake, please use /makeregular.", Iplayerid);
- SendClientMessage(playerid, iBot, string1);
- SendClientMessage(Iplayerid, iBot, "iBot: You are now a moderator! /moderator to view your commands.");*/
- if (IsNumeric(inputtext))
- {
- print("test worked");
- new playerIDFS = strval(inputtext);
- SetPVarInt(playerIDFS,"AdminLevel",3);
- new clientMessage[240];
- format(clientMessage,240,retMessPl, playerIDFS);
- SendClientMessage(playerid, iBot, clientMessage);
- SendClientMessage(playerIDFS, iBot, retMessBt);
- }
- }
- }
- if(dialogid == 9) //Make Admin
- {
- if(response) //If the player clicked GO!
- {
- //
- new youmadeadmin[24];
- format(youmadeadmin, sizeof(youmadeadmin), "iBot: You have made ID %s an admin. If this was a mistake, please use /makeregular.", inputtext[9]);
- SendClientMessage(playerid, iBot, youmadeadmin);
- SendClientMessage(inputtext[8], iBot, "iBot: You are now an admin! /admincmds to view your commands.");
- }
- }
- if(dialogid == 10) //Make Supervisor
- {
- if(response) //If the player clicked GO!
- {
- //
- new youmadeadmin[24];
- format(youmadeadmin, sizeof(youmadeadmin), "iBot: You have made ID %s a supervisor. If this was a mistake, please use /makeregular.", inputtext[10]);
- SendClientMessage(playerid, iBot, youmadeadmin);
- SendClientMessage(inputtext[8], iBot, "iBot: You are now a supervisor! /supervisorcmds to view your commands.");
- }
- }
- if(dialogid == 11) //Make Regular
- {
- if(response) //If the player clicked GO!
- {
- //
- new string[24];
- format(string, sizeof(string), "iBot: You have made ID %s a regular player. If this was a mistake, please use /makeadmin, /makemoderator or /makesupervisor.", inputtext[11]);
- SendClientMessage(playerid, iBot, string);
- SendClientMessage(inputtext[11], iBot, "iBot: You are now a regular player! /cmds to view your commands.");
- }
- }
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
Add Comment
Please, Sign In to add comment