ARSEnic69

Main

Dec 21st, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.10 KB | None | 0 0
  1. class Server{
  2. RegisterFunc = ["StartChallenge"]
  3. }
  4.  
  5. local ChallengeCount = 0;
  6. local ClientSphere = array(128);
  7. local ClientBlip = array(128);
  8. local LastCheckpoint = array(128);
  9. local PlayerChallenge = array(128);
  10. function onScriptLoad(){
  11. print("Hello rod")
  12. foreach(ToRegister in Server.RegisterFunc){
  13. RegisterRemoteFunc(ToRegister);
  14. }
  15. LoadModule("lu_ini")
  16. ChallengeCount = ReadIniInteger("Server/Data.ini", "Data", "Count");;
  17.  
  18. }
  19. function onPlayerJoin(pPlayer){
  20. CallClientFunc(pPlayer, "Main/Client.nut", "SetChallengeCount", ChallengeCount)
  21. Message("ss")
  22. }
  23. function onPlayerCommand(pPlayer, Command, Params){
  24. if(Command == "pos")Message(pPlayer.Pos+"")
  25. }
  26. function onPlayerSpawn(pPlayer, Spawn){
  27. local Runway = Random(1,2)
  28. if(Runway == 1 ) pPlayer.Pos = Vector(-1575, -965, 11)
  29. else if(Runway == 2 ) pPlayer.Pos = Vector(-1575, -980, 11)
  30. local Vehicle = CreateVehicle(119, pPlayer.Pos, 270);
  31. Vehicle.OneTime = true;
  32. pPlayer.Vehicle = Vehicle;
  33. //pPlayer.Frozen = true;
  34. }
  35.  
  36. function onConsoleInput(Command, Parameters){
  37. }
  38. function StartChallenge(pPlayer, Challenge){
  39. SmallMessage(pPlayer, "Loaded challenge " + Challenge, 1000, 1)
  40. PlayerChallenge[pPlayer.ID] = Challenge;
  41. Challenge = Challenge.tostring();
  42. LastCheckpoint[pPlayer.ID] = 1;
  43. local XPos = ReadIniFloat("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "XPos");
  44. local YPos = ReadIniFloat("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "YPos");
  45. local ZPos = ReadIniFloat("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "ZPos");
  46. local Radius = ReadIniFloat("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "Radius");
  47. local RSphereCol = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "RSphereCol");
  48. local GSphereCol = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "GSphereCol");
  49. local BSphereCol = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "BSphereCol");
  50. local BlipCol = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "BlipCol");
  51. local Size = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "Size");
  52. local Description = ReadIniString("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "Description");
  53. ClientSphere[pPlayer.ID] = CreateClientSphere(Vector(XPos, YPos, ZPos), Radius, Colour( RSphereCol, GSphereCol, BSphereCol), pPlayer)
  54. //pPlayer.Pos = ClientSphere[pPlayer.ID].Pos;
  55. ClientBlip[pPlayer.ID] = CreateClientBlip(pPlayer, BLIP_NONE, Vector(XPos, YPos, ZPos))
  56. ClientBlip[pPlayer.ID].Size = Size;
  57. ClientBlip[pPlayer.ID].Colour = BlipCol;
  58. if(Description != "") SmallMessage(pPlayer, Description, 10000, 1)
  59. }
  60. function onPlayerEnterSphere( pPlayer, Sphere ){
  61. if(Sphere.ID == ClientSphere[pPlayer.ID].ID){
  62. LastCheckpoint[pPlayer.ID]++
  63. local Challenge = PlayerChallenge[pPlayer.ID];
  64. local XPos = ReadIniFloat("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "XPos");
  65. local YPos = ReadIniFloat("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "YPos");
  66. local ZPos = ReadIniFloat("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "ZPos");
  67. if((XPos == 0)&&(YPos == 0)&&(ZPos == 0))
  68. {
  69. Message(pPlayer.Name + " has completed challenge " + Challenge + "!")
  70. PlayerChallenge[pPlayer.ID] = 0;
  71. ClientBlip[pPlayer.ID].Remove();
  72. ClientSphere[pPlayer.ID].Remove();
  73. LastCheckpoint[pPlayer.ID] = 0;
  74. CallClientFunc(pPlayer, "Main/Client.nut", "EndChallenge", "-")
  75. }else{
  76. local Radius = ReadIniFloat("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "Radius");
  77. local RSphereCol = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "RSphereCol");
  78. local GSphereCol = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "GSphereCol");
  79. local BSphereCol = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "BSphereCol");
  80. local BlipCol = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "BlipCol");
  81. local Size = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "Size");
  82. local Description = ReadIniString("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "Description");
  83. ClientSphere[pPlayer.ID].Pos = Vector(XPos, YPos, ZPos);
  84. ClientSphere[pPlayer.ID].Radius = Radius;
  85. ClientSphere[pPlayer.ID].Colour = Colour(RSphereCol, GSphereCol, BSphereCol);
  86. ClientBlip[pPlayer.ID].Pos = Vector(XPos, YPos, ZPos);
  87. ClientBlip[pPlayer.ID].Size = Size;
  88. MessagePlayer("You have completed checkpoint " + (LastCheckpoint[pPlayer.ID]-1).tointeger().tostring(), pPlayer)
  89. MessagePlayer("Next checkpoint " + LastCheckpoint[pPlayer.ID] + "is located in " + GetDistrictName(PosX, PosY), pPlayer)
  90. if(Description != "") SmallMessage(pPlayer, Description, 10000, 1)
  91. }
  92. }
  93. }
  94.  
  95. function Random ( Min, Max ) {
  96. //Min and Max Inclusive
  97. return rand ( ) % ( Min - Max - 1 ) + Min;
  98. }
Add Comment
Please, Sign In to add comment