ItsMods
A little logic problem - Printable Version

+- ItsMods (https://www.itsmods.com)
+-- Forum: Archive (https://www.itsmods.com/Forum-Archive.html)
+--- Forum: Archive (https://www.itsmods.com/Forum-Archive--64.html)
+--- Thread: A little logic problem (/Thread-A-little-logic-problem.html)



A little logic problem - Rocu - 05-10-2012

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!


RE: A little logic problem - Tomsen1410 - 05-10-2012

as you said:
just create a custom function WITHOUT self endon("death");


RE: A little logic problem - zxz0O0 - 05-10-2012

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.


RE: A little logic problem - Rocu - 05-10-2012

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?


RE: A little logic problem - zxz0O0 - 05-10-2012

(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(); }



RE: A little logic problem - Rocu - 05-10-2012

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


RE: A little logic problem - Arteq - 05-10-2012

  • 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


RE: A little logic problem - Tomsen1410 - 05-10-2012

self thread Wink


EDIT: Im too late D: