Am I doing something wrong if I do this with my vars? - 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)
+--- Thread: Am I doing something wrong if I do this with my vars? (
/showthread.php?tid=655256)
Is it wrong to use one Var for multiple similar tasks -
rt-2 - 17.06.2018
Hi all,
I'm not sure if I'm being smart here or if I'm doing a mistake, so i thought I'd ask you guys.
I tried simplifying some variables like so:
Before:
Код:
UsefullFunction()
{
new sqlquery[512];
format(sqlquery, sizeof(sqlquery), "SELECT ETC");
//code that uses 'sqlquery' var.
}
UsefullFunction2etc()
{
new sqlquery[512];
format(sqlquery, sizeof(sqlquery), "SELECT AND ALL");
//code that uses 'sqlquery' var.
}
After:
Код:
new sqlquery[512];
UsefullFunction()
{
format(sqlquery, sizeof(sqlquery), "SELECT ETC");
//code that uses 'sqlquery' var.
}
UsefullFunction2etc()
{
format(sqlquery, sizeof(sqlquery), "SELECT AND ALL");
//code that uses 'sqlquery' var.
}
I figured that since the CPU can only execute one thing at a time, it can only be executing one function at a time.
Therefore if I always use this variable to immediately format and use it at the same 'time' then it's a good solution?
I don't see any problems at this time and I think multi-threading is not a possibility for SAMP Servers.
Thank you in advance for your opinions.
rt-2