Raised This Month: $ Target: $400
 0% 

Array Operations


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
S34Qu4K3
Veteran Member
Join Date: Jan 2010
Location: Galicia
Old 10-09-2010 , 12:09   Array Operations
Reply With Quote #1

Hi I have this

PHP Code:
new Password[4]
new 
szArg[192]

//.........


public RegisterPassword(id)
{
    
client_cmd(id"messagemode Register_Pwd")
    
    
client_print(idprint_center"Write Password  Numbers")
    
set_hudmessage(255000.00.000.14.00.010.01, -1)
    
ShowSyncHudMsg(idg_MsgSync"^n^n^n  Write Password  Numbers")
    
    return 
PLUGIN_CONTINUE;
}

public 
Pwd_register(id)
{
    
read_argsszArg191 )
    
remove_quotesszArg )
    
trim szArg )
    
    if( !
isdigit(szArg[0]) )
    {
        
RegisterPassword(id)
        return 
PLUGIN_HANDLED;
    }
        
    
copyPassword[id], charsmaxPassword[] ), szArg )
    
    
client_printidprint_chat"Tu password es: %s"Password[id] )
    
CheckValidPassword(id)
    return 
PLUGIN_CONTINUE;
    
}  
public 
CheckValidPassword(id)
{
    
client_print(idprint_chat"[DEBUG]public CheckValidPassword")
    if((
Password[0]*Password[3])-(Password[1]*Password[2]) == 1)
    {
        
client_print(idprint_chat"[DEBUG]Password Acepted")
        
InverseArray(id)
    }
    else
    {
        
client_print(idprint_chat"[DEBUG]Array Determinant Not 1")
        
RegisterPassword(id)
    }

When the player write 4 numbers for the array Password, i want to check if the determinat of the array is 1 but when i put my four numbers, the plugin say that the determinat of the array is not 1. Why?
__________________

- ASM2SMA: Experimental AMXX Assembly encoder

- Defuse Bar Fix

Quote:
Originally Posted by Arkshine
I DON'T WANT TO SEE NOOOOOOOOOOOOOOO AHHHHH. MY EYES ARE ALREADY HURT.
S34Qu4K3 is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 10-09-2010 , 12:15   Re: Array Operations
Reply With Quote #2

What do you mean by determinat?
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-09-2010 , 12:19   Re: Array Operations
Reply With Quote #3

The password only allows 3 characters and then the last slot is ^0 because Password is a string with a size of 4, giving it a max length of 3.
Also, Password is not a 2D array for players, so you should not index it by the player id when copying it from szArg.

PHP Code:
if( !isdigit(szArg[0]) ) 
Should be
PHP Code:
if( !is_str_num(szArg[0]) || strlen(szArg) != 
So it checks if the whole string is a number than that it has 4 numbers.

PHP Code:
copyPassword[id], charsmaxPassword[] ), szArg 
Should be
PHP Code:
new iArg str_to_numszArg )
Password[0] = iArg 1000
Password
[1] = (iArg 100) % 10
Password
[2] = (iArg 10) % 10
Password
[3] = iArg 10
// 1234 / 1000 = 1
// (1234 / 100) % 10 = (12) % 10 = 2
// (1234 / 10) % 10 = (123) % 10 = 3
// 1234 % 10 = 4 
@wrecked_
It's a math term for matrices.
http://en.wikipedia.org/wiki/Determinant
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
S34Qu4K3
Veteran Member
Join Date: Jan 2010
Location: Galicia
Old 10-09-2010 , 12:21   Re: Array Operations
Reply With Quote #4

a b
X=
c d

Determinant= a × d − c ×b = 1

@Exolent
Now the plugin works but I don´t understand what mean the operations :S

// 1234 / 1000 = 1
// (1234 / 100) % 10 = (12) % 10 = 2
// (1234 / 10) % 10 = (123) % 10 = 3
// 1234 % 10 = 4

More: Why i can´t use this to make the inverse array?
PHP Code:

