21.07.2009, 00:28
I can't seem to get this to work correctly,
[code=pawn]#include <a_samp>
stock Something
perator--(Something
per)
return Something
_
per - 1);
stock Something
perator++(Something
per)
return Something
_
per + 1);
public OnFilterScriptInit()
{
new Something:a = Something:5, Something:b = Something:5;
a++;
b--;
printf("a = %i, b = %i", _:a, _:b);
return 1;
}[/code]
gives
but if I just have the decrement operator and not the increment operator it gives the expected value. Am I doing something wrong or is this a compiler problem?
[code=pawn]#include <a_samp>
stock Something
perator--(Something
per)return Something
_
per - 1);stock Something
perator++(Something
per)return Something
_
per + 1);public OnFilterScriptInit()
{
new Something:a = Something:5, Something:b = Something:5;
a++;
b--;
printf("a = %i, b = %i", _:a, _:b);
return 1;
}[/code]
gives
Quote:
|
a = 6, b = 6 |


. The only reason floats work at all is because the operators are overloaded to use functions instead of the default operators. You can make your own type with your own operators which is what I'm trying to do but it doesn't seem to work properly.