AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How do you use the modulus in amxx if there is one (https://forums.alliedmods.net/showthread.php?t=76028)

silentt 08-17-2008 00:50

How do you use the modulus in amxx if there is one
 
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.

Lee 08-17-2008 00:57

Re: How do you use the modulus in amxx if there is one
 
There's no reason that shouldn't work.

silentt 08-17-2008 01:09

Re: How do you use the modulus in amxx if there is one
 
hmm okay well ill go over my code again and check my variables and try with just putting numbers like i put there

silentt 08-17-2008 01:11

Re: How do you use the modulus in amxx if there is one
 
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

Exolent[jNr] 08-17-2008 01:32

Re: How do you use the modulus in amxx if there is one
 
Show me the line where the error is.

silentt 08-17-2008 01:34

Re: How do you use the modulus in amxx if there is one
 
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 08-17-2008 01:35

Re: How do you use the modulus in amxx if there is one
 
Exolent[jNr]: if(16 % 2 == 0)

Exolent[jNr] 08-17-2008 02:00

Re: How do you use the modulus in amxx if there is one
 
Show me the full code that you used.

Lee 08-17-2008 02:03

Re: How do you use the modulus in amxx if there is one
 
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.

silentt 08-17-2008 14:24

Re: How do you use the modulus in amxx if there is one
 
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.


All times are GMT -4. The time now is 03:09.

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