30.06.2014, 14:20
So, I was trying to make a fishing system.
Code works fine at printing (debug)
Does prints
But when it comes to
It outputs
Help, please?
The problem I have is on randWeight. Which is the random value of MIN_WEIGHT of the fish and MAX_WEIGHT. Hence why the randomEx function is there
pawn Код:
new
g_Fishes[][][] = {
{"Angelfish", 10, 88}, // {Fish name} {Min. weight [pounds]} {Max. weight [pounds]}
{"Brill", 10, 78},
{"Catfish", 40, 120},
{"Dartfish", 30, 100},
{"Electric Eel", 40, 118},
{"Frogfish", 25, 105},
{"Giant Sea Bass", 125, 302},
{"Horn Shark", 50, 200}, // A shark!
{"Icefish", 10, 40},
{"Jackfish", 30, 80},
{"Koi", 40, 120},
{"Lemon Shark", 95, 255}, // I like lemons, also sharks
{"Mackerel", 20, 75},
{"Northern Pike", 20, 60},
{"Oilfish", 60, 135},
{"Porbeagle Shark", 135, 270}, // Another shark
{"Quillfish", 10, 50},
{"Requiem Shark", 60, 200}, // Another shark
{"Salmon", 30, 120},
{"Trout", 30, 75},
{"Unicorn Fish", 10, 40}, // Search on wikipedia.....
{"Viperfish", 10, 40},
{"Whale Shark", 400, 1000}, // This fish is really rewarding because I love sharks, lol. (can reach 66k lbs but hey...)
{"Yellowfin Tuna", 10, 60},
{"Zebra Bullhead Shark", 50, 120} // Last fish and the last shark.
};
pawn Код:
print("Fishes loaded:");
for (new i, j = sizeof(g_Fishes); i < j; ++ i) {
printf("%s || Min Weight: %d || Max Weight: %d", g_Fishes[i][0], g_Fishes[i][1], g_Fishes[i][2]);
}
pawn Код:
[21:30:21] Fishes loaded:
[21:30:21] Angelfish || Min Weight: 10 || Max Weight: 88
[21:30:21] Brill || Min Weight: 10 || Max Weight: 78
[21:30:21] Catfish || Min Weight: 40 || Max Weight: 120
[21:30:21] Dartfish || Min Weight: 30 || Max Weight: 100
[21:30:21] Electric Eel || Min Weight: 40 || Max Weight: 118
[21:30:21] Frogfish || Min Weight: 25 || Max Weight: 105
[21:30:21] Giant Sea Bass || Min Weight: 125 || Max Weight: 302
[21:30:21] Horn Shark || Min Weight: 50 || Max Weight: 200
[21:30:21] Icefish || Min Weight: 10 || Max Weight: 40
[21:30:21] Jackfish || Min Weight: 30 || Max Weight: 80
[21:30:21] Koi || Min Weight: 40 || Max Weight: 120
[21:30:21] Lemon Shark || Min Weight: 95 || Max Weight: 255
[21:30:21] Mackerel || Min Weight: 20 || Max Weight: 75
[21:30:21] Northern Pike || Min Weight: 20 || Max Weight: 60
[21:30:21] Oilfish || Min Weight: 60 || Max Weight: 135
[21:30:21] Porbeagle Shark || Min Weight: 135 || Max Weight: 270
[21:30:21] Quillfish || Min Weight: 10 || Max Weight: 50
[21:30:21] Requiem Shark || Min Weight: 60 || Max Weight: 200
[21:30:21] Salmon || Min Weight: 30 || Max Weight: 120
[21:30:21] Trout || Min Weight: 30 || Max Weight: 75
[21:30:21] Unicorn Fish || Min Weight: 10 || Max Weight: 40
[21:30:21] Viperfish || Min Weight: 10 || Max Weight: 40
[21:30:21] Whale Shark || Min Weight: 400 || Max Weight: 1000
[21:30:21] Yellowfin Tuna || Min Weight: 10 || Max Weight: 60
[21:30:21] Zebra Bullhead Shark || Min Weight: 50 || Max Weight: 120
pawn Код:
stock randEx(min = cellmin, max = cellmax)
return random(max - min + 1) + min;
// in a command
new rand = random(sizeof(g_Fishes));
new randWeight = randEx(g_Fishes[rand][1], g_Fishes[rand][2]);
pawn Код:
error 035: argument type mismatch (argument 1)
// on line :
new randWeight = randEx(g_Fishes[rand][1], g_Fishes[rand][2]);
The problem I have is on randWeight. Which is the random value of MIN_WEIGHT of the fish and MAX_WEIGHT. Hence why the randomEx function is there