Sign in to follow this  
Followers 0
Minikori

Compare Number to String with number

4 posts in this topic

Hello, I have a part in my my script where it checks to see if the user broke a highscore. The problem is the user's score is a number but the IniRead() returns a string for the highscore. How can I check to see if the user broke the highscore?


For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Share this post


Link to post
Share on other sites



Hello, I have a part in my my script where it checks to see if the user broke a highscore. The problem is the user's score is a number but the IniRead() returns a string for the highscore. How can I check to see if the user broke the highscore?

If $userScore > Number($highscore) then

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

How about compare sections ?

I have this problem with this INI that i am trying to erase some players data.

What this code does is it's looking for players that have Level within specified range and then remove them.

It works so great i love it but it has one giant problem.

Problem is that it also removes main settings.

Check his out. i could not paste all code so i attached it.

INI is simply to big so i attached it.

Try using my code and see that everything works OK but it also removes very first few sections:

[uT2004RPG.MutUT2004RPG]

[DruidsRPG200.AbilityLoadedMonsters]

[uT2004RPG.RPGArtifactManager]

How can i fix it so it would avoid reading those sections ?

Hope to hear any reply

thanks!! your Number compare example helped me allot.

UT2004RPG.zip

Clean_RPG_V1.0.au3

Edited by lessstoopid

Share this post


Link to post
Share on other sites

Ok, a couple of things.

First of all, when you run with a "Min" parameter of "0", it will delete all sections.

Why?

MsgBox(4096, "Oh-oh", "Number() of a failed IniRead = " & Number("Return Error. Nothing found in specified range"))

You need to check that the IniRead() completed succesfully with something like

If StringInStr($level, "Return Error") then ContinueLoop

before you do your "If $level >= Number ($MinValue) and $level <= Number ($MaxValue) Then" check.

Next, all of your IniReads are failing!

This is because you are adding "RPGPlayerDataObject" to the section name

$level = IniRead ($filename,$Section[$X]& 'RPGPlayerDataObject','Level','Return Error. Nothing found in specified range')

The problem is, "RPGPlayerDataObject" already exists in the section name, so you are trying to execute an IniRead() like this

IniRead ($filename,"Kompute101 RPGPlayerDataObjectRPGPlayerDataObject", 'Level','Return Error. Nothing found in specified range')

Since no sections contain "RPGPlayerDataObjectRPGPlayerDataObject" your reads will always fail.

If you want to try reading only those sections that are player objects, then I'd suggest something like

If StringInStr($Section[$X], "RPGPlayerDataObject") then 
  $level = IniRead ($filename,$Section[$X],'Level','Return Error. Nothing found in specified range'); ....  etc

That should get you started.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0