Jump to content

Need some help with script


tinnetju

Recommended Posts

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

Try this:
setTimer ( explosions1, 3000, 3 ) -- you can set the time how much you want (1000-1sec))

Well

Its correct

and

Ok! Ok! I get it! But do ya know whats wrong with my script

Delete the:

end

It's the last 1

why should he delete that line?

thats the end of the script

when if im not wrong the script must look same this:

function recourse_says_hai ()
explosions1 ()
end
addEventHandler ( "onClientResourceStart", getRootElement(), recourse_says_hai )
function explosions1 ()
createExplosion ( -2094.9040527344, 1419.5814208984, 15.529975891113, 12, false )
createExplosion ( -2061.7202148438, 1419.6507568359, 15.529975891113, 11, false )
createExplosion ( -2061.6442871094, 1437.0441894531, 15.529975891113, 0, false )
createExplosion ( -2094.9599609375, 1437.4919433594, 15.529975891113, 2, false )
setTimer ( explosions1, 3000, 3 ) -- you can set the time how much you want (1000-1sec))
end
 
createBlip ( -2078.2707519531, 1427.4582519531, 8.5, 48 )
 
end

As i said 1000 - is a second so it must be 3000 not 3

Understand

try my code and youre sure it didnt gives any bugs?

Link to comment
function recourse_says_hai ()
explosions1 ()
end
addEventHandler ( "onClientResourceStart", getRootElement(), recourse_says_hai )
 
function explosions1 ()
createExplosion ( -2094.9040527344, 1419.5814208984, 15.529975891113, 12, false )
createExplosion ( -2061.7202148438, 1419.6507568359, 15.529975891113, 11, false )
createExplosion ( -2061.6442871094, 1437.0441894531, 15.529975891113, 0, false )
createExplosion ( -2094.9599609375, 1437.4919433594, 15.529975891113, 2, false )
setTimer ( explosions1, 3000, 3 ) 
createBlip ( -2078.2707519531, 1427.4582519531, 8.5, 48 )
end

Link to comment

Isnt there anything wrong if this?

function recourse_says_hai ()
explosions1 ()
end
addEventHandler ( "onClientResourceStart", getRootElement(), recourse_says_hai )
function explosions1 ()

Like explosions1 or resource_says_hi ?

And why doesnt 50p or little toady answers my question? xD

Link to comment
...

And why doesnt 50p or little toady answers my question? xD

