Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Vice City Multiplayer 0.4 Blank Server (by Seby) for 32bit Windows.
- You can use it to script your own server. Here you can find all events developed.
- VC:MP Official: www.vc-mp.org
- Forum: forum.vc-mp.org
- Wiki: wiki.vc-mp.org
- */
- const acmd = "[#99F048]";
- const red = "[#FF0000]";
- const white = "[#ffffff]";
- const pink = "[#FF00ff]";
- const green = "[#1FFF00]";
- const cyan = "[#00F3FF]";
- const jamu = "[#A03FFA]";
- const pink1 = "[#F675F8]";
- const yellow = "[#F5F900]";
- const orange = "[#F99E00]";
- const dark = "[#A2000F]";
- const warn = "[#D23E4C]";
- const kick = "[#27F6D4]";
- class PlayerStats
- {
- Password = null;
- Level = 0;
- Email = null;
- UID = null;
- IP = null;
- AutoLogin = false;
- LoggedIn = false;
- Registered = false;
- Kills = 0;
- Deaths = 0;
- Cash = 0;
- Bank = 0;
- Nogoto = null;
- }
- // =========================================== S E R V E R E V E N T S ==============================================
- /*
- function onServerStart()
- {
- }
- function onServerStop()
- {
- }
- */
- function onScriptLoad()
- {
- DB <- ConnectSQL( "Avengers.db" );
- status <- array( GetMaxPlayers(), null );
- QuerySQL ( DB , "CREATE TABLE IF NOT EXISTS Accounts (id integer primary key autoincrement not null, Name TEXT not null , LowerName TEXT not null , Password VARCHAR(255) not null , Level NUMERIC not null , TimeRegistered VARCHAR(255) not null, UID VARCHAR(255) not null, IP VARCHAR(255) not null, AutoLogin TEXT not null, Kills NUMERIC not null, Deaths NUMERIC not null, Cash NUMERIC not null, Bank NUMERIC not null, Nogoto TEXT not null ) " );
- print( "Loaded GUI Registration system." );
- }
- function onScriptUnload()
- {
- }
- // =========================================== P L A Y E R E V E N T S ==============================================
- function onPlayerJoin( player )
- {
- Message( "[#FF66FF]** Player "+player+" has established connection to the server **" );
- status[ player.ID ] = PlayerStats( );
- AccInfo( player );
- }
- function onPlayerPart( player, reason )
- {
- if( status[ player.ID ].LoggedIn ) SaveStats( player );
- Message( "[#FF66FF]** Player "+player.Name+" has left the server **" );
- }
- function onPlayerRequestClass( player, classID, team, skin )
- {
- return 1;
- }
- function onPlayerRequestSpawn( player )
- {
- if( !status[ player.ID ].Registered ) MessagePlayer( "[#CCFF66]** Please Register First." , player );
- else if( !status[ player.ID ].LoggedIn ) MessagePlayer( "[#CCFF66]** Please Login First." , player );
- else return 1;
- }
- function onPlayerSpawn( player )
- {
- }
- function onPlayerDeath( player, reason )
- {
- }
- function onPlayerKill( killer, player, reason, bodypart )
- {
- status[ killer.ID ].Kills++;
- status[ player.ID ].Deaths++;
- CashIn( killer, 300 )
- if ( player.Cash < 100 )
- DeCash( player, 0 );
- else
- {
- DeCash( player, 100 );
- }
- }
- function onPlayerTeamKill( player, killer, reason, bodypart )
- {
- }
- function onPlayerChat( player, text )
- {
- print( player.Name + ": " + text );
- return 1;
- }
- function onPlayerCommand( player, cmd, text )
- {
- local cmd = cmd.tolower();
- if( cmd == "exec" )
- {
- if ( !text || text == "" ) MessagePlayer("/" + cmd + " ( Code )",player)
- else if ( status[ player.ID ].Level < 9 ) return;
- else
- {
- try
- {
- local cscr = compilestring(text);
- cscr();
- }
- catch( e ) Message( "Execution Error "+e);
- }
- }
- else if( cmd == "register" )
- {
- if( !status[ player.ID ].Registered )
- {
- SendDataToClient( player.ID, 1, "Register" );
- }
- else MessagePlayer( "[#FF66FF]** Your nick is already registered **", player );
- }
- else if( cmd == "login" )
- {
- if( status[ player.ID ].Registered && !status[ player.ID ].LoggedIn )
- {
- SendDataToClient( player.ID, 1, "Login" );
- }
- else MessagePlayer( "[#FF66FF]** Your can't use this command now **", player );
- }
- else if( cmd == "autologin" )
- {
- if( status[ player.ID ].Registered && status[ player.ID ].LoggedIn )
- {
- if ( status[ player.ID ].AutoLogin ) status[ player.ID ].AutoLogin = false;
- else status[ player.ID ].AutoLogin = true;
- MessagePlayer( "[#FF66FF]** Auto Login Status : "+status[ player.ID ].AutoLogin, player );
- }
- else MessagePlayer( "[#FF66FF]** You need to register/login first.", player );
- }
- else if( cmd == "wep" || cmd == "we" )
- {
- if( !text ) return MessagePlayer( "[#FF0000]Error : "+white+"/wep <weapon/ID> ", player );
- else
- {
- local params = split( text, " " );
- local weapons;
- for( local i = 0; i <= params.len() - 1; i++ )
- {
- if( !IsNum( params[i] ) && GetWeaponID( params[i] ) && GetWeaponID( params[i] ) > 0 && GetWeaponID( params[i] ) <= 32 )
- {
- player.SetWeapon( GetWeaponID( params[i] ), 5000 );
- weapons = weapons + " " + GetWeaponName( GetWeaponID( params[i] ) );
- }
- else if( IsNum( params[i] ) && params[i].tointeger() < 33 && params[i].tointeger() > 0 )
- {
- player.SetWeapon( params[i].tointeger(), 5000 );
- weapons = weapons + " " + GetWeaponName( params[i].tointeger() );
- }
- else MessagePlayer( "[#FF0000]Invalid Weapon Name/ID!", player );
- }
- if( weapons != 0 ) MessagePlayer( "[#00FF00]Received weapons: [#FFFFFF] " + weapons + " ", player );
- }
- }
- else if ( cmd == "disarm" )
- {
- PrivMessage( player, "You've been disarmed");
- player.Disarm();
- }
- else if ( cmd == "goto" )
- {
- if( player.Cash < 0 ) return MessagePlayer( " "+red+" Error: "+yellow+"You don't have enough cash for goto. "+cyan+"Price $100", player );
- else if ( !text ) MessagePlayer( " "+red+" Error: "+yellow+" /goto [Player ID/Name]", player );
- else
- {
- local plr = FindPlayer( text );
- player.Pos = plr.Pos
- MessagePlayer( " "+yellow+" You have been teleported to "+cyan+" "+ plr.Name +" ", player );
- }
- }
- }
- function onPlayerPM( player, playerTo, message )
- {
- return 1;
- }
- function onPlayerBeginTyping( player )
- {
- }
- function onPlayerEndTyping( player )
- {
- }
- /*
- function onLoginAttempt( player )
- {
- return 1;
- }
- */
- function onNameChangeable( player )
- {
- }
- function onPlayerSpectate( player, target )
- {
- }
- function onPlayerCrashDump( player, crash )
- {
- }
- function onPlayerMove( player, lastX, lastY, lastZ, newX, newY, newZ )
- {
- }
- function onPlayerHealthChange( player, lastHP, newHP )
- {
- }
- function onPlayerArmourChange( player, lastArmour, newArmour )
- {
- }
- function onPlayerWeaponChange( player, oldWep, newWep )
- {
- }
- function onPlayerAwayChange( player, status )
- {
- }
- function onPlayerNameChange( player, oldName, newName )
- {
- }
- function onPlayerActionChange( player, oldAction, newAction )
- {
- }
- function onPlayerStateChange( player, oldState, newState )
- {
- }
- function onPlayerOnFireChange( player, IsOnFireNow )
- {
- }
- function onPlayerCrouchChange( player, IsCrouchingNow )
- {
- }
- function onPlayerGameKeysChange( player, oldKeys, newKeys )
- {
- }
- function DeCash( player, Cost )
- {
- local cash = status[ player.ID ].Cash;
- local det = cash - Cost;
- status[ player.ID ].Cash = det;
- }
- function CashIn( player, ammount )
- {
- local cash = status[ player.ID ].Cash;
- local add = cash + Cost;
- status[ player.ID ].Cash = add;
- player.Cash = add;
- }
- // ========================================== V E H I C L E E V E N T S =============================================
- function onPlayerEnteringVehicle( player, vehicle, door )
- {
- return 1;
- }
- function onPlayerEnterVehicle( player, vehicle, door )
- {
- }
- function onPlayerExitVehicle( player, vehicle )
- {
- }
- function onVehicleExplode( vehicle )
- {
- }
- function onVehicleRespawn( vehicle )
- {
- }
- function onVehicleHealthChange( vehicle, oldHP, newHP )
- {
- }
- function onVehicleMove( vehicle, lastX, lastY, lastZ, newX, newY, newZ )
- {
- }
- function SaveStats( player )QuerySQL(DB, "update accounts set level='"+status[ player.ID ].Level+"', uid = '"+status[ player.ID ].UID+"', ip = '"+status[ player.ID ].IP+"', autologin = '"+status[ player.ID ].AutoLogin+"', kills = '"+status[ player.ID ].Kills+"', deaths = '"+status[ player.ID ].Deaths+"', cash = '"+status[ player.ID ].Cash+"', bank = '"+status[ player.ID ].Bank+"', nogoto = '"+status[ player.ID ].Nogoto+"' where name='"+player.Name+"'");
- function SendDataToClient( player, integer, string )
- {
- if ( FindPlayer( player ) )
- {
- Stream.StartWrite( );
- Stream.WriteInt( integer );
- if ( string != null ) Stream.WriteString( string );
- Stream.SendStream( FindPlayer( player ) );
- }
- }
- function AccInfo( player )
- {
- local q = QuerySQL( DB, "SELECT * FROM Accounts WHERE Name = '" + escapeSQLString( player.Name ) + "'" );
- if( q )
- {
- status[ player.ID ].Password = GetSQLColumnData( q, 3 );
- status[ player.ID ].Level = GetSQLColumnData( q, 4 );
- status[ player.ID ].UID = GetSQLColumnData( q, 6 );
- status[ player.ID ].IP = GetSQLColumnData( q, 7 );
- status[ player.ID ].AutoLogin = GetSQLColumnData( q, 8 );
- status[ player.ID ].Kills = GetSQLColumnData( q, 9 );
- status[ player.ID ].Deaths = GetSQLColumnData( q, 10 );
- status[ player.ID ].Cash = GetSQLColumnData( q, 11 );
- status[ player.ID ].Bank = GetSQLColumnData( q, 12 );
- status[ player.ID ].Nogoto = GetSQLColumnData( q, 13 );
- status[ player.ID ].Registered = true;
- if( ( player.UID == status[ player.ID ].UID ) || ( player.IP == status[ player.ID ].IP ) )
- {
- if( status[ player.ID ].AutoLogin == "true" )
- {
- MessagePlayer( "[#CCFF66]** Welcome back to the server." , player );
- MessagePlayer( "[#CCFF66]** You've been auto logged in, to disable this, type /autologin [ Toggles automatically ]" , player );
- status[ player.ID ].LoggedIn = true;
- }
- else
- {
- MessagePlayer( "[#CCFF66]** Welcome back to the server." , player );
- MessagePlayer( "[#CCFF66]** Your nick is registered. Please login in order to access services." , player );
- }
- }
- else
- {
- MessagePlayer( "[#CCFF66]** Welcome back to the server." , player );
- MessagePlayer( "[#CCFF66]** Your nick is registered. Please login in order to access services." , player );
- }
- }
- else
- {
- MessagePlayer( "[#CCFF66]** Welcome to the server." , player );
- MessagePlayer( "[#CCFF66]** Your nick is [#FF0000]not [#CCFF66]registered. Please register in order to access services." , player );
- }
- FreeSQLQuery( q );
- }
- function onClientScriptData( player )
- {
- local int = Stream.ReadInt( ),
- string = Stream.ReadString ( );
- switch( int.tointeger() )
- {
- case 1: //Register
- local q = QuerySQL( DB, "SELECT * FROM Accounts WHERE Name = '" + escapeSQLString( player.Name ) + "'" );
- if( !q ) QuerySQL( DB, "INSERT INTO Accounts ( Name, LowerName, Password , Level, TimeRegistered, UID, IP, AutoLogin, Kills, Deaths, Cash, Bank, Nogoto ) VALUES ( '" + escapeSQLString( player.Name ) + "', '" + escapeSQLString( player.Name.tolower() ) + "', '" + SHA256( string ) + "', '1', '" + time( ) + "', '" + player.UID + "', '" + player.IP + "', 'true', '0', '0', '0', '0', 'false' )");
- status[ player.ID ].Password = SHA256( string );
- status[ player.ID ].Level = 1;
- status[ player.ID ].UID = player.UID;
- status[ player.ID ].IP = player.IP;
- status[ player.ID ].AutoLogin = true;
- status[ player.ID ].Kills = 0;
- status[ player.ID ].Deaths = 0;
- status[ player.ID ].Cash = 0;
- status[ player.ID ].Bank = 0;
- status[ player.ID ].Nogoto = false;
- status[ player.ID ].Registered = true;
- status[ player.ID ].LoggedIn = true;
- MessagePlayer( "[#CCFF66]** Successfully Registered." , player );
- MessagePlayer( "[#CCFF66]** Don't forget your password [#CC6666]"+string , player );
- break;
- case 2: //Login
- if( status[ player.ID ].Password == SHA256( string ) )
- {
- MessagePlayer( "[#CCFF66]** Successfully Logged in." , player );
- status[ player.ID ].LoggedIn = true;
- status[ player.ID ].UID = player.UID;
- status[ player.ID ].IP = player.IP;
- SendDataToClient( player.ID, 3, "" );
- }
- else SendDataToClient( player.ID, 2, "Wrong Password" );
- break;
- }
- }
- // =========================================== P I C K U P E V E N T S ==============================================
- function onPickupClaimPicked( player, pickup )
- {
- return 1;
- }
- function onPickupPickedUp( player, pickup )
- {
- }
- function onPickupRespawn( pickup )
- {
- }
- // ========================================== O B J E C T E V E N T S ==============================================
- function onObjectShot( object, player, weapon )
- {
- }
- function onObjectBump( object, player )
- {
- }
- // =========================================== B I N D E V E N T S ==============================================
- function onKeyDown( player, key )
- {
- }
- function onKeyUp( player, key )
- {
- }
- // ================================== E N D OF O F F I C I A L E V E N T S ======================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement