[ HELP ] Big problem with PayDay System !
#1

Hello everybody. I have a big problem with Payday System. Of 5 payday, players are paid only 2-3 times. Somebody told me that the problem is the time since it left behind because of ping.

Код:
public PayDay()
{
	new string[128];
	new account,interest;
	new rent = 0;
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
		    if(PlayerInfo[i][pLevel] > 0)
		    {
			    if(MoneyMessage[i]==1)
				{
				    SendClientMessage(i, COLOR_LIGHTRED, "You failed to pay your debt, Jail time.");
				    GameTextForPlayer(i, "~r~Busted!", 2000, 1);
				    //SetPlayerInterior(i, 6);
					//SetPlayerPos(i,264.6288,77.5742,1001.0391);
					SetPlayerInterior(i, 0);
					TogglePlayerControllable(i,false);
					SetTimerEx("freezejail", 2000,0,"d",i);
					new pcell = random(3);
				    switch(pcell)
				    {
					    case 0:
					    {
					        SetPlayerPos(i,1778.6156,-1583.5420,1734.9430);
					        SetPlayerFacingAngle(i,2.6243);
					    }
					    case 1:
					    {
					        SetPlayerPos(i,1774.1909,-1583.0372,1734.9430);
					        SetPlayerFacingAngle(i,357.4647);
					    }
					    case 2:
					    {
					        SetPlayerPos(i,1770.1483,-1583.1619,1734.9430);
					        SetPlayerFacingAngle(i,3.0212);
					    }
				    }
		            PlayerInfo[i][pJailed] = 1;
		            ResetPlayerWeapons(i);
					WantedPoints[i] = 0;
					PlayerInfo[i][pJailTime] = 240;
					format(string, sizeof(string), "You are jailed for %d seconds.   Bail: Unable", PlayerInfo[i][pJailTime]);
					SendClientMessage(i, COLOR_LIGHTBLUE, string);
				}
				new playername2[MAX_PLAYER_NAME];
				GetPlayerName(i, playername2, sizeof(playername2));
				account = PlayerInfo[i][pAccount];
				new key = PlayerInfo[i][pPhousekey];
				if(key != 255)
				{
					rent = HouseInfo[key][hRent];
					if(strcmp(playername2, HouseInfo[key][hOwner], true) == 0)
					{
						rent = 0;
					}
					else if(rent > GetPlayerMoney(i))
					{
						PlayerInfo[i][pPhousekey] = 255;
						SendClientMessage(i, COLOR_WHITE, "You have been evicted.");
						rent = 0;
					}
					HouseInfo[key][hTakings] = HouseInfo[key][hTakings]+rent;
				}
				new tmpintrate;
				if (key != 255 && strcmp(playername2, HouseInfo[key][hOwner], true) == 0)
				{
				    if(PlayerInfo[i][pDonateRank] > 0) { tmpintrate = intrate+4; }
					else { tmpintrate = intrate+2; }//HouseInfo[key][hLevel]
				}
				else
				{
				    if(PlayerInfo[i][pDonateRank] > 0) { tmpintrate = 3; }
					else { tmpintrate = 1; }
				}
				if(PlayerInfo[i][pPayDay] >= 5)
				{
				    Tax += TaxValue;//Should work for every player online
				    PlayerInfo[i][pAccount] -= TaxValue;
				    if(PlayerInfo[i][pDonateRank] > 0)
					{
					    new bonus = PlayerInfo[i][pPayCheck] / 2;
					    PlayerInfo[i][pPayCheck] += bonus;
					}
					new checks = PlayerInfo[i][pPayCheck];
				    new ebill = (PlayerInfo[i][pAccount]/8000)*(PlayerInfo[i][pLevel]);
				    ConsumingMoney[i] = 1;
				    GivePlayerMoney(i, checks);
				    if(PlayerInfo[i][pAccount] > 0)
				    {
				    	PlayerInfo[i][pAccount] -= ebill;
				    	SBizzInfo[4][sbTill] += ebill;
					}
					else
					{
					    ebill = 0;
					}
					interest = (PlayerInfo[i][pAccount]/800)*(tmpintrate);
					PlayerInfo[i][pExp]++;
					PlayerPlayMusic(i);
					PlayerInfo[i][pAccount] = account+interest;
					SendClientMessage(i, COLOR_LIGHTGREEN, "_______________________");
					format(string, sizeof(string), "•  Paycheck: $%d", checks);
					SendClientMessage(i, 0xEBEBEBAA, string);
					format(string, sizeof(string), "•  Tax Money: -$%d", TaxValue);
					SendClientMessage(i, 0xEBEBEBAA, string);
					if(PlayerInfo[i][pPhousekey] != 255 || PlayerInfo[i][pPbiskey] != 255)
					{
					    format(string, sizeof(string), "•  Electricity: -$%d", ebill);
						SendClientMessage(i, 0xEBEBEBAA, string);
					}
					format(string, sizeof(string), "•  Balance: $%d", account);
					SendClientMessage(i, 0xEBEBEBAA, string);
					format(string, sizeof(string), "•  Interest Rate: 0.%d percent",tmpintrate);
					SendClientMessage(i, 0xEBEBEBAA, string);
					format(string, sizeof(string), "•  Interest Gained $%d", interest);
					SendClientMessage(i, 0xEBEBEBAA, string);
					SendClientMessage(i, COLOR_LIGHTGREEN, "_______________________");
					format(string, sizeof(string), "•  New Balance: $%d", PlayerInfo[i][pAccount]);
					SendClientMessage(i, 0xEBEBEBAA, string);
					format(string, sizeof(string), "•  Rent: -$%d", rent);
					SendClientMessage(i, 0xEBEBEBAA, string);
					//SendClientMessage(i, COLOR_LIGHTGREEN, "_______________________");
					format(string, sizeof(string), "~r~~h~PayDay~n~~w~Paycheck");
					PlayerInfo[i][pPoint] += 500;
					GameTextForPlayer(i, string, 5000, 1);
					rent = 0;
					PlayerInfo[i][pPayDay] = 0;
					PlayerInfo[i][pPayCheck] = 0;
					PlayerInfo[i][pConnectTime] += 1;
					if(PlayerInfo[i][pDonateRank] > 0)
					{
					    PlayerInfo[i][pPayDayHad] += 1;
					    if(PlayerInfo[i][pPayDayHad] >= 5)
					    {
					        PlayerInfo[i][pExp]++;
					        PlayerInfo[i][pPayDayHad] = 0;
					    }
					}
				}
				else
				{
				    SendClientMessage(i, COLOR_LIGHTRED, "* You haven't played long enough to obtain a PayDay.");
				}
			}
		}
	}
	Checkprop();
	return 1;
}
Even if the player plays 60 minutes he sometimes gets the message You haven't Played Long Enough to obtain a payday.

