encode_tires
#1

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?
Reply
#2

Код:
stock encode_tires(tires1, tires2, tires3, tires4) {
	return tires1 | (tires2 << 1) | (tires3 << 2) | (tires4 << 3);
}


encode_tires(1,0,0,1);
1001
Reply
#3

I don't understand what you want to say it's corrent my way or no?
Reply
#4

You're simply performing the shifting in reverse order. First parameter should be shifted by 3, next by 2 and so on.
Reply
#5

Код:
stock encode_tires(tires1, tires2, tires3, tires4) {

	return (tires4 << 3) | (tires3 << 2) | (tires2 << 1) | tires1;
}
?

But i get still same
Reply
#6

Wrong post, thought too fast.
Reply
#7

I think I clearly said "first parameter". The first parameter is tires1, not tires4.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)