09.03.2014, 22:14
Hello, I'm having a small issue.
Upon trying to raise a players variable from "RandomFish", it doesn't work. It just stays 0, and will sometimes raise +1. The variable I'm trying to raise is "fish"
I'm also having a problem with a timer not making a player controllable. (The timer just doesn't end in general.)
Upon trying to raise a players variable from "RandomFish", it doesn't work. It just stays 0, and will sometimes raise +1. The variable I'm trying to raise is "fish"
I'm also having a problem with a timer not making a player controllable. (The timer just doesn't end in general.)
pawn Код:
// This is the RandomFish cases.
forward RandomFish(playerid);
public RandomFish(playerid)
{
new rand = random(1);
switch(rand)
{
case 0:
{
fish[playerid]++;
new string[128];
format(string,sizeof(string), "Total Fish Carried: %d",fish);
SendClientMessage(playerid,COLOR_GREEN, "You've caught a fish. /eat to eat it.");
SendClientMessage(playerid,COLOR_GREY, string);
return 1;
}
case 1:
{
RemovePlayerHealth(playerid, 10);
SendClientMessage(playerid,COLOR_RED, "The fish bit you.");
}
}
return 1;
}
// And upon a player doing /fish it toggles them so they cant be controlled, but it doesn't end the timer.
CMD:fish(playerid, params[])
{
if(GameProgress == 0) return SCM(playerid, COLOR_GREY, "Error: You can't fish when a game is not in progress.");
if(IsPlayerReady[playerid] == 0) return SCM(playerid, COLOR_GREY, "Error: You're not in a game.");
if(fish[playerid] == 3) return SCM(playerid,COLOR_GREY, "Error: You're already holding enough fish. (3)");
if(currentlyfishing[playerid] == 1) return SCM(playerid,COLOR_GREY, "Error: You're already fishing.");
if(IsPlayerInRangeOfPoint(playerid,5.0,-1518.3820,-2238.1162,1.2963) || IsPlayerInRangeOfPoint(playerid,5.0,-1409.2754,-2023.9181,0.9553) || IsPlayerInRangeOfPoint(playerid,5.0,-1642.4501,-1711.1929,2.2226)
|| IsPlayerInRangeOfPoint(playerid, 5.0, -1247.4921,-2484.1455,1.1251) ||IsPlayerInRangeOfPoint(playerid, 5.0, -1225.4283,-2382.1177,1.2049) || IsPlayerInRangeOfPoint(playerid, 5.0, -1189.1252,-2154.5989,2.0511))
{
currentlyfishing[playerid] = 1;
IsFishing = SetTimerEx("FishTimer", 5000, false, "i", playerid);
TogglePlayerControllable(playerid, 0);
ApplyAnimation(playerid,"BOMBER","BOM_Plant_Loop",4,1,0,0, 0,0,1);
}
else
{
SCM(playerid,COLOR_GREY, "Error: You're not near a fishing spot. Search near water.");
}
return 1;
}
forward FishTimer(playerid);
public FishTimer(playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, Float:x, Float:y, Float:z);
SetPlayerPos(playerid, Float:x, Float:y, Float:z);
ClearAnimations(playerid);
TogglePlayerControllable(playerid, 1);
currentlyfishing[playerid] = 0;
RandomFish(playerid);
KillTimer(IsFishing);
return 1;
}