1. I have been away for a few days and I have NO IDEA what this subject is about (especially when the topic name doesn't tell me anything)

2. I don't know what your problem is and I can't be bothered to read the whole topic to find out what you've gone through...

3. I can see people are trying to help and I let them do it. I don't like to jump in front of someone who is trying to help and fix the problem with 1 or 2 posts and get all the credits. That may get him annoyed because he's been trying to help you for days whereas me just a few posts.

Link to comment
Lol, hi 50P xD

And, ye they are helping me, but the script still doesn't work... And i really want it to let it work... So can you be one of the people that are helping me?

If you explained what the problem is... I can't be bothered to read the whole topic to find out and show your latest code.

Link to comment

Ok 50P, i wanted to make a stage with fireworks and stuff, a little that looks like

this.

And this is the code:

function recourse_says_hai ()
explosions1 ()
end
addEventHandler ( "onClientResourceStart", getRootElement(), recourse_says_hai )
function explosions1 ()
setTimer ( explosions1, 3000, 3 )
createExplosion ( -2094.9040527344, 1419.5814208984, 15.529975891113, 12, false )
createExplosion ( -2061.7202148438, 1419.6507568359, 15.529975891113, 11, false )
createExplosion ( -2061.6442871094, 1437.0441894531, 15.529975891113, 0, false )
createExplosion ( -2094.9599609375, 1437.4919433594, 15.529975891113, 2, false )
end
 
addEventHandler ( "onResourceStart", getRootElement(), pedLoad )
function pedLoad ( createPed )
createPed ( 164, -2093.9348144531, 1416.8395996094, 7.1006660461426, 180 )
end

But when i run the script, he doesn't give any problems. And the debugscript only says that line 13 is wrong, the addEvendHandler... But how could that possibly be wrong when i got it from the wiki?

Can you please help me?

Link to comment
I just wanna test the explosions, but is the code right or not?

No.

setTimer ( explosions1, 3, 3 )

That's wrong.. Like the wiki says: "The minimum accepted interval is 50ms."

Working version:

setTimer ( explosions1, 50, 3 )

Link to comment

Well, have a read about code execution order https://forum.multitheftauto.com/viewtop ... 00#p289183

Basically, pedLoad does NOT exist above line 13.

Line 6, if you want a function to call itself with a timer, you have to put 1 for timesToExecute parameter otherwise this function will be called more and more times than you'd want. This is why:

explosion1 - called 1st time
1st timer is created
 
3seconds later:
explosion1 - called 2nd time (because timer called it, but the same timer needs to call the function 2 more times)
new timer is created (2 timers)
 
3seconds later:
explosion1 - called 3rd time (the first timer needs 1 more call, new timer calls this function 1st time, so 2 timers called the same function at the same time)
another timer is created - 1st timer called this function (3 timers)
and another one - 2nd timer called this function (4 timers)
 
3seconds later:
explosion1 - called 4th time (first timer is now dead, 2nd timer needs 2 more calls, 3rd and 4th timers 3 more calls)
new timer is created - 2nd timer called this function (4 timers because 1 died)
another timer is created - 3rd timer called this func (5 timers)
and another one - 4th timer called this func (6 timers)

I don't know if you understand what I just tried to explain but it's important not to overload your server/client with hundreds of timers and cause lag.

If you want a function to be executed specific amount of times do something like this:

function a( count )
if ( count ~= 0 ) then
setTimer( a, 3000, 1, count - 1 );
end
end
 
a( 5 ); -- this will pass 5 to function a

Function will check if 5 is not 0 and if it's true, a timer will call the function again with decreased count number: 4. Then again, count passed to function a will be checked, ( if 4 is not 0 ) then a new timer will call function a but again, with decreased count number: 3. It will keep doing it until count will be 0.

Link to comment
I just wanna test the explosions, but is the code right or not?

No.

setTimer ( explosions1, 3, 3 )

That's wrong.. Like the wiki says: "The minimum accepted interval is 50ms."

Working version:

setTimer ( explosions1, 50, 3 )

And still it doesnt work... Why does this stupid script don't work?!

Link to comment
And still it doesnt work... Why does this stupid script don't work?!

Because you missed my post? What doesn't work? You said:

...

But when i run the script, he doesn't give any problems. And the debugscript only says that line 13 is wrong, the addEvendHandler... But how could that possibly be wrong when i got it from the wiki?

Can you please help me?

Did you mean there is no problem with the script?

Link to comment
And still it doesnt work... Why does this stupid script don't work?!

Because you missed my post? What doesn't work? You said:

...

But when i run the script, he doesn't give any problems. And the debugscript only says that line 13 is wrong, the addEvendHandler... But how could that possibly be wrong when i got it from the wiki?

Can you please help me?

Did you mean there is no problem with the script?

oowh nonono i was replying sebas' post, and then the same time you posted your post. I gonna check your post right now,

Link to comment
Well, have a read about code execution order https://forum.multitheftauto.com/viewtop ... 00#p289183

Basically, pedLoad does NOT exist above line 13.

Line 6, if you want a function to call itself with a timer, you have to put 1 for timesToExecute parameter otherwise this function will be called more and more times than you'd want. This is why:

explosion1 - called 1st time
1st timer is created
 
3seconds later:
explosion1 - called 2nd time (because timer called it, but the same timer needs to call the function 2 more times)
new timer is created (2 timers)
 
3seconds later:
explosion1 - called 3rd time (the first timer needs 1 more call, new timer calls this function 1st time, so 2 timers called the same function at the same time)
another timer is created - 1st timer called this function (3 timers)
and another one - 2nd timer called this function (4 timers)
 
3seconds later:
explosion1 - called 4th time (first timer is now dead, 2nd timer needs 2 more calls, 3rd and 4th timers 3 more calls)
new timer is created - 2nd timer called this function (4 timers because 1 died)
another timer is created - 3rd timer called this func (5 timers)
and another one - 4th timer called this func (6 timers)

I don't know if you understand what I just tried to explain but it's important not to overload your server/client with hundreds of timers and cause lag.

If you want a function to be executed specific amount of times do something like this:

function a( count )
if ( count ~= 0 ) then
setTimer( a, 3000, 1, count - 1 );
end
end
 
a( 5 ); -- this will pass 5 to function a

Function will check if 5 is not 0 and if it's true, a timer will call the function again with decreased count number: 4. Then again, count passed to function a will be checked, ( if 4 is not 0 ) then a new timer will call function a but again, with decreased count number: 3. It will keep doing it until count will be 0.

Im affraid, i dont understand... I don't get it...

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...