Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if speedcartVars == nil or speedcartVars == false then
- speedcartVars = true
- raceStarted = false
- lastSpawnUsed = 0
- lastWinner = nil
- end
- function constantCheck()
- cancel(constantSch)
- numGoodOnes = 0
- theGoodOne = nil
- numClients = getNumClients()
- for i = 0,numClients-1,1 do
- client = getClientIdx(i)
- player = client:getPlayer()
- if player ~= nil then
- x,y,z = player:getPosition()
- if y > 15 then
- theGoodOne = client
- numGoodOnes = numGoodOnes + 1
- else
- playSound("Death",x,y,z,false)
- client:setPlayer(nil)
- player:remove()
- client:setCameraPosition(x,y,z)
- client:bottomPrint("You uh drowned I guess.",7000)
- end
- end
- end
- if numGoodOnes == 0 then
- bottomPrintAll("Everyone died!",2000)
- schedule(2100,"endRace")
- elseif numGoodOnes == 1 then
- lastWinner = theGoodOne
- winRace()
- else
- constantSch = schedule(1000,"constantCheck")
- end
- end
- function preStartRace()
- numBricks = getNumNamedBricks("stopLight")
- for i = 0,numBricks-1,1 do
- brick = getNamedBrickIdx("stopLight",i)
- if brick ~= nil then
- brick:setColor(1,1,0,1)
- end
- end
- playSound("NoteFs5")
- schedule(1000,"preStartRaceA")
- schedule(2000,"startRace")
- end
- function preStartRaceA()
- playSound("NoteFs5")
- end
- function startRace()
- numBricks = getNumNamedBricks("stopLight")
- for i = 0,numBricks-1,1 do
- brick = getNamedBrickIdx("stopLight",i)
- if brick ~= nil then
- brick:setColor(0,1,0,1)
- end
- end
- playSound("NoteA6")
- numClients = getNumClients()
- for i = 0,numClients-1,1 do
- getClientIdx(i):clearBricks()
- end
- numBricks = getNumNamedBricks("garageDoor")
- for i = 0,numBricks-1,1 do
- brick = getNamedBrickIdx("garageDoor",i)
- if brick ~= nil then
- r,g,b,a = brick:getColor()
- brick:setColor(r,g,b,0)
- brick:setColliding(false)
- end
- end
- bottomPrintAll("The race has started! 5 minutes remaining!",7000)
- endRaceSchedule = schedule(300000,"raceTimeout")
- constantSch = schedule(1000,"constantCheck")
- raceStarted = true
- end
- function raceTimeout()
- bottomPrintAll("The time limit is up!",7000)
- endRace()
- end
- function spawnPlayerSpeedcart(client,x,y,z,cancelled)
- numSpawns = getNumNamedBricks("spawn")
- x = 1000 + math.random(-5,5)
- y = 70
- z = 150 + math.random(-5,5)
- if numSpawns > 0 then
- x,y,z = getNamedBrickIdx("spawn",lastSpawnUsed):getPosition()
- y = y + 2
- lastSpawnUsed = lastSpawnUsed + 1
- if lastSpawnUsed >= numSpawns then
- lastSpawnUsed = 0
- end
- end
- if raceStarted == true then
- cancelled = true
- client:setCameraPosition(1000,70,150)
- client:bottomPrint("You will spawn after the race!",15000)
- end
- if cancelled == false then
- playSound("Spawn",x,y,z,false)
- end
- return client,x,y,z,cancelled
- end
- registerEventListener("spawnPlayer","spawnPlayerSpeedcart")
- function winRace()
- bottomPrintAll(lastWinner:getName() .. " has won the race!",7000)
- playSound("Win")
- numClients = getNumClients()
- for i = 0,numClients-1,1 do
- if lastWinner:getPlayer() == nil then
- getClientIdx(i):setCameraPosition(-450,80,1200)
- else
- getClientIdx(i):bindCamera(lastWinner:getPlayer())
- end
- end
- schedule(7000,"endRace")
- end
- function endRace()
- clearAllCars()
- cancel(endRaceSchedule)
- cancel(constantSch)
- raceStarted = false
- numBricks = getNumNamedBricks("stopLight")
- for i = 0,numBricks-1,1 do
- brick = getNamedBrickIdx("stopLight",i)
- if brick ~= nil then
- brick:setColor(1,0,0,1)
- end
- end
- numBricks = getNumNamedBricks("garageDoor")
- for i = 0,numBricks-1,1 do
- brick = getNamedBrickIdx("garageDoor",i)
- if brick ~= nil then
- r,g,b,a = brick:getColor()
- brick:setColor(r,g,b,0.95) -- Keep a bit below 1 otherwise transparency can be messed up later
- brick:setColliding(true)
- end
- end
- numClients = getNumClients()
- for i = 0,numClients-1,1 do
- getClientIdx(i):spawnPlayer(1000+math.random(-5,5),70,150+math.random(-5,5))
- end
- end
- function clientLeaveSpeedcart(client)
- client:clearBricks()
- end
- registerEventListener("clientLeave","clientLeaveSpeedcart")
- function clickBrick(client,brick,x,y,z)
- if brick:getName() == "goob" then
- player = client:getPlayer()
- if player ~= nil then
- x,y,z = player:getPosition()
- playSound("FastImpact",x,y,z,false)
- client:bottomPrint("Bwoamp",2000);
- end
- end
- if raceStarted == true then
- if brick:getName() == "winner" then
- lastWinner = client
- winRace()
- end
- end
- end
- registerEventListener("clientClickBrick","clickBrick")
- function plantBrick(client,brick)
- if raceStarted == true then
- client:bottomPrint("You can not build during the race!",7000)
- brick:remove()
- end
- end
- registerEventListener("clientPlantBrick","plantBrick")
- function loadCarSpeedcart(client,car,loadCarAsCar)
- if raceStarted == true then
- client:bottomPrint("You can not load cars during the race!",7000)
- return true
- else
- if client:getNumVehicles() > 1 then
- client:bottomPrint("You can't have over 2 cars at a time!",7000)
- return true
- end
- end
- return false
- end
- registerEventListener("clientTryLoadCar","loadCarSpeedcart")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement