Advertisement
Anik1204

Rizwan's Error fix - Anik

Jun 15th, 2017
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.74 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 ( !text || text == "" ) MessagePlayer("/" + cmd + " ( Code )",player)
  148. else if ( status[ player.ID ].Level < 9 ) return;
  149. else
  150. {
  151. try
  152. {
  153. local cscr = compilestring(text);
  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. else if( cmd == "wep" || cmd == "we" )
  187. {
  188. if( !text ) return MessagePlayer( "[#FF0000]Error : "+white+"/wep <weapon/ID> ", player );
  189. else
  190. {
  191. local params = split( text, " " );
  192. local weapons;
  193. for( local i = 0; i <= params.len() - 1; i++ )
  194. {
  195. if( !IsNum( params[i] ) && GetWeaponID( params[i] ) && GetWeaponID( params[i] ) > 0 && GetWeaponID( params[i] ) <= 32 )
  196. {
  197. player.SetWeapon( GetWeaponID( params[i] ), 5000 );
  198. weapons = weapons + " " + GetWeaponName( GetWeaponID( params[i] ) );
  199. }
  200. else if( IsNum( params[i] ) && params[i].tointeger() < 33 && params[i].tointeger() > 0 )
  201. {
  202. player.SetWeapon( params[i].tointeger(), 5000 );
  203. weapons = weapons + " " + GetWeaponName( params[i].tointeger() );
  204. }
  205. else MessagePlayer( "[#FF0000]Invalid Weapon Name/ID!", player );
  206. }
  207.  
  208. if( weapons != 0 ) MessagePlayer( "[#00FF00]Received weapons: [#FFFFFF] " + weapons + " ", player );
  209. }
  210. }
  211.  
  212.  
  213. else if ( cmd == "disarm" )
  214. {
  215. PrivMessage( player, "You've been disarmed");
  216. player.Disarm();
  217. }
  218. else if ( cmd == "goto" )
  219. {
  220. if( player.Cash < 0 ) return MessagePlayer( " "+red+" Error: "+yellow+"You don't have enough cash for goto. "+cyan+"Price $100", player );
  221. else if ( !text ) MessagePlayer( " "+red+" Error: "+yellow+" /goto [Player ID/Name]", player );
  222. else
  223. {
  224. local plr = FindPlayer( text );
  225. player.Pos = plr.Pos
  226. MessagePlayer( " "+yellow+" You have been teleported to "+cyan+" "+ plr.Name +" ", player );
  227. }
  228.  
  229. }
  230.  
  231.  
  232. }
  233.  
  234. function onPlayerPM( player, playerTo, message )
  235. {
  236. return 1;
  237. }
  238.  
  239. function onPlayerBeginTyping( player )
  240. {
  241. }
  242.  
  243. function onPlayerEndTyping( player )
  244. {
  245. }
  246.  
  247. /*
  248. function onLoginAttempt( player )
  249. {
  250. return 1;
  251. }
  252. */
  253.  
  254. function onNameChangeable( player )
  255. {
  256. }
  257.  
  258. function onPlayerSpectate( player, target )
  259. {
  260. }
  261.  
  262. function onPlayerCrashDump( player, crash )
  263. {
  264. }
  265.  
  266. function onPlayerMove( player, lastX, lastY, lastZ, newX, newY, newZ )
  267. {
  268. }
  269.  
  270. function onPlayerHealthChange( player, lastHP, newHP )
  271. {
  272. }
  273.  
  274. function onPlayerArmourChange( player, lastArmour, newArmour )
  275. {
  276. }
  277.  
  278. function onPlayerWeaponChange( player, oldWep, newWep )
  279. {
  280. }
  281.  
  282. function onPlayerAwayChange( player, status )
  283. {
  284. }
  285.  
  286. function onPlayerNameChange( player, oldName, newName )
  287. {
  288. }
  289.  
  290. function onPlayerActionChange( player, oldAction, newAction )
  291. {
  292. }
  293.  
  294. function onPlayerStateChange( player, oldState, newState )
  295. {
  296. }
  297.  
  298. function onPlayerOnFireChange( player, IsOnFireNow )
  299. {
  300. }
  301.  
  302. function onPlayerCrouchChange( player, IsCrouchingNow )
  303. {
  304. }
  305.  
  306. function onPlayerGameKeysChange( player, oldKeys, newKeys )
  307. {
  308. }
  309.  
  310. function DeCash( player, Cost )
  311. {
  312. local cash = status[ player.ID ].Cash;
  313. local det = cash - Cost;
  314. status[ player.ID ].Cash = det;
  315. }
  316. function CashIn( player, ammount )
  317. {
  318. local cash = status[ player.ID ].Cash;
  319. local add = cash + Cost;
  320. status[ player.ID ].Cash = add;
  321. player.Cash = add;
  322.  
  323.  
  324. }
  325. // ========================================== V E H I C L E E V E N T S =============================================
  326.  
  327. function onPlayerEnteringVehicle( player, vehicle, door )
  328. {
  329. return 1;
  330. }
  331.  
  332. function onPlayerEnterVehicle( player, vehicle, door )
  333. {
  334. }
  335.  
  336. function onPlayerExitVehicle( player, vehicle )
  337. {
  338. }
  339.  
  340. function onVehicleExplode( vehicle )
  341. {
  342. }
  343.  
  344. function onVehicleRespawn( vehicle )
  345. {
  346. }
  347.  
  348. function onVehicleHealthChange( vehicle, oldHP, newHP )
  349. {
  350. }
  351.  
  352. function onVehicleMove( vehicle, lastX, lastY, lastZ, newX, newY, newZ )
  353. {
  354. }
  355.  
  356. 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+"'");
  357.  
  358. function SendDataToClient( player, integer, string )
  359. {
  360.  
  361. if ( FindPlayer( player ) )
  362. {
  363.  
  364. Stream.StartWrite( );
  365. Stream.WriteInt( integer );
  366. if ( string != null ) Stream.WriteString( string );
  367. Stream.SendStream( FindPlayer( player ) );
  368.  
  369. }
  370. }
  371. function AccInfo( player )
  372. {
  373. local q = QuerySQL( DB, "SELECT * FROM Accounts WHERE Name = '" + escapeSQLString( player.Name ) + "'" );
  374. if( q )
  375. {
  376. status[ player.ID ].Password = GetSQLColumnData( q, 3 );
  377. status[ player.ID ].Level = GetSQLColumnData( q, 4 );
  378. status[ player.ID ].UID = GetSQLColumnData( q, 6 );
  379. status[ player.ID ].IP = GetSQLColumnData( q, 7 );
  380. status[ player.ID ].AutoLogin = GetSQLColumnData( q, 8 );
  381. status[ player.ID ].Kills = GetSQLColumnData( q, 9 );
  382. status[ player.ID ].Deaths = GetSQLColumnData( q, 10 );
  383. status[ player.ID ].Cash = GetSQLColumnData( q, 11 );
  384. status[ player.ID ].Bank = GetSQLColumnData( q, 12 );
  385. status[ player.ID ].Nogoto = GetSQLColumnData( q, 13 );
  386.  
  387. status[ player.ID ].Registered = true;
  388. if( ( player.UID == status[ player.ID ].UID ) || ( player.IP == status[ player.ID ].IP ) )
  389. {
  390. if( status[ player.ID ].AutoLogin == "true" )
  391. {
  392. MessagePlayer( "[#CCFF66]** Welcome back to the server." , player );
  393. MessagePlayer( "[#CCFF66]** You've been auto logged in, to disable this, type /autologin [ Toggles automatically ]" , player );
  394. status[ player.ID ].LoggedIn = true;
  395. }
  396. else
  397. {
  398. MessagePlayer( "[#CCFF66]** Welcome back to the server." , player );
  399. MessagePlayer( "[#CCFF66]** Your nick is registered. Please login in order to access services." , player );
  400. }
  401. }
  402. else
  403. {
  404. MessagePlayer( "[#CCFF66]** Welcome back to the server." , player );
  405. MessagePlayer( "[#CCFF66]** Your nick is registered. Please login in order to access services." , player );
  406. }
  407. }
  408. else
  409. {
  410. MessagePlayer( "[#CCFF66]** Welcome to the server." , player );
  411. MessagePlayer( "[#CCFF66]** Your nick is [#FF0000]not [#CCFF66]registered. Please register in order to access services." , player );
  412. }
  413. FreeSQLQuery( q );
  414. }
  415.  
  416. function onClientScriptData( player )
  417. {
  418. local int = Stream.ReadInt( ),
  419. string = Stream.ReadString ( );
  420. switch( int.tointeger() )
  421. {
  422. case 1: //Register
  423. local q = QuerySQL( DB, "SELECT * FROM Accounts WHERE Name = '" + escapeSQLString( player.Name ) + "'" );
  424. 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' )");
  425. status[ player.ID ].Password = SHA256( string );
  426. status[ player.ID ].Level = 1;
  427. status[ player.ID ].UID = player.UID;
  428. status[ player.ID ].IP = player.IP;
  429. status[ player.ID ].AutoLogin = true;
  430. status[ player.ID ].Kills = 0;
  431. status[ player.ID ].Deaths = 0;
  432. status[ player.ID ].Cash = 0;
  433. status[ player.ID ].Bank = 0;
  434. status[ player.ID ].Nogoto = false;
  435. status[ player.ID ].Registered = true;
  436. status[ player.ID ].LoggedIn = true;
  437. MessagePlayer( "[#CCFF66]** Successfully Registered." , player );
  438. MessagePlayer( "[#CCFF66]** Don't forget your password [#CC6666]"+string , player );
  439.  
  440. break;
  441.  
  442. case 2: //Login
  443.  
  444. if( status[ player.ID ].Password == SHA256( string ) )
  445. {
  446. MessagePlayer( "[#CCFF66]** Successfully Logged in." , player );
  447. status[ player.ID ].LoggedIn = true;
  448. status[ player.ID ].UID = player.UID;
  449. status[ player.ID ].IP = player.IP;
  450. SendDataToClient( player.ID, 3, "" );
  451. }
  452. else SendDataToClient( player.ID, 2, "Wrong Password" );
  453.  
  454. break;
  455. }
  456.  
  457.  
  458.  
  459.  
  460.  
  461. }
  462.  
  463. // =========================================== P I C K U P E V E N T S ==============================================
  464.  
  465. function onPickupClaimPicked( player, pickup )
  466. {
  467. return 1;
  468. }
  469.  
  470. function onPickupPickedUp( player, pickup )
  471. {
  472. }
  473.  
  474. function onPickupRespawn( pickup )
  475. {
  476. }
  477.  
  478. // ========================================== O B J E C T E V E N T S ==============================================
  479.  
  480. function onObjectShot( object, player, weapon )
  481. {
  482. }
  483.  
  484. function onObjectBump( object, player )
  485. {
  486. }
  487.  
  488. // =========================================== B I N D E V E N T S ==============================================
  489.  
  490. function onKeyDown( player, key )
  491. {
  492. }
  493.  
  494. function onKeyUp( player, key )
  495. {
  496. }
  497.  
  498. // ================================== 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