public InverseArray(id)
{
    
InversePassword[0] = Password[3]
    
InversePassword[1] = -Password[1]
    
InversePassword[2] = -Password[2]
    
InversePassword[3] = Password[1]
    
client_print(idprint_center"[DEBUG]Array Inversed, now is %s"InversePassword)
    

__________________

- ASM2SMA: Experimental AMXX Assembly encoder

- Defuse Bar Fix

Quote:
Originally Posted by Arkshine
I DON'T WANT TO SEE NOOOOOOOOOOOOOOO AHHHHH. MY EYES ARE ALREADY HURT.

Last edited by S34Qu4K3; 10-09-2010 at 12:46.
S34Qu4K3 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-09-2010 , 12:36   Re: Array Operations
Reply With Quote #5

Those calculations get the 4 digits of the number you need.

That is now an array of numbers, not a string.
So you can't just print it out like that.
You must print it as an integer.
PHP Code:
client_print(idprint_center"[DEBUG]Array Inversed, now is %d%d%d%d"InversePassword[0], InversePassword[1], InversePassword[2], InversePassword[3]) 
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
S34Qu4K3
Veteran Member
Join Date: Jan 2010
Location: Galicia
Old 10-09-2010 , 12:45   Re: Array Operations
Reply With Quote #6

Thank you again Exolent and i´ve found an error:

PHP Code:
    InversePassword[0] = Password[3]
    
InversePassword[1] = -Password[1]
    
InversePassword[2] = -Password[2]
    
InversePassword[3] = Password[1
Should be:
PHP Code:
    InversePassword[0] = Password[3]
    
InversePassword[1] = -Password[1]
    
InversePassword[2] = -Password[2]
    
InversePassword[3] = Password[0
And a last question: Exists any plugin for encrypt text or i´m trying to make the first??
__________________

- ASM2SMA: Experimental AMXX Assembly encoder

- Defuse Bar Fix

Quote:
Originally Posted by Arkshine
I DON'T WANT TO SEE NOOOOOOOOOOOOOOO AHHHHH. MY EYES ARE ALREADY HURT.

Last edited by S34Qu4K3; 10-09-2010 at 12:50.
S34Qu4K3 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-09-2010 , 18:38   Re: Array Operations
Reply With Quote #7

Quote:
Originally Posted by S34Qu4K3 View Post
And a last question: Exists any plugin for encrypt text or i´m trying to make the first??
md5?

Quote:
Originally Posted by wrecked_ View Post
What do you mean by determinat?
Quote:
Originally Posted by S34Qu4K3 View Post
a b
X=
c d

Determinant= a × d − c ×b = 1

A determinant is NOT an array operation. It is a matrix operation. Matrix != Array.
__________________

Last edited by fysiks; 10-09-2010 at 18:47.
fysiks is offline
S34Qu4K3
Veteran Member
Join Date: Jan 2010
Location: Galicia
Old 10-09-2010 , 19:04   Re: Array Operations
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
md5?
A determinant is NOT an array operation. It is a matrix operation. Matrix != Array.
Can you show me an example?

Yeah, i´m mistaken xD
__________________

- ASM2SMA: Experimental AMXX Assembly encoder

- Defuse Bar Fix

Quote:
Originally Posted by Arkshine
I DON'T WANT TO SEE NOOOOOOOOOOOOOOO AHHHHH. MY EYES ARE ALREADY HURT.
S34Qu4K3 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-09-2010 , 19:28   Re: Array Operations
Reply With Quote #9

When you code a matrix in Pawn, you will use arrays.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
S34Qu4K3
Veteran Member
Join Date: Jan 2010
Location: Galicia
Old 10-09-2010 , 19:41   Re: Array Operations
Reply With Quote #10

Im thinking, is not the same, array=matrix?

THis code can be optimized?:

PHP Code:
        TextEncrypted[0][0] = (szPieces[0][0] * Password[0]) + (szPieces[0][1] * Password[2])
    
TextEncrypted[0][1] = (szPieces[0][1] * Password[1]) + (szPieces[0][1] * Password[3])
    
TextEncrypted[1][0] = (szPieces[1][0] * Password[0]) + (szPieces[1][1] * Password[2])
    
TextEncrypted[1][1] = (szPieces[1][1] * Password[1]) + (szPieces[1][1] * Password[3])
    
TextEncrypted[2][0] = (szPieces[2][0] * Password[0]) + (szPieces[2][1] * Password[2])
    
TextEncrypted[2][1] = (szPieces[2][1] * Password[1]) + (szPieces[2][1] * Password[3]) 
__________________

- ASM2SMA: Experimental AMXX Assembly encoder

- Defuse Bar Fix

Quote:
Originally Posted by Arkshine
I DON'T WANT TO SEE NOOOOOOOOOOOOOOO AHHHHH. MY EYES ARE ALREADY HURT.
S34Qu4K3 is offline
Reply



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 10:17.


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