Jump to content

[Race] Start script after counting down 3.2.1.GO


code123

Recommended Posts

Hi

 

I have a code and it works from (Object Movement Generator) - server side

 

function omg_movement()
  omg5036 = createObject(8838, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 90)
  omgMoveomg5036(1)
  omg9139 = createObject(8838, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 0)
  omgMoveomg9139(1)
end

function omgMoveomg5036(point)
    moveObject(omg5036, 5000, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 100)
    setTimer(moveObject, 5000, 0, omg5036, 5000, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 100)
end

function omgMoveomg9139(point)
    moveObject(omg9139, 5000, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 100)
    setTimer(moveObject, 5000, 0, omg9139, 5000, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 100)
end

 But I need to start it after counting down on the server. (after map loading)

 

function omg_movement()
  omg5036 = createObject(8838, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 90)
  omgMoveomg5036(1)
  omg9139 = createObject(8838, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 0)
  omgMoveomg9139(1)
end

function omgMoveomg5036(point)
    moveObject(omg5036, 5000, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 100)
    setTimer(moveObject, 5000, 0, omg5036, 5000, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 100)
end

function omgMoveomg9139(point)
    moveObject(omg9139, 5000, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 100)
    setTimer(moveObject, 5000, 0, omg9139, 5000, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 100)
end
  
addEvent("onRaceStateChanging",true) 
addEventHandler("onRaceStateChanging",root, 
function (new) 
if (new == "Running") then 
    startomg_movement() 
    
end 
end) 

I've added some lines but it's still doesn't works. I'm newbie in scripting. Could you help guys ?

Link to comment
addEvent("onRaceStateChanging",true) 
addEventHandler("onRaceStateChanging",root, 
  function (new) 
    if (new == "Running") then 
      startomg_movement() 
    end 
  end)

This is my best guess on how to do that, and you already have that in your code. The state "GridCountdown" is apparently the countdown state. The very next state is "Running". Thus, state change from "GridCountdown", or any state tbh, to "Running" should only occur once the countdown is finished. Hence, onRaceStateChanging with new state being "Running" should be triggered just after the countdown ends.

Are you sure the code you tested was the one you posted? Perhaps it didn't save and you kept testing some old code?

Edited by MrTasty
Link to comment

I'm sure I saved it and etc.   BTW The original code looks like that before I did changes

 

 

function omg_movement()
  omg5036 = createObject(8838, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 90)
  omgMoveomg5036(1)
  omg9139 = createObject(8838, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 0)
  omgMoveomg9139(1)
end

function omgMoveomg5036(point)
    moveObject(omg5036, 5000, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 100)
    setTimer(moveObject, 5000, 0, omg5036, 5000, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 100)
end

function omgMoveomg9139(point)
    moveObject(omg9139, 5000, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 100)
    setTimer(moveObject, 5000, 0, omg9139, 5000, 2198.2998046875, 1214.2998046875, 13.5, 0, 0, 100)
end

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), omg_movement)

 

And I tried modify it with that:

 

addEvent("onRaceStateChanging",true) 
addEventHandler("onRaceStateChanging",root, 
  function (new) 
    if (new == "Running") then 
      startomg_movement() 
    end 
  end)

By removed that:

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), omg_movement)

I don't know how to solve that.

Should I use addEventHandler ?

 

Link to comment

@code123 maybe a dumb question, but remembering myself years and years before.. well, do you even have a function called "startomg_movement() " ? :D

Also you can use for example outputChatBox to debug it and see where it fails, also check /debugscript

We don't see your full code so it's hard to help. (I don't see).

I have a feeling like instead of "startomg_movement()" there should be "omg_movement()"

Oh, if its full code then ye, its obviously ur mistake

Edited by AleksCore
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...