MuhammadZeeshan

bstats and wstats

Dec 2nd, 2016
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.87 KB | None | 0 0
  1. //============================ Wstats And Bstats Fucntions ==============================================//
  2. function SetPlayerBodyPart( player, bodypart, amount )
  3. {
  4. QuerySQL( db, format( "UPDATE Bstats SET %s=%i WHERE Name='" + player.Name + "'", BStats( bodypart ), amount ) );
  5. }
  6.  
  7. function GetPlayerBodyPart( player, bodypart )
  8. {
  9. local BP = GetSQLColumnData( QuerySQL( db, format( "SELECT %s FROM Bstats WHERE Name='" + player.Name + "'", BStats( bodypart ) ) ), 0 );
  10. if ( BP ) return BP;
  11. else return 0;
  12. }
  13.  
  14. function IncPlayerBodyPart( player, bodypart, amount )
  15. {
  16. QuerySQL( db, format( "UPDATE Bstats SET %s=%i WHERE Name='" + player.Name + "'", BStats( bodypart ), ( GetPlayerBodyPart( player, bodypart ) + amount ) ) );
  17. }
  18.  
  19. function DecPlayerBodyPart( player, bodypart, amount )
  20. {
  21. QuerySQL( db, format( "UPDATE Bstats SET %s=%i WHERE Name='" + player.Name + "'", BStats( bodypart ), ( GetPlayerBodyPart( player, bodypart ) - amount ) ) );
  22. }
  23.  
  24. function GetPlayerBStats( player )
  25. {
  26. local bps = null;
  27. for ( local b = 0; b <= 6; b++ )
  28. {
  29. if ( GetPlayerBodyPart( player, b ) > 0 )
  30. {
  31. if ( bps ) bps = bps + " " + BStats( b ) + ": [ " + GetPlayerBodyPart( player, b ) + " ]";
  32. else bps = "" + BStats( b ) + ": [ " + GetPlayerBodyPart( player, b ) + " ]";
  33. }
  34. }
  35. if ( bps ) return bps;
  36. else return "Empty (Need Stats)";
  37. }
  38.  
  39. //====================== Functions Of Wstats =============================//
  40.  
  41. function SetPlayerWep( player, wepid, amount )
  42. {
  43. QuerySQL( db, format( "UPDATE Wstats SET %s=%i WHERE Name='" + player.Name + "'", WStats( wepid ), amount ) );
  44. }
  45.  
  46. function GetPlayerWep( player, wepid )
  47. {
  48. local WP = GetSQLColumnData( QuerySQL( db, format( "SELECT %s FROM Wstats WHERE Name='" + player.Name + "'", WStats( wepid ) ) ), 0 );
  49. if ( WP ) return WP;
  50. else return 0;
  51. }
  52.  
  53. function IncPlayerWep( player, wepid, amount )
  54. {
  55. QuerySQL( db, format( "UPDATE Wstats SET %s=%i WHERE Name='" + player.Name + "'", WStats( wepid ), ( GetPlayerWep( player, wepid ) + amount ) ) );
  56. }
  57.  
  58. function DecPlayerWep( player, wepid, amount )
  59. {
  60. QuerySQL( db, format( "UPDATE Wstats SET %s=%i WHERE Name='" + player.Name + "'", WStats( wepid ), ( GetPlayerWep( player, wepid ) - amount ) ) );
  61. }
  62.  
  63. function GetPlayerWStats( player )
  64. {
  65. local wps = null;
  66. for ( local w = 0; w <= 32; w++ )
  67. {
  68. if ( GetPlayerWep( player, w ) > 0 )
  69. {
  70. if ( wps ) wps = wps + " " + WStats( w ) + ": [ " + GetPlayerWep( player, w ) + " ] ";
  71. else wps = " " + WStats( w ) + ": [ " + GetPlayerWep( player, w ) + " ] ";
  72. }
  73. }
  74. if ( wps ) return wps;
  75. else return "Empty (Need Stats)";
  76. }
  77.  
  78. function BStats( bodypart )
  79. {
  80. local bp = "Not found";
  81. if ( bodypart.tointeger() == 0 ) bp = "Body";
  82. if ( bodypart.tointeger() == 1 ) bp = "Torso";
  83. if ( bodypart.tointeger() == 2 ) bp = "LeftArm";
  84. if ( bodypart.tointeger() == 3 ) bp = "RightArm";
  85. if ( bodypart.tointeger() == 4 ) bp = "LeftLeg";
  86. if ( bodypart.tointeger() == 5 ) bp = "RightLeg";
  87. if ( bodypart.tointeger() == 6 ) bp = "Head";
  88. return bp;
  89. }
  90.  
  91. function WStats( wep )
  92. {
  93. local id = "Not found";
  94. if ( wep.tointeger() == 0 ) id = "Fist";
  95. if ( wep.tointeger() == 1 ) id = "BrassKnuckle";
  96. if ( wep.tointeger() == 2 ) id = "ScrewDriver";
  97. if ( wep.tointeger() == 3 ) id = "GolfClub";
  98. if ( wep.tointeger() == 4 ) id = "NightStick";
  99. if ( wep.tointeger() == 5 ) id = "Knife";
  100. if ( wep.tointeger() == 6 ) id = "BaseballBat";
  101. if ( wep.tointeger() == 7 ) id = "Hammer";
  102. if ( wep.tointeger() == 8 ) id = "Cleaver";
  103. if ( wep.tointeger() == 9 ) id = "Machete";
  104. if ( wep.tointeger() == 10 ) id = "Katana";
  105. if ( wep.tointeger() == 11 ) id = "Chainsaw";
  106. if ( wep.tointeger() == 12 ) id = "Grenade";
  107. if ( wep.tointeger() == 13 ) id = "RemoteGrenade";
  108. if ( wep.tointeger() == 14 ) id = "TearGas";
  109. if ( wep.tointeger() == 15 ) id = "Molotov";
  110. if ( wep.tointeger() == 16 ) id = "Missile";
  111. if ( wep.tointeger() == 17 ) id = "Colt45";
  112. if ( wep.tointeger() == 18 ) id = "Python";
  113. if ( wep.tointeger() == 19 ) id = "Shotgun";
  114. if ( wep.tointeger() == 20 ) id = "Spaz";
  115. if ( wep.tointeger() == 21 ) id = "Stubby";
  116. if ( wep.tointeger() == 22 ) id = "Tec9";
  117. if ( wep.tointeger() == 23 ) id = "Uzi";
  118. if ( wep.tointeger() == 24 ) id = "Ingrams";
  119. if ( wep.tointeger() == 25 ) id = "MP5";
  120. if ( wep.tointeger() == 26 ) id = "M4";
  121. if ( wep.tointeger() == 27 ) id = "Ruger";
  122. if ( wep.tointeger() == 28 ) id = "SniperRifle";
  123. if ( wep.tointeger() == 29 ) id = "LaserScope";
  124. if ( wep.tointeger() == 30 ) id = "RocketLauncher";
  125. if ( wep.tointeger() == 31 ) id = "FlameThrower";
  126. if ( wep.tointeger() == 32 ) id = "M60";
  127. return id;
  128. }
  129. function GetBPName( bodypart )
  130. {
  131. local bpd;
  132. if ( bodypart == 0 ) bpd = "Body";
  133. if ( bodypart == 1 ) bpd = "Torso";
  134. if ( bodypart == 2 ) bpd = "Left Arm";
  135. if ( bodypart == 3 ) bpd = "Right Arm";
  136. if ( bodypart == 4 ) bpd = "Left Leg";
  137. if ( bodypart == 5 ) bpd = "Right Leg";
  138. if ( bodypart == 6 ) bpd = "Head";
  139. return bpd;
  140. }
  141.  
  142. //========================== End of Wstats And Bstats Functions =========================================//
  143.  
  144. // ========================= Wstats and Bstats commands =====================
  145. else if ( cmd == "bstats" )
  146. {
  147. if ( !text ) SendMessage( "Your BodyStats: [ " + GetPlayerBStats( player ) + " ]", player );
  148. else if ( text )
  149. {
  150. local plr = GetPlayer( text );
  151. if ( !plr ) ErrorMessage( "[Error] - Unknown Player..", player );
  152. else SendMessage( plr.Name +"'s Body Stats: [ " + GetPlayerBStats( plr ) + " ]", player );
  153. }
  154. }
  155. else if ( cmd == "wstats" )
  156. {
  157. if ( !text ) SendMessage( "Your Weapon Stats: [ " + GetPlayerWStats( player ) + " ]", player);
  158. else if ( text)
  159. {
  160. local plr = GetPlayer( text );
  161. if ( !plr ) ErrorMessage( "[Error] - Unknown Player..", player );
  162. else SendMessage( plr.Name +"'s Wstats: [ " + GetPlayerWStats( plr ) + " ]", player);
  163. }
  164.  
  165. }
  166.  
  167. // ======================== OnPlayerKill function =======================
  168. if ( bodypart <= 7 ) IncPlayerBodyPart( killer, bodypart, 1 );
  169.  
  170. // ============= Tables ======================
  171. QuerySQL( db, "CREATE TABLE IF NOT EXISTS Bstats ( Name TEXT, User TEXT, Body NUMERIC, Torso NUMERIC, LeftArm NUMERIC, RightArm NUMERIC, LeftLeg NUMERIC, RightLeg NUMERIC, Head NUMERIC )" );
  172. QuerySQL( db, "CREATE TABLE IF NOT EXISTS Wstats ( Name TEXT, User TEXT, Fist NUMERIC, BrassKnuckle NUMERIC, ScrewDriver NUMERIC, GolfClub NUMERIC, NightStick NUMERIC, Knife NUMERIC, BaseballBat NUMERIC, Hammer NUMERIC, Cleaver NUMERIC, Machete NUMERIC, Katana NUMERIC, Chainsaw NUMERIC, Grenade NUMERIC, RemoteGrenade NUMERIC, TearGas NUMERIC, Molotov NUMERIC, Missile NUMERIC, Colt45 NUMERIC, Python NUMERIC, Shotgun NUMERIC, Spaz NUMERIC, Stubby NUMERIC, Tec9 NUMERIC, Uzi NUMERIC, Ingrams NUMERIC, MP5 NUMERIC, M4 NUMERIC, Ruger NUMERIC, SniperRifle NUMERIC, LaserScope NUMERIC, RocketLauncher NUMERIC, FlameThrower NUMERIC, M60 NUMERIC )" );
  173.  
  174. // ================ Player Info functions ===========================
  175. QuerySQL( db, "INSERT INTO Bstats ( Name, User, Body, Torso, LeftArm, RightArm, LeftLeg, RightLeg, Head ) VALUES ( '" + player.Name + "', '" + player.Name + "', 0, 0, 0, 0, 0, 0, 0 )" );
  176. QuerySQL( db, "INSERT INTO Wstats ( Name, User, Fist, BrassKnuckle, ScrewDriver, GolfClub, NightStick, Knife, BaseballBat, Hammer, Cleaver, Machete, Katana, Chainsaw, Grenade, RemoteGrenade, TearGas, Molotov, Missile, Colt45, Python, Shotgun, Spaz , Stubby, Tec9, Uzi, Ingrams, MP5, M4, Ruger, SniperRifle, LaserScope, RocketLauncher, FlameThrower, M60 ) VALUES ( '" + player.Name + "', '" + player.Name + "', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )" );
Add Comment
Please, Sign In to add comment