Raised This Month: $ Target: $400
 0% 

[HELP] Switching two variables


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 12-28-2008 , 07:29   Re: [HELP] Switching two variables
Reply With Quote #11

[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_wordswordA[], wordB[], lenz )
{
    new 
temp250 ]; // 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.
    
    
formattemplenz 1"%s"wordA );
    
formatwordAlenz 1"%s"wordB );
    
formatwordBlenz 1"%s"temp );
    
    return 
1;

Example of usage:
PHP Code:
#include <amxmodx>

// lenz = number of characters to swap.
stock swap_wordswordA[], wordB[], lenz )
{
    new 
temp250 ]; // 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.
    
    
formattemplenz 1"%s"wordA );
    
formatwordAlenz 1"%s"wordB );
    
formatwordBlenz 1"%s"temp );
    
    return 
1;
}

public 
plugin_init()
{
    
register_clcmd"say /swap""myFunction" );
}

public 
myFunctionid )
{
    new 
HelloWorld[] = "HelloWorld!";
    new 
WorldHello[] = "WorldHello!";
    
    
swap_wordsHelloWorldWorldHello11 );
    
client_printidprint_chat"HelloWorld: %s    WorldHello:    %s"HelloWorldWorldHello );

__________________
O o
/¯________________________
| IMMA FIRIN' MAH LAZOR!!!
\_¯¯¯

Last edited by Dores; 12-28-2008 at 08:05.
Dores is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:12.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode