Fishing : Make Player Wait
#1

Hey guys ! Im still working on a Fishing script and I just cant make the player wait and make an animation while fishing. The idea is pretty simple, it lets the player fish, and I want to make him wait and not being able to fish again for like 10 seconds.(which doesnt works ) Then, when he has 5 fishes, he can't fish anymore for 300 secs. (which works...)


So here is the script.

Код:
CMD:seafish(playerid, params[])
{
	new string[128], done, fish;
   	if(!IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use command.");
 	if(!IsAtFishingSpot2(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are on a boat standing near blue algae");
	if(FishTime[playerid])
	{
	    format(string, sizeof(string), "You need to wait %d more seconds before fishing again.", FishTime[playerid]);
		SendClientMessage(playerid, COLOR_GREY, string);

	    return 1;
	}
	for(new i=0; i<5; i++) // Fish
	{
	    if(!done)
	    {
		    if(!PlayerInfo[playerid][pFish][i]) done = i+1;
	    }
	}
	if(!done) return SendClientMessage(playerid, COLOR_GREY, "You can't carry anymore fishes.");
	done = done-1;
	// Catching
	if(strval(RPJL(playerid, JOB_FISHER)) == 1) fish = random(30)+5;
	else if(strval(RPJL(playerid, JOB_FISHER)) == 2) fish = random(60)+10;
	else if(strval(RPJL(playerid, JOB_FISHER)) == 3) fish = random(90)+15;
	else if(strval(RPJL(playerid, JOB_FISHER)) == 4) fish = random(120)+20;
	else if(strval(RPJL(playerid, JOB_FISHER)) == 5) fish = random(150)+30;
	PlayerInfo[playerid][pFish][done] = fish;
	format(string, sizeof(string), "* %s attempts to catch a fish using the fishing rod.", RPN(playerid));
 	SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
	format(string, sizeof(string), " You have caught a %d lbs fish.", fish);
	SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
	// Leveling
    new oldj = strval(RPJL(playerid, JOB_FISHER));
    PlayerInfo[playerid][pJobSkill][JOB_FISHER] ++;
	new newj = strval(RPJL(playerid, JOB_FISHER));
    if(oldj < newj)
	{
	    format(string, sizeof(string), "** Your Fisher level is now %d, you can now catch heavier fishes. **", newj);
		SendClientMessage(playerid, COLOR_YELLOW, string);
	}
	Fished[playerid] ++;
	if(Fished[playerid] >= 5)
	{
		Fished[playerid] = 0;
		FishTime[playerid] = 60*5;
		SetTimerEx("FishingTime", 1000, false, "i", playerid);
	}
	return 1;
}
Reply
#2

Change this:

Код:
        if(Fished[playerid] >= 5)
	{
		Fished[playerid] = 0;
		FishTime[playerid] = 60*5;
		SetTimerEx("FishingTime", 1000, false, "i", playerid);
	}
To this:

Код:
        if(Fished[playerid] >= 5)
	{
		Fished[playerid] = 0;
		FishTime[playerid] = 5;
		SetTimerEx("FishingTime", 1000, true, "i", playerid);
	}
This will give a 5 seconds cooldown. You don't need to add *60 because SetTimerEx and SetTimer are in milliseconds ( 1000 milliseconds = 1 second ). You also want to have it on true, because if it's on false, the timer will be set only once and FishingTime callback will be called only once. If we make it True, it will call it until FishTime[playerid] = 0;

Also, public FishingTime(playerid) or whatever you got should include this:

Код:
if(FishTime[playerid] > 0) { FishTime[playerid]--; }
Reply
#3

Oh well let me try then hahah :')

Edit : It doesnt work :/ It changed the 300 second timer to 5 second

Edit : I'd like to make the player wait 5 second everytime he use the command /seafish ^^

Edit : Ok it should work i'll try this
Reply
#4

Sure thing ^^. Tell me if something occurs though.
Reply
#5

Код:
forward FishingTime(playerid);
public FishingTime(playerid)
{
    FishTime[playerid] --;
    if(FishTime[playerid] < 0)
    {
        FishTime[playerid] = 0;
    }
	if(FishTime[playerid] > 0)
	{
		SetTimerEx("FishingTime", 1000, false, "i", playerid);
	}

	return 1;
}
This is what i have
Reply
#6

Make it like this:

Код:
forward FishingTime(playerid);
public FishingTime(playerid)
{
    if(FishTime[playerid] > 0) { FishTime[playerid] --; }
    return 1;
}
Reply
#7

Doesnt work I can keep fishing like crazy every time i type the command
Reply
#8

Change this

Код:
if(FishTime[playerid])
	{
	    format(string, sizeof(string), "You need to wait %d more seconds before fishing again.", FishTime[playerid]);
		SendClientMessage(playerid, COLOR_GREY, string);

	    return 1;
	}
To this:

Код:
if(FishTime[playerid] > 0)
	{
	    format(string, sizeof(string), "You need to wait %d more seconds before fishing again.", FishTime[playerid]);
		SendClientMessage(playerid, COLOR_GREY, string);

	    return 1;
	}
Reply
#9

Tried it but it's the same result. Thanks for your quick answers btw ^^
Reply
#10

Can you make it like this:

On top of your script: new FishCooldown[MAX_PLAYERS];

Код:
if(Fished[playerid] >= 5)
	{
                print("Works");
		Fished[playerid] = 0;
		FishTime[playerid] = 5;
		FishCooldown[playerid] = SetTimerEx("FishingTime", 1000, true, "i", playerid);
	}
Then change the forward to this:

Код:
forward FishingTime(playerid);
public FishingTime(playerid)
{
    if(FishTime[playerid] > 0) 
    { 
          FishTime[playerid] --;
          if(FishTime[playerid] == 0) { KillTimer(FishCooldown[playerid]); } 
    }
    return 1;
}
Tell me if it prints the "Work" text on the samp-server.exe when Fished[playerid] is 5 or above.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)