Raised This Month: $ Target: $400
 0% 

How do you use the modulus in amxx if there is one


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
silentt
Member
Join Date: Feb 2006
Location: Toronto, Ontario, Canada
Old 08-17-2008 , 00:50   How do you use the modulus in amxx if there is one
Reply With Quote #1

The modulus I know in C and C++ is '%', so I was wondering how it is used in amxx if it is even in it. Cause it doesn't work for me.

Example code:
Code:
if(16 % 2 == 0)
{
      client_print(0, print_chat, "16 is evenly divisable")
}
The code was thought up on the spot, so please post about modulus and how to use it rather than how stupid this piece of code is.
silentt is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 08-17-2008 , 00:57   Re: How do you use the modulus in amxx if there is one
Reply With Quote #2

There's no reason that shouldn't work.
__________________
No support via PM.

Last edited by Lee; 08-17-2008 at 01:00.
Lee is offline
silentt
Member
Join Date: Feb 2006
Location: Toronto, Ontario, Canada
Old 08-17-2008 , 01:09   Re: How do you use the modulus in amxx if there is one
Reply With Quote #3

hmm okay well ill go over my code again and check my variables and try with just putting numbers like i put there
silentt is offline
silentt
Member
Join Date: Feb 2006
Location: Toronto, Ontario, Canada
Old 08-17-2008 , 01:11   Re: How do you use the modulus in amxx if there is one
Reply With Quote #4

hmm when i try just numbers, trying that one actually it gives my this
Code:
Warning: Redundant test: constant expression is non-zero on line 59
silentt is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-17-2008 , 01:32   Re: How do you use the modulus in amxx if there is one
Reply With Quote #5

Show me the line where the error is.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
silentt
Member
Join Date: Feb 2006
Location: Toronto, Ontario, Canada
Old 08-17-2008 , 01:34   Re: How do you use the modulus in amxx if there is one
Reply With Quote #6

figured out the problem I think, first is i got that warning becuase it needs a variable or it will tell me its dumb to do something like that. Then the first time when it didnt work was because modulus cant work if the number before the modulus is smaller. I think from running tests.

However I also get this whenever I do modulus (%) or division (/). First it will tell me to put debug at the end of my plugin in plugins.ini. When I do that it tells me this on the line where I use modulus or division
Code:
L 08/17/2008 - 01:31:50: [AMXX] Run time error 11: divide
Anyone know why or have anything they can tell me about it. If you need an example the example is what I had above 16 % 2 when I replace with variables and whatnot and get it to work I get that error, same with if I did regular division.
silentt is offline
silentt
Member
Join Date: Feb 2006
Location: Toronto, Ontario, Canada
Old 08-17-2008 , 01:35   Re: How do you use the modulus in amxx if there is one
Reply With Quote #7

Exolent[jNr]: if(16 % 2 == 0)
silentt is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-17-2008 , 02:00   Re: How do you use the modulus in amxx if there is one
Reply With Quote #8

Show me the full code that you used.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 08-17-2008 , 02:03   Re: How do you use the modulus in amxx if there is one
Reply With Quote #9

The Pawn compiler is being uncharacteristically intelligent. 16 % 2 will obviously always equal 0. The warning is telling you that your code contains a calculation that will always have the same answer and so it is redundant. You can safely ignore that warning.
__________________
No support via PM.
Lee is offline
silentt
Member
Join Date: Feb 2006
Location: Toronto, Ontario, Canada
Old 08-17-2008 , 14:24   Re: How do you use the modulus in amxx if there is one
Reply With Quote #10

kk thanks thats what I thought, that example was actually just there because I use using it as an example my actual program is using variables, but I always get a division error ingame when it is debugging, I get this when I use division or modulus.
silentt is offline
Reply


Thread Tools
Display Modes

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 03:09.


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