Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Server{
- RegisterFunc = ["StartChallenge"]
- }
- local ChallengeCount = 0;
- local ClientSphere = array(128);
- local ClientBlip = array(128);
- local LastCheckpoint = array(128);
- local PlayerChallenge = array(128);
- function onScriptLoad(){
- print("Hello rod")
- foreach(ToRegister in Server.RegisterFunc){
- RegisterRemoteFunc(ToRegister);
- }
- LoadModule("lu_ini")
- ChallengeCount = ReadIniInteger("Server/Data.ini", "Data", "Count");;
- }
- function onPlayerJoin(pPlayer){
- CallClientFunc(pPlayer, "Main/Client.nut", "SetChallengeCount", ChallengeCount)
- Message("ss")
- }
- function onPlayerCommand(pPlayer, Command, Params){
- if(Command == "pos")Message(pPlayer.Pos+"")
- }
- function onPlayerSpawn(pPlayer, Spawn){
- local Runway = Random(1,2)
- if(Runway == 1 ) pPlayer.Pos = Vector(-1575, -965, 11)
- else if(Runway == 2 ) pPlayer.Pos = Vector(-1575, -980, 11)
- local Vehicle = CreateVehicle(119, pPlayer.Pos, 270);
- Vehicle.OneTime = true;
- pPlayer.Vehicle = Vehicle;
- //pPlayer.Frozen = true;
- }
- function onConsoleInput(Command, Parameters){
- }
- function StartChallenge(pPlayer, Challenge){
- SmallMessage(pPlayer, "Loaded challenge " + Challenge, 1000, 1)
- PlayerChallenge[pPlayer.ID] = Challenge;
- Challenge = Challenge.tostring();
- LastCheckpoint[pPlayer.ID] = 1;
- local XPos = ReadIniFloat("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "XPos");
- local YPos = ReadIniFloat("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "YPos");
- local ZPos = ReadIniFloat("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "ZPos");
- local Radius = ReadIniFloat("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "Radius");
- local RSphereCol = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "RSphereCol");
- local GSphereCol = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "GSphereCol");
- local BSphereCol = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "BSphereCol");
- local BlipCol = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "BlipCol");
- local Size = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "Size");
- local Description = ReadIniString("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "Description");
- ClientSphere[pPlayer.ID] = CreateClientSphere(Vector(XPos, YPos, ZPos), Radius, Colour( RSphereCol, GSphereCol, BSphereCol), pPlayer)
- //pPlayer.Pos = ClientSphere[pPlayer.ID].Pos;
- ClientBlip[pPlayer.ID] = CreateClientBlip(pPlayer, BLIP_NONE, Vector(XPos, YPos, ZPos))
- ClientBlip[pPlayer.ID].Size = Size;
- ClientBlip[pPlayer.ID].Colour = BlipCol;
- if(Description != "") SmallMessage(pPlayer, Description, 10000, 1)
- }
- function onPlayerEnterSphere( pPlayer, Sphere ){
- if(Sphere.ID == ClientSphere[pPlayer.ID].ID){
- LastCheckpoint[pPlayer.ID]++
- local Challenge = PlayerChallenge[pPlayer.ID];
- local XPos = ReadIniFloat("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "XPos");
- local YPos = ReadIniFloat("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "YPos");
- local ZPos = ReadIniFloat("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "ZPos");
- if((XPos == 0)&&(YPos == 0)&&(ZPos == 0))
- {
- Message(pPlayer.Name + " has completed challenge " + Challenge + "!")
- PlayerChallenge[pPlayer.ID] = 0;
- ClientBlip[pPlayer.ID].Remove();
- ClientSphere[pPlayer.ID].Remove();
- LastCheckpoint[pPlayer.ID] = 0;
- CallClientFunc(pPlayer, "Main/Client.nut", "EndChallenge", "-")
- }else{
- local Radius = ReadIniFloat("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "Radius");
- local RSphereCol = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "RSphereCol");
- local GSphereCol = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "GSphereCol");
- local BSphereCol = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "BSphereCol");
- local BlipCol = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "BlipCol");
- local Size = ReadIniInteger("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "Size");
- local Description = ReadIniString("Server/Pos/" + Challenge + ".ini", LastCheckpoint[pPlayer.ID]+"", "Description");
- ClientSphere[pPlayer.ID].Pos = Vector(XPos, YPos, ZPos);
- ClientSphere[pPlayer.ID].Radius = Radius;
- ClientSphere[pPlayer.ID].Colour = Colour(RSphereCol, GSphereCol, BSphereCol);
- ClientBlip[pPlayer.ID].Pos = Vector(XPos, YPos, ZPos);
- ClientBlip[pPlayer.ID].Size = Size;
- MessagePlayer("You have completed checkpoint " + (LastCheckpoint[pPlayer.ID]-1).tointeger().tostring(), pPlayer)
- MessagePlayer("Next checkpoint " + LastCheckpoint[pPlayer.ID] + "is located in " + GetDistrictName(PosX, PosY), pPlayer)
- if(Description != "") SmallMessage(pPlayer, Description, 10000, 1)
- }
- }
- }
- function Random ( Min, Max ) {
- //Min and Max Inclusive
- return rand ( ) % ( Min - Max - 1 ) + Min;
- }
Add Comment
Please, Sign In to add comment