[HELP] fishing permet
#1

Hello guys im stuck on this one well here i go.. i have made a fishing license that expires after 5 paydays like a permit but the problem im havin is when it gets to the 6th payday the permit hours start going in minus and keeps going back so when you buy another u have to buy 2 or 3 to top up the munus hours to get back into plus. so my question is any idea how to fix it ??

regards ktr



Код:
pFishLicenseTime,
PlayerInfo[playerid][pFishLicenseTime] = 0;
-----------------------------------------------

  if (GetPlayerMoney(playerid) > 500)
				{
				
				PlayerInfo[playerid][pFishLicenseTime] += 5;
				PlayerInfo[playerid][pFishLic] = 1;
				SendClientMessage(playerid, COLOR_GREY, "  You have been charged $500 for your purchase.");
				SendClientMessage(playerid,COLOR_GREY,"  Congratulations! You now have a 5 Hour fishing Permit.");
				SendClientMessage(playerid, COLOR_GRAD5, "You can check this anytime by typing /licenses");
		    SafeGivePlayerMoney(playerid,-500);
		    PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
		  	TogglePlayerControllable(playerid, 1);
				return 1;
				}
				else
				{
		    	SendClientMessage(playerid, COLOR_YELLOW, "You don't have enough cash.");
		    	TogglePlayerControllable(playerid, 1);

//---------- this bit in payday--------------

					format(string, sizeof(string), " Balance: $%d", account);
					SendClientMessage(i, COLOR_GRAD1, string);
					format(string, sizeof(string), " Interest Rate: 0.%d percent",tmpintrate);
					SendClientMessage(i, COLOR_GRAD2, string);
					format(string, sizeof(string), " Interest Gained $%d", interest);
					SendClientMessage(i, COLOR_GRAD3, string);
					SendClientMessage(i, COLOR_GRAD4, "|--------------------------------------|");
					format(string, sizeof(string), " New Balance: $%d", PlayerInfo[i][pAccount]);
					SendClientMessage(i, COLOR_GRAD5, string);
					format(string, sizeof(string), " Rent: -$%d", rent);
					SendClientMessage(i, COLOR_GRAD5, string);
					format(string, sizeof(string), "~y~PayDay~n~~w~Paycheck");
					GameTextForPlayer(i, string, 5000, 1);
					rent = 0;
					PlayerInfo[i][pPayDay] = 0;
					PlayerInfo[i][pPayCheck] = 0;
					PlayerInfo[i][pConnectTime] += 1;
					PlayerInfo[i][pDonorExtraPay]++;
					PlayerInfo[i][pFishLicenseTime] -= 1;
					
					if (PlayerInfo[i][pFishLic] == 1 && PlayerInfo[i][pFishLicenseTime] <= 0)
					{
						PlayerInfo[i][pFishLic] = 0;
						PlayerInfo[i][pFishLicenseTime] = 0;
						SendClientMessage(i, COLOR_LIGHTRED, "* Your Fishing License has expired!");
					}

					if (PlayerInfo[i][pFishingPole] > 0)
					{
						if ( (PlayerInfo[i][pFishLicenseTime] / 5) == 1)
						{
							PlayerInfo[i][pFishingPole] = 0;
							SendClientMessage(i, COLOR_LIGHTRED, "* Your Fishing Pole has broken!");
						}
					}
				format(var, 32, "FishTime=%d\n",PlayerInfo[playerid][pFishLicenseTime]);fwrite(hFile, var);

	if( strcmp( key , "FishTime" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pFishLicenseTime] = strvalEx( val ); }

-----------------this in licenses---------------------

format(string, sizeof(string), "** Fishing License: %s. (%d Hours Left)", text3, PlayerInfo[playerid][pFishLicenseTime]);
Reply
#2

What's a permet?
Reply
#3

He means a "fishing permit", The thing with you Mikep, You always make people look stupid, Yet you never really help.
Smartass.
Reply
#4

I help alot of people unknown to you.

Plus your "yet" shouldn't be capitalized, as it's after a comma!
Reply
#5

Quote:
Originally Posted by Mikep
I help alot of people unknown to you.

Plus your "yet" shouldn't be capitalized, as it's after a comma!
Correct my other mistake will yeah?
Reply
#6

So no actual help then? lol
Reply
#7

About the problem with the amount of licenses
replace
pawn Код:
PlayerInfo[playerid][pFishLicenseTime] += 5;
with
pawn Код:
PlayerInfo[playerid][pFishLicenseTime] = 5;
Reply
#8

I don't understand what needs to be fixed here?
Reply
#9

Well what i can make of it is that when each payday has gone it takes 1 hour of his 5 hour fishing permet and when the 5 hours is up it starts going backwards so his fishing permet is in minus like -1 -2 --3 and on and on so what i think he wants is it to stop at 0 and not continue going down
Reply
#10

replace this

pawn Код:
PlayerInfo[i][pFishLicenseTime] -= 1;
with this.

pawn Код:
if(PlayerInfo[i][pFishLicenseTime] > 0)
{
  PlayerInfo[i][pFishLicenseTime] -= 1;
}
That will stop the fishing license time from dropping below 0.


_________________________________________
Alt: You can also do this as an alternate way.
pawn Код:
PlayerInfo[i][pFishLicenseTime] -= 1;
if(Playerinfo[i][pFishLicenseTime] <= 0)
{
  PlayerInfo[i][pFishLicenseTime]++;
}
This will still drop the amount by 1, but then checks if its below 0 and if it is, it adds 1. This makes it 0 again. Both ways will work. Its up to you which you prefer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)