Which is faster? - 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: Which is faster? (
/showthread.php?tid=594955)
Which is faster? -
xTURBOx - 26.11.2015
is this faster
Код:
if (sscanf(params, "ud",id,amount)) return SendClientMessage(playerid,-1,"msg");
or
Код:
if (sscanf(params, "ud",id,amount))
{
SendClientMessage(playerid,-1,"msg")
return 0;
}
Re: Which is faster? -
HydraHumza - 26.11.2015
both are same for me if I am not wrong. But if they have any difference then it will be 1 to 2 ms.
Re: Which is faster? -
Vince - 26.11.2015
Theoretically they're two different things because the first one returns the value returned by SendClientMessage (which is usually 1) while the other one just returns 0.
For readability reasons, however, I prefer to always put a return statement on a line of its own. I don't even begin to read code that's all crammed together with zero whitespace (= spaces, tab, or newlines).
Re: Which is faster? -
iKarim - 26.11.2015
I prefer using this:
PHP код:
extract params -> new player:id, amount; else return SendClientMessage(playerid, -1, "Lol invalid params you naaaaap");
Anyways, no need to open brackets or shits for a simple thing, just one line is enough.