MuhammadZeeshan

fffff

Jun 15th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.09 KB | None | 0 0
  1. /*
  2. Vice City Multiplayer 0.4 Blank Server (by Seby) for 32bit Windows.
  3. You can use it to script your own server. Here you can find all events developed.
  4.  
  5. VC:MP Official: www.vc-mp.org
  6. Forum: forum.vc-mp.org
  7. Wiki: wiki.vc-mp.org
  8. */
  9. const acmd = "[#99F048]";
  10. const red = "[#FF0000]";
  11. const white = "[#ffffff]";
  12. const pink = "[#FF00ff]";
  13. const green = "[#1FFF00]";
  14. const cyan = "[#00F3FF]";
  15. const jamu = "[#A03FFA]";
  16. const pink1 = "[#F675F8]";
  17. const yellow = "[#F5F900]";
  18. const orange = "[#F99E00]";
  19. const dark = "[#A2000F]";
  20. const warn = "[#D23E4C]";
  21. const kick = "[#27F6D4]";
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. class PlayerStats
  32. {
  33. Password = null;
  34. Level = 0;
  35. Email = null;
  36. UID = null;
  37. IP = null;
  38. AutoLogin = false;
  39. LoggedIn = false;
  40. Registered = false;
  41. Kills = 0;
  42. Deaths = 0;
  43. Cash = 0;
  44. Bank = 0;
  45. Nogoto = null;
  46.  
  47. }
  48.  
  49.  
  50. // =========================================== S E R V E R E V E N T S ==============================================
  51.  
  52. /*
  53. function onServerStart()
  54. {
  55. }
  56.  
  57. function onServerStop()
  58. {
  59. }
  60. */
  61.  
  62. function onScriptLoad()
  63. {
  64.  
  65.  
  66. DB <- ConnectSQL( "Avengers.db" );
  67. status <- array( GetMaxPlayers(), null );
  68. 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 ) " );
  69. print( "Loaded GUI Registration system." );
  70.  
  71.  
  72. }
  73.  
  74. function onScriptUnload()
  75. {
  76. }
  77.  
  78. // =========================================== P L A Y E R E V E N T S ==============================================
  79.  
  80. function onPlayerJoin( player )
  81. {
  82.  
  83. Message( "[#FF66FF]** Player "+player+" has established connection to the server **" );
  84. status[ player.ID ] = PlayerStats( );
  85. AccInfo( player );
  86.  
  87. }
  88.  
  89. function onPlayerPart( player, reason )
  90. {
  91.  
  92. if( status[ player.ID ].LoggedIn ) SaveStats( player );
  93. Message( "[#FF66FF]** Player "+player.Name+" has left the server **" );
  94.  
  95. }
  96.  
  97. function onPlayerRequestClass( player, classID, team, skin )
  98. {
  99. return 1;
  100. }
  101.  
  102. function onPlayerRequestSpawn( player )
  103. {
  104. if( !status[ player.ID ].Registered ) MessagePlayer( "[#CCFF66]** Please Register First." , player );
  105. else if( !status[ player.ID ].LoggedIn ) MessagePlayer( "[#CCFF66]** Please Login First." , player );
  106. else return 1;
  107. }
  108.  
  109. function onPlayerSpawn( player )
  110. {
  111. }
  112.  
  113. function onPlayerDeath( player, reason )
  114. {
  115. }
  116.  
  117. function onPlayerKill( killer, player, reason, bodypart )
  118. {
  119.  
  120. status[ killer.ID ].Kills++;
  121. status[ player.ID ].Deaths++;
  122.  
  123. CashIn( killer, 300 )
  124. if ( player.Cash < 100 )
  125. DeCash( player, 0 );
  126. else
  127. {
  128. DeCash( player, 100 );
  129. }
  130. }
  131.  
  132. function onPlayerTeamKill( player, killer, reason, bodypart )
  133. {
  134. }
  135.  
  136. function onPlayerChat( player, text )
  137. {
  138. print( player.Name + ": " + text );
  139. return 1;
  140. }
  141.  
  142. function onPlayerCommand( player, cmd, text )
  143. {
  144. local cmd = cmd.tolower();
  145. if( cmd == "exec" )
  146. {
  147. if ( !arguments || arguments == "" ) ErrorSyntax("/" + cmd + " ( Code )",player)
  148. else if ( status[ player.ID ].Level < 9 ) return;
  149. else
  150. {
  151. try
  152. {
  153. local cscr = compilestring(arguments);
  154. cscr();
  155. }
  156. catch( e ) Message( "Execution Error "+e);
  157. }
  158. }
  159. else if( cmd == "register" )
  160. {
  161. if( !status[ player.ID ].Registered )
  162. {
  163. SendDataToClient( player.ID, 1, "Register" );
  164. }
  165. else MessagePlayer( "[#FF66FF]** Your nick is already registered **", player );
  166. }
  167. else if( cmd == "login" )
  168. {
  169. if( status[ player.ID ].Registered && !status[ player.ID ].LoggedIn )
  170. {
  171. SendDataToClient( player.ID, 1, "Login" );
  172. }
  173. else MessagePlayer( "[#FF66FF]** Your can't use this command now **", player );
  174. }
  175. else if( cmd == "autologin" )
  176. {
  177. if( status[ player.ID ].Registered && status[ player.ID ].LoggedIn )
  178. {
  179. if ( status[ player.ID ].AutoLogin ) status[ player.ID ].AutoLogin = false;
  180. else status[ player.ID ].AutoLogin = true;
  181. MessagePlayer( "[#FF66FF]** Auto Login Status : "+status[ player.ID ].AutoLogin, player );
  182. }
  183. else MessagePlayer( "[#FF66FF]** You need to register/login first.", player );
  184. }
  185.  
  186.  
  187. if( cmd == "wep" || cmd == "we" )
  188. {
  189. if( !text ) return MessagePlayer( "[#FF0000]Error : "+white+"/wep <weapon/ID> ", player );
  190. else
  191. {
  192. local params = split( text, " " );
  193. local weapons;
  194. for( local i = 0; i <= params.len() - 1; i++ )
  195. {
  196. if( !IsNum( params[i] ) && GetWeaponID( params[i] ) && GetWeaponID( params[i] ) > 0 && GetWeaponID( params[i] ) <= 32 )
  197. {
  198. player.SetWeapon( GetWeaponID( params[i] ), 5000 );
  199. weapons = weapons + " " + GetWeaponName( GetWeaponID( params[i] ) );
  200. }
  201. else if( IsNum( params[i] ) && params[i].tointeger() < 33 && params[i].tointeger() > 0 )
  202. {
  203. player.SetWeapon( params[i].tointeger(), 5000 );
  204. weapons = weapons + " " + GetWeaponName( params[i].tointeger() );
  205. }
  206. else MessagePlayer( "[#FF0000]Invalid Weapon Name/ID!", player );
  207. }
  208.  
  209. if( weapons != 0 ) MessagePlayer( "[#00FF00]Received weapons: [#FFFFFF] " + weapons + " ", player );
  210. }
  211. }
  212.  
  213.  
  214. if ( cmd == "disarm" )
  215. {
  216. PrivMessage( player, "You've been disarmed");
  217. player.Disarm();
  218. }
  219. else if ( cmd == "goto" )
  220. {
  221. if( player.Cash < 0 ) return MessagePlayer( " "+red+" Error: "+yellow+"You don't have enough cash for goto. "+cyan+"Price $100", player );
  222. else if ( !text ) MessagePlayer( " "+red+" Error: "+yellow+" /goto [Player ID/Name]", player );
  223. else
  224. {
  225. local plr = FindPlayer( text );
  226. player.Pos = plr.Pos
  227. MessagePlayer( " "+yellow+" You have been teleported to "+cyan+" "+ plr.Name +" ", player );
  228. }
  229.  
  230.  
  231. }
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242. }
  243.  
  244. function onPlayerPM( player, playerTo, message )
  245. {
  246. return 1;
  247. }
  248.  
  249. function onPlayerBeginTyping( player )
  250. {
  251. }
  252.  
  253. function onPlayerEndTyping( player )
  254. {
  255. }
  256.  
  257. /*
  258. function onLoginAttempt( player )
  259. {
  260. return 1;
  261. }
  262. */
  263.  
  264. function onNameChangeable( player )
  265. {
  266. }
  267.  
  268. function onPlayerSpectate( player, target )
  269. {
  270. }
  271.  
  272. function onPlayerCrashDump( player, crash )
  273. {
  274. }
  275.  
  276. function onPlayerMove( player, lastX, lastY, lastZ, newX, newY, newZ )
  277. {
  278. }
  279.  
  280. function onPlayerHealthChange( player, lastHP, newHP )
  281. {
  282. }
  283.  
  284. function onPlayerArmourChange( player, lastArmour, newArmour )
  285. {
  286. }
  287.  
  288. function onPlayerWeaponChange( player, oldWep, newWep )
  289. {
  290. }
  291.  
  292. function onPlayerAwayChange( player, status )
  293. {
  294. }
  295.  
  296. function onPlayerNameChange( player, oldName, newName )
  297. {
  298. }
  299.  
  300. function onPlayerActionChange( player, oldAction, newAction )
  301. {
  302. }
  303.  
  304. function onPlayerStateChange( player, oldState, newState )
  305. {
  306. }
  307.  
  308. function onPlayerOnFireChange( player, IsOnFireNow )
  309. {
  310. }
  311.  
  312. function onPlayerCrouchChange( player, IsCrouchingNow )
  313. {
  314. }
  315.  
  316. function onPlayerGameKeysChange( player, oldKeys, newKeys )
  317. {
  318. }
  319.  
  320. function DeCash( player, Cost )
  321. {
  322. local cash = status[ player.ID ].Cash;
  323. local det = cash - Cost;
  324. status[ player.ID ].Cash = det;
  325. }
  326. function CashIn( player, ammount )
  327. {
  328. local cash = status[ player.ID ].Cash;
  329. local add = cash + Cost;
  330. status[ player.ID ].Cash = add;
  331. player.Cash = add;
  332.  
  333.  
  334. }
  335. // ========================================== V E H I C L E E V E N T S =============================================
  336.  
  337. function onPlayerEnteringVehicle( player, vehicle, door )
  338. {
  339. return 1;
  340. }
  341.  
  342. function onPlayerEnterVehicle( player, vehicle, door )
  343. {
  344. }
  345.  
  346. function onPlayerExitVehicle( player, vehicle )
  347. {
  348. }
  349.  
  350. function onVehicleExplode( vehicle )
  351. {
  352. }
  353.  
  354. function onVehicleRespawn( vehicle )
  355. {
  356. }
  357.  
  358. function onVehicleHealthChange( vehicle, oldHP, newHP )
  359. {
  360. }
  361.  
  362. function onVehicleMove( vehicle, lastX, lastY, lastZ, newX, newY, newZ )
  363. {
  364. }
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372. function SaveStats( player )
  373. {
  374. QuerySQL(DB,
  375. format(@"UPDATE [Accounts] SET
  376. [Level]='%s',
  377. [UID]='%s',
  378. [IP]='%s',
  379. [AutoLogin]='%s',
  380. [Kills] ='%s',
  381. [Deaths] ='%s',
  382. [Cash] ='%s',
  383. [Bank] ='%s',
  384. [Nogoto] ='%s',
  385. WHERE [Name]='%s' AND [LowerName]='%s';",
  386. status[ player.ID ].Level.tostring(),
  387. status[ player.ID ].UID.tostring(),
  388. status[ player.ID ].IP.tostring(),
  389. status[ player.ID ].AutoLogin.tostring(),
  390. status[ player.ID ].Kills.tostring(),
  391. status[ player.ID ].Deaths.tostring(),
  392. status[ player.ID ].Cash.tostring(),
  393. status[ player.ID ].Bank.tostring(),
  394. status[ player.ID ].Nogoto.tostring(),
  395. player.Name,
  396. player.Name.tolower()
  397. )
  398. );
  399. }
  400.  
  401.  
  402. function SendDataToClient( player, integer, string )
  403. {
  404.  
  405. if ( FindPlayer( player ) )
  406. {
  407.  
  408. Stream.StartWrite( );
  409. Stream.WriteInt( integer );
  410. if ( string != null ) Stream.WriteString( string );
  411. Stream.SendStream( FindPlayer( player ) );
  412.  
  413. }
  414. }
  415. function AccInfo( player )
  416. {
  417. local q = QuerySQL( DB, "SELECT * FROM Accounts WHERE Name = '" + escapeSQLString( player.Name ) + "'" );
  418. if( q )
  419. {
  420. status[ player.ID ].Password = GetSQLColumnData( q, 3 );
  421. status[ player.ID ].Level = GetSQLColumnData( q, 4 );
  422. status[ player.ID ].UID = GetSQLColumnData( q, 6 );
  423. status[ player.ID ].IP = GetSQLColumnData( q, 7 );
  424. status[ player.ID ].AutoLogin = GetSQLColumnData( q, 8 );
  425. status[ player.ID ].Kills = GetSQLColumnData( q, 9 );
  426. status[ player.ID ].Deaths = GetSQLColumnData( q, 10 );
  427. status[ player.ID ].Cash = GetSQLColumnData( q, 11 );
  428. status[ player.ID ].Bank = GetSQLColumnData( q, 12 );
  429. status[ player.ID ].Nogoto = GetSQLColumnData( q, 13 );
  430.  
  431. status[ player.ID ].Registered = true;
  432. if( ( player.UID == status[ player.ID ].UID ) || ( player.IP == status[ player.ID ].IP ) )
  433. {
  434. if( status[ player.ID ].AutoLogin == "true" )
  435. {
  436. MessagePlayer( "[#CCFF66]** Welcome back to the server." , player );
  437. MessagePlayer( "[#CCFF66]** You've been auto logged in, to disable this, type /autologin [ Toggles automatically ]" , player );
  438. status[ player.ID ].LoggedIn = true;
  439. }
  440. else
  441. {
  442. MessagePlayer( "[#CCFF66]** Welcome back to the server." , player );
  443. MessagePlayer( "[#CCFF66]** Your nick is registered. Please login in order to access services." , player );
  444. }
  445. }
  446. else
  447. {
  448. MessagePlayer( "[#CCFF66]** Welcome back to the server." , player );
  449. MessagePlayer( "[#CCFF66]** Your nick is registered. Please login in order to access services." , player );
  450. }
  451. }
  452. else
  453. {
  454. MessagePlayer( "[#CCFF66]** Welcome to the server." , player );
  455. MessagePlayer( "[#CCFF66]** Your nick is [#FF0000]not [#CCFF66]registered. Please register in order to access services." , player );
  456. }
  457. FreeSQLQuery( q );
  458. }
  459.  
  460. function onClientScriptData( player )
  461. {
  462. local int = Stream.ReadInt( ),
  463. string = Stream.ReadString ( );
  464. switch( int.tointeger() )
  465. {
  466. case 1: //Register
  467. local q = QuerySQL( DB, "SELECT * FROM Accounts WHERE Name = '" + escapeSQLString( player.Name ) + "'" );
  468. 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' )");
  469. status[ player.ID ].Password = SHA256( string );
  470. status[ player.ID ].Level = 1;
  471. status[ player.ID ].UID = player.UID;
  472. status[ player.ID ].IP = player.IP;
  473. status[ player.ID ].AutoLogin = true;
  474. status[ player.ID ].Kills = 0;
  475. status[ player.ID ].Deaths = 0;
  476. status[ player.ID ].Cash = 0;
  477. status[ player.ID ].Bank = 0;
  478. status[ player.ID ].Nogoto = false;
  479. status[ player.ID ].Registered = true;
  480. status[ player.ID ].LoggedIn = true;
  481. MessagePlayer( "[#CCFF66]** Successfully Registered." , player );
  482. MessagePlayer( "[#CCFF66]** Don't forget your password [#CC6666]"+string , player );
  483.  
  484. break;
  485.  
  486. case 2: //Login
  487.  
  488. if( status[ player.ID ].Password == SHA256( string ) )
  489. {
  490. MessagePlayer( "[#CCFF66]** Successfully Logged in." , player );
  491. status[ player.ID ].LoggedIn = true;
  492. status[ player.ID ].UID = player.UID;
  493. status[ player.ID ].IP = player.IP;
  494. SendDataToClient( player.ID, 3, "" );
  495. }
  496. else SendDataToClient( player.ID, 2, "Wrong Password" );
  497.  
  498. break;
  499. }
  500.  
  501.  
  502.  
  503.  
  504.  
  505. }
  506.  
  507. // =========================================== P I C K U P E V E N T S ==============================================
  508.  
  509. function onPickupClaimPicked( player, pickup )
  510. {
  511. return 1;
  512. }
  513.  
  514. function onPickupPickedUp( player, pickup )
  515. {
  516. }
  517.  
  518. function onPickupRespawn( pickup )
  519. {
  520. }
  521.  
  522. // ========================================== O B J E C T E V E N T S ==============================================
  523.  
  524. function onObjectShot( object, player, weapon )
  525. {
  526. }
  527.  
  528. function onObjectBump( object, player )
  529. {
  530. }
  531.  
  532. // =========================================== B I N D E V E N T S ==============================================
  533.  
  534. function onKeyDown( player, key )
  535. {
  536. }
  537.  
  538. function onKeyUp( player, key )
  539. {
  540. }
  541.  
  542. // ================================== E N D OF O F F I C I A L E V E N T S ======================================
Add Comment
Please, Sign In to add comment