What happends if... - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: What happends if... (
/showthread.php?tid=178374)
What happends if... -
The_Moddler - 21.09.2010
What happends if I use a global variable, and then I use that variable in two commands, and two players tipe a command at the same time, the variable would be bugged?
Re: What happends if... -
Mauzen - 21.09.2010
It is very very (very) unlikely that they type it at exactly the same time, there will always be at least 10ms difference.
Even if they should get it done, pawn is only single-threaded, meaning, the two command requests will be processed one after the other, so the variable will get the value of the last processed request.
So no fear, there will be no problems
Re: What happends if... -
The_Moddler - 21.09.2010
Quote:
Originally Posted by Mauzen
It is very very (very) unlikely that they type it at exactly the same time, there will always be at least 10ms difference.
Even if they should get it done, pawn is only single-threaded, meaning, the two command requests will be processed one after the other, so the variable will get the value of the last processed request.
So no fear, there will be no problems 
|
Thanks!
Re: What happends if... -
Kyeno - 21.09.2010
The situation you mentioned is generally called a "race condition". You can read more about it at
http://en.wikipedia.org/wiki/Race_condition
Usually OOP solves some of the problems, as each objects can have their own state controllers without the need of using globals, but that's just a theory not usable in Pawn. I'd suggest you digging deeper on the article i pasted.