encode_tires - 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: encode_tires (
/showthread.php?tid=605363)
encode_tires -
ScIrUsna - 18.04.2016
Hi,
Код:
new restreturn = encode_tires( 0, 1, 1,1 );
printf("%d", restreturn);
Код:
stock encode_tires(tires1, tires2, tires3, tires4) {
return tires1 | (tires2 << 1) | (tires3 << 2) | (tires4 << 3);
}
https://sampwiki.blast.hk/wiki/TireStates
as 0111 should return 7 but return 14
Код:
new restreturn = encode_tires( 1,1,1,0 );
printf("%d", restreturn);
as 1110 should return 14 but return 7
It's a bug and how to fix it?
Re: encode_tires -
AbyssMorgan - 18.04.2016
Код:
stock encode_tires(tires1, tires2, tires3, tires4) {
return tires1 | (tires2 << 1) | (tires3 << 2) | (tires4 << 3);
}
encode_tires(1,0,0,1);
1001
Re: encode_tires -
ScIrUsna - 18.04.2016
I don't understand what you want to say it's corrent my way or no?
Re: encode_tires -
Vince - 18.04.2016
You're simply performing the shifting in reverse order. First parameter should be shifted by 3, next by 2 and so on.
Re: encode_tires -
ScIrUsna - 18.04.2016
Код:
stock encode_tires(tires1, tires2, tires3, tires4) {
return (tires4 << 3) | (tires3 << 2) | (tires2 << 1) | tires1;
}
?
But i get still same
Re: encode_tires -
introzen - 18.04.2016
Wrong post, thought too fast.
Re: encode_tires -
Vince - 18.04.2016
I think I clearly said "first parameter". The first parameter is tires1, not tires4.