[OT]@danielkza: So if the 2 bits are different, the result will be the bit that is less close to 000?
i.e:
010 XOR 011 = 011? // 011 > 010? Or it doesn't work like that with bits?
100 XOR 011 = 100? // 100 > 011?[/OT]
@AoD90:
Try this:
PHP Code:
// lenz = number of characters to swap.
stock swap_words( wordA[], wordB[], lenz )
{
new temp[ 250 ]; // 250 will be the maximum number of character the wordA can contain. Edit this to your liking.
// You must make sure that lenz is NOT bigger than temp's size.
format( temp, lenz - 1, "%s", wordA );
format( wordA, lenz - 1, "%s", wordB );
format( wordB, lenz - 1, "%s", temp );
return 1;
}
Example of usage:
PHP Code:
#include <amxmodx>
// lenz = number of characters to swap.
stock swap_words( wordA[], wordB[], lenz )
{
new temp[ 250 ]; // 250 will be the maximum number of character the wordA can contain. Edit this to your liking.
// You must make sure that lenz is NOT bigger than temp's size.
format( temp, lenz - 1, "%s", wordA );
format( wordA, lenz - 1, "%s", wordB );
format( wordB, lenz - 1, "%s", temp );
return 1;
}
public plugin_init()
{
register_clcmd( "say /swap", "myFunction" );
}
public myFunction( id )
{
new HelloWorld[] = "HelloWorld!";
new WorldHello[] = "WorldHello!";
swap_words( HelloWorld, WorldHello, 11 );
client_print( id, print_chat, "HelloWorld: %s WorldHello: %s", HelloWorld, WorldHello );
}
__________________