I have a question....lol im writing a simple script for a ChangePKP Command that simply allows the user to change their Pkps to whatever they like! But i'd like to set a limit that they can't command over 10,000 Pkps. Heres the script:
Code:
if (Cmd[0] == "/changepkp")
{
[color=red]if (Cmd[1] <= 10000)[/color]
{
GC.MyChar.MyClient.LocalMessage(2000, "You Cannot Command Above 10,000 PKPs");
}
else
{
GC.MyChar.PKPoints = ushort.Parse(Cmd[1]);
}
}
Now my problem is the txt in red. Obviously this is an error because you cant compare String and Int using the "<=" sign. I've tried changing it using:
Code:
if ((int)Cmd[1] <= 10000)
but it still wont succesfully covert it! I also tried this piece of code i found when i googled the problem:
Code:
if (Convert.ToInt32(Cmd[1]) <= 10000)
which made it build without error, but when i ran the server and tried the command it always gave me the "Cannot Command Above 10,000 PKPs" no matter what value i entered!
EDIT: IM A RETARD
The code "Convert.ToInt32" actually did work! Stupidly i had the code wrong! I had
If (Cmd[1] is less than or equal to 10000)
when of course it should have been
If (Cmd[1] is greater than or equal to 10000)
Moral of the story: Always
Google and
Recheck your code before posting questions as i just learned