AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Plugins compiles ok, but doesn't work as expected (strings) (https://forums.alliedmods.net/showthread.php?t=12815)

PyRo 04-25-2005 17:31

Plugins compiles ok, but doesn't work as expected (strings)
 
I've posted this over at dodplugins.net, but I'll post it here too since it's driving me nuts and I might get a faster reply here :?

I started working on my 2nd plugin today, I managed to get rid of all the compiler errors, but it doesn't run as expected and I can't work out why so I'm hoping one of you guys could help me out with this.

Here's the code;
Code:

<removed>
What I want the plugin to do is check if the string at least x characters (amx_caps_minlen) long and if over y percent (mx_caps_minpercent) of the string is in caps and if it is it'll call punish() on them.
At the moment punish() will only be called if there's no lower case characters in the string so "HELLO WORLD" will trigger it, but "HELLO WORLd" wont.
What am I doing wrong?

Any help with this would be really appreciated, I'm a complete newb at this so it's probably something completly stupid :?.

Pyro

PyRo 04-25-2005 20:11

Turns out I was misunderstanding how strings in SMALL work.
If string was set to "Hello World!" I'd expect string[1] to return "e", but instead it returns "ello World!".
How would I go about getting only a single character from a string?

karlos 04-26-2005 04:19

try this:
Code:

if (isalpha(text[i]) && equal(text[i], text2[i], 1) ) {
compare text1 and text2 but only 1 char

PyRo 04-26-2005 07:47

Quote:

Originally Posted by karlos
try this:
Code:

if (isalpha(text[i]) && equal(text[i], text2[i], 1) ) {
compare text1 and text2 but only 1 char

Just recompiled and I'm waiting for the next map change to test it, but even if equal works like it should I still have no way of getting only a simgle character so the isalpha won't work like it should :(

Edit: Just tested and it's not working, probably because isalpha is returning false because of the null character terminating the string.

PyRo 04-26-2005 11:12

Half way there thanks to an overly complicated hack :)


All times are GMT -4. The time now is 16:41.

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