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.
};
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]);
}
[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
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]);
error 035: argument type mismatch (argument 1)
// on line :
new randWeight = randEx(g_Fishes[rand][1], g_Fishes[rand][2]);
print("random fist");
new rand= random(sizeof(g_Fishes));
printf("%s || Min Weight: %d || Max Weight: %d", g_Fishes[rand][0], g_Fishes[rand][1], g_Fishes[rand][2]);
you dont need randomEx
just use new rand = random(sizeof(g_Fishes)); and then after it use g_Fishes[rand][1] and g_Fishes[rand][2] in any way you want to like for printing it will be like this pawn Код:
|
new rand = random(sizeof(g_Fishes));
new var = g_Fishes[rand][2]-g_Fishes[rand][1];
new randweight = random(var) + var;
//now use randweight as random weight it will be between minimum and maximum always :D
oh thatt for that do like this
pawn Код:
|
error 033: array must be indexed (variable "g_Fishes")
new var = g_Fishes[rand][2]-g_Fishes[rand][1];
enum fish
{
FishName[50],
MinWeight,
MaxWeight
};
new g_Fishes[][fish] = {
{"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.
};
/*==========================================*/
new rand = random(sizeof(g_Fishes));
new var = g_Fishes[rand][MaxWeight]-g_Fishes[rand][MinWeight];
new randweight = random(var) + var;
try like this
not sure but this should work pawn Код:
|