ID:175382
 
My fishing coding is like makign it for skill and it wont work. Please help me fix these:
                    if(usr.fishing >= 0)
var/fish = rand(1,8)
if(fish == 1)
usr << "<b>The fish gets away!</b>"
return
if(fish == 2)
usr << "<b>The fish gets away!</b>"
return
if(fish == 3)
usr << "<b>The fish gets away!</b>"
return
if(fish == 4)
usr << "<b>You catch a fish!</b>"
usr.fishing += 1
new/obj/Fish(usr.loc)
if(fish == 5)
usr << "<b>The fish gets away!</b>"
return
if(fish == 6)
usr << "<b>The fish gets away!</b>"
return
if(fish == 7)
usr << "<b>The fish gets away!</b>"
return
if(fish == 8)
usr << "<b>The fish gets away!</b>"
return

if(usr.fishing >= 25)
var/fish = rand(1,4)
if(fish == 1)
usr << "<b>The fish gets away!</b>"
return
if(fish == 2)
usr << "<b>The fish gets away!</b>"
return
if(fish == 3)
usr << "<b>The fish gets away!</b>"
return
if(fish == 4)
usr << "<b>You catch a fish!</b>"
usr.fishing += 1
new/obj/Fish(usr.loc)

if(usr.fishing >= 50)
var/fish = rand(1,4)
if(fish == 1)
usr << "<b>The fish gets away!</b>"
return
if(fish == 2)
usr << "<b>The fish gets away!</b>"
return
if(fish == 3)
usr << "<b>You catch a fish!</b>"
usr.fishing += 1
new/obj/Fish(usr.loc)
if(fish == 4)
usr << "<b>You catch a fish!</b>"
usr.fishing += 1
new/obj/Fish(usr.loc)

if(usr.fishing >= 75)
var/fish = rand(1,4)
if(fish == 1)
usr << "<b>The fish gets away!</b>"
return
if(fish == 2)
usr << "<b>You catch a fish!</b>"
usr.fishing += 1
new/obj/Fish(usr.loc)
if(fish == 3)
usr << "<b>You catch a fish!</b>"
usr.fishing += 1
new/obj/Fish(usr.loc)
if(fish == 4)
usr << "<b>You catch a fish!</b>"
usr.fishing += 1
new/obj/Fish(usr.loc)

if(usr.fishing == 100)
var/fish = rand(1,4)
if(fish == 1)
usr << "<b>You catch a fish!</b>"
new/obj/Fish(usr.loc)
if(fish == 2)
usr << "<b>You catch a fish!</b>"
new/obj/Fish(usr.loc)
if(fish == 3)
usr << "<b>You catch a fish!</b>"
new/obj/Fish(usr.loc)
if(fish == 4)
usr << "<b>You catch a fish!</b>"
new/obj/Fish(usr.loc)
Well first what is the exact problem?
Second, you might want to shorten your code a bit by using >= and <= more instead of having a if == for each of the numbers. For example in the first lot of "Fish gets away!" you have 7 out of out saying it gets away.
This would be much better if you just had:
if(fish <= 7)
//Fish gets away code.
else
//Catching a fish code.

Third. Youve got a problem with how your using usr.fishing. Its possible for usr.fishing to be >= 0 and >= 25. Im not sure if you meant that or not.
In response to DarkView
i want to make it so if your skill is 0-24 you get certain chances to get a fish, same for 25-49, 50-74, 75-99, and 100
In response to Koolguy900095
Ok, then your going to need to understand the || and && opperators. Basically || means or, and && means and.
When you write a if() statement it can contain more then one argument if you use these. For example:
if(var1 == 1)
if(var2 == 2)
//Do something.

can be re-written to become:
if(var1 == 1 && var2 == 2)
//Do something.

Now its very important you understand the differnce between || (OR) and && (AND). AND means that both must be true, and OR means that only one must be true.
So this means that
var/var1 = 1
var/var2 = 1
if(var1 == 1 && var2 == 2)
src << "True"
else
src << "False"

will output "False", because only one part of the if() is true. However
var/var1 = 1
var/var2 = 1
if(var1 == 1 || var2 == 2)
src << "True"
else
src << "False"

will output "True", because one of the parts (var1 == 1) is true.
Now in your situation you'll want to use the && too check weather the value of usr.fishing is between >= 0 AND <= 24.
So it would look something like this.
if(usr.fishing >= 0 && usr.fishing <= 24)
//See weather you get a fish or not.
In response to DarkView
Thanks!