Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A little logic problem
#1
Hello ItsMods. I've been browsing your forums for quite a while now and I've started doing some basic moding a bit and I've ran into a little problem. I'm pretty sure this problem isn't in my code. I think I'm just having a little wrong approach here.

Anyway, here's my problem:

Currently I'm making a function that freezes every player for 10 seconds. For example, when someone presses ActionSlot1 key (X on keyboard) then everyone gets frozen, timer counts 10 seconds and everyone gets unfrozen.

Now the problem I'm encountering is that when the guy who frozes everyone dies during the timer countdown, the script stops, therefor the timer stops and everyone is frozen forever.

I'm pretty sure this problem is because I'm coding everything inside the onPlayerSpawn() function which has a safety feature at the beginning of it: self endon("death");

I haven't fully figured out how the logic in BO works yet. So how could I prevent this from happening? Should I create a new separate function for frozing people in which I WONT put the self endon("death"); ?

Any help appreciated. Thanks!
Reply

#2
as you said:
just create a custom function WITHOUT self endon("death");
[Image: ctoc.jpg]
Reply

#3
self endon("event") ends the code when the event occurs. So that means that the timer (loop) stops and the code after it is not executed.

Start a new thread but without the endon.
[Image: azuw.jpg]
Reply

#4
Yes but if I create something like this:


PHP Code:
customFunction ()
{
no end OnDeath here...



PHP Code:
onPlayerSpawn() 
{
    
end("onDeath");
    
customFunction();


The custom function will still stop running if I die right?
Reply

#5
(05-10-2012, 15:10)Rocu Wrote: Yes but if I create something like this:


PHP Code:
customFunction ()
{
no end OnDeath here...



PHP Code:
onPlayerSpawn() 
{
    
end("onDeath");
    
customFunction();


The custom function will still stop running if I die right?

That's why you need to create a thread which runs parallel.

PHP Code:
onPlayerSpawn() 
{
    
self endon("death");
    
self thread customFunction();

[Image: azuw.jpg]
Reply

#6
Oooooooohh... Now *that* is what I was looking for (I think). Thank you.
I'm gonna test it later today.
Reply

#7
  • copy default onPlayerSpawn() thread
  • in thread onPlayerConnect() right before declaration of onPlayerSpawn() thread make new line and declare myFunc() thread in same way as onPlayerSpawn() is declared
  • paste default onPlayerSpawn() somewhere in your GSC, change name to myFunc. Delete endon death part. voila. put stuff inside.

sorry if explanation is not the best
[Image: r212360a129ce9b84444093b6cd2699013a1fbn155.png]
Reply

#8
self thread Wink


EDIT: Im too late D:
[Image: ctoc.jpg]
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Help Android problem Yamato 12 8,175 04-25-2014, 04:49
Last Post: ScHmIdTy56789
  Problem with Rain Effects on Maps mitchhacker 5 4,861 10-22-2013, 00:46
Last Post: mitchhacker
  Help Liberation Problem Yamato 27 24,947 07-17-2013, 19:54
Last Post: feature
  [xna 4]Rendering problem narkos 9 5,945 07-03-2013, 19:00
Last Post: Nekochan
  Help Problem God plugin v4.0 4nonymous 1 2,728 06-22-2013, 23:25
Last Post: 8q4s8
  Help Infected Shop Plugin Problem Hallla 2 3,158 05-06-2013, 18:29
Last Post: Hallla
  problem with gsc code CheGuevara 5 5,616 04-20-2013, 15:06
Last Post: Nekochan
  problem to connect to server s.j-rez 0 2,234 04-17-2013, 18:18
Last Post: s.j-rez
  warning problem AndEEDJay 0 2,110 04-08-2013, 09:54
Last Post: AndEEDJay
  Help ADDON,PROBLEM HACK emilioxativa 5 4,829 04-03-2013, 08:16
Last Post: narkos

Forum Jump:


Users browsing this thread:
3 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.