Raised This Month: $ Target: $400
 0% 

Plugins compiles ok, but doesn't work as expected (strings)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PyRo
Member
Join Date: Mar 2005
Old 04-25-2005 , 17:31   Plugins compiles ok, but doesn't work as expected (strings)
Reply With Quote #1

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
__________________
85.133.16.45:27035 - [CPP] Clan Server #1 (fun Maps)
85.133.16.48:27195 - [CPP] Clan Server #2 (Standard/Custom/Fun Maps)
PyRo is offline
PyRo
Member
Join Date: Mar 2005
Old 04-25-2005 , 20:11  
Reply With Quote #2

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?
__________________
85.133.16.45:27035 - [CPP] Clan Server #1 (fun Maps)
85.133.16.48:27195 - [CPP] Clan Server #2 (Standard/Custom/Fun Maps)
PyRo is offline
karlos
Veteran Member
Join Date: Apr 2004
Location: Germany/Poland
Old 04-26-2005 , 04:19  
Reply With Quote #3

try this:
Code:
if (isalpha(text[i]) && equal(text[i], text2[i], 1) ) {
compare text1 and text2 but only 1 char
__________________
alias White Panther
karlos is offline
PyRo
Member
Join Date: Mar 2005
Old 04-26-2005 , 07:47  
Reply With Quote #4

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.
__________________
85.133.16.45:27035 - [CPP] Clan Server #1 (fun Maps)
85.133.16.48:27195 - [CPP] Clan Server #2 (Standard/Custom/Fun Maps)
PyRo is offline
PyRo
Member
Join Date: Mar 2005
Old 04-26-2005 , 11:12  
Reply With Quote #5

Half way there thanks to an overly complicated hack
__________________
85.133.16.45:27035 - [CPP] Clan Server #1 (fun Maps)
85.133.16.48:27195 - [CPP] Clan Server #2 (Standard/Custom/Fun Maps)
PyRo 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 16:41.


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