Код:
public SyncTime()
{
	new string[64];
	new tmphour;
	new tmpminute;
	new tmpsecond;
	gettime(tmphour, tmpminute, tmpsecond);
	FixHour(tmphour);
	tmphour = shifthour;
	if ((tmphour > ghour) || (tmphour == 0 && ghour == 23))
	{
		format(string, sizeof(string), "Este Ora %d:00 Fix",tmphour);
		BroadCast(COLOR_LIGHTGREEN,string);
		ghour = tmphour;
		PayDay();
		if (realtime)
		{
			SetWorldTime(tmphour);
		}
		format(string, sizeof(string), "~y~Lotto Time!! ~n~~w~Select Your Number ~n~~p~/lotto 1-80 ~g~($100) ~n~~r~Prize: ~g~$%d", Jackpot);
        if(TD3D == 1)
		{
       		KillTimer(HideTD4Timer);
			TextDrawHideForAll(TD3);
	 		TextDrawSetString(TD3, string);
			TextDrawShowForAll(TD3);
			HideTD4Timer = SetTimer("HideTD4", 8500, false);
		}
		else
		{
			TextDrawSetString(TD3, string);
		   	TextDrawShowForAll(TD3);
		   	TD3D = 1;
		   	HideTD4Timer = SetTimer("HideTD4", 8500, false);
		}
		SetTimer("StartLotto",20000,false);
	}
}
Sorry for my bad english.
Reply
#2

Yes, i witnessed problems like that, i think what is a problem of SA-MP, when the player have a high ping he loses a part of the connection causing bugs like that.
Reply
#3

So what can I do to solve this problem?
Reply
#4

Quote:
Originally Posted by Vibrate17
Посмотреть сообщение
So what can I do to solve this problem?
Is not possible to prevent this from happening, unless they kick the player for high ping.
Reply
#5

Nobody know any solution? I heard that one friend of mine solved the problem but has no time to solve and mine: |
Reply
#6

Run 6, 10 minute timers, each time check if the player has lost connection or not.
Or else
Make one global timer for all paydays?
Reply
#7

can be more specific? send me the code if is possible, please. Thank you.
Reply
#8

You are setting a timer for each player correct?
If so, just use one global timer for everyone?
Reply
#9

I use only one global timer for everyone. My GM is an Godfather edit.
Reply
#10

Guys, this happens without bad script, when the ping of player increases to 800-2000 he loses the conection with OnPlayerUpdate, Timers, and one part of chat.
I'm speaking of what happens with me and some friends.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)