30.10.2017, 13:47
Hello! I've created a stock to store fish names at random, along with a /fish command that should check whether fish name 'linesnap' is chosen - and if it is - display a message to show the players line has snapped.
Unfortunately, the code only calls the line snap message and doesn't choose any other fish at random.
If I remove the linesnap check in the /fish command it works, but I need it this way.
I'm guessing the code below checks if "LineSnap" exists in the actual stock rather than what it generated at random.
How to change it so the code checks whether "LineSnap" is called at random?
Unfortunately, the code only calls the line snap message and doesn't choose any other fish at random.
If I remove the linesnap check in the /fish command it works, but I need it this way.
I'm guessing the code below checks if "LineSnap" exists in the actual stock rather than what it generated at random.
How to change it so the code checks whether "LineSnap" is called at random?
Код:
stock FishName() { new name[20]; switch(random(6)) { case 0: name = "LineSnap"; // here is what breaks fishing line case 1: name = "Trout"; case 2: name = "Shark"; case 3: name = "Tuna"; case 4: name = "Flounder"; case 5: name = "Sea Bass"; } return name; }
Код:
forward FishingTimer(playerid); public FishingTimer(playerid) { if(PlayerFishing[playerid] > 0) { new string[128]; PlayerFishing[playerid] = 0; TogglePlayerControllable(playerid, 1); if(strfind(FishName(), "LineSnap")) // And here is what fucks up the random fishes. Always shows line snapped now { format(string, sizeof(string), "%s's rod line has snapped!", GetName(playerid)); SendActionMessage(string); return 1; } else { format(string, sizeof(string), ""COLOR_CORNSILK"You have caught a fish - %s!", FishName()); SendClientMessage(playerid, -1, string); } } return 1; }