[HELP] Phone system problem
#1

Script: My own
Problem: I'm trying to make Phone system. I almost succeeded, i have only one problem.
When i'm a caller or called player (what ever) hangup the Call, next time when player join (if i hanguped the call, than other player when join and reverse), Server send him a lot of messages ("%s nema dovoljno kredita da nastavi razgovor! / %s dont have enough credit to continue conversation")
So, i have the question for you, how can i make a timer or whatever to check when player talking if he have enough credit to continue talking ? (EDIT: this is only when i do /rcon gmx)

Now, i have one timer every sec, but i dont work with it... I must make something else, to do same function

Код:
task TaxiMeter[1000]()
{
	new sendername[MAX_PLAYER_NAME], str[256];
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    if(InCall[i] != 999 && iCall[i] != 999)
		{
		    if(PlayerInfo[i][pMobileCredit] == 0)
		    {
		        iCall[i] = 999;
		        InCall[i] = 999;
		        InCall[CalledPlayer[i]] = 999;
		        SCM(i, BOJA_CRVENA, "Nemate dovoljno kredita da nastavite razgovor!");
		        GetPlayerName(i, sendername, sizeof(sendername));
		        format(str, sizeof(str), "%s nema dovoljno kredita da nastavi razgovor!", sendername);
		        SCM(CalledPlayer[i], BOJA_CRVENA, str);
		        Caller[CalledPlayer[i]] = 999;
		        CalledPlayer[i] = 999;
		    }
		    else
		   {
			PlayerInfo[i][pMobileCredit] -= 1;
			savePlayer(i);
		   }
		}
	}
}
Sorry for my bad English, i think you understand what's the problem
Reply
#2

You may...

Global Variable ---->
pawn Код:
new Timers[MAX_PLAYERS];
OnPlayerConnect --->
pawn Код:
Timers[playerid] = SetTimerEx("TaxiMeter", 1000, true, "i", playerid);
OnPlayerDisconnect --->
pawn Код:
KillTimer(Timers[playerid]);

Well, about GMX. So, if you have all these times already set, you show end up them on the GMX process (GameModeExit). So, put that at it:

pawn Код:
for(int a = 0; a < MAX_PLAYERS; a++) if(IsPlayerConnected(a)) KillTimer(Timers[a]);

Sorry if any code is wrong in synthax, so much time I won't go in Pawn language.
Reply
#3

Look this : https://sampforum.blast.hk/showthread.php?tid=55261
pawn Код:
new sendername[MAX_PLAYER_NAME+1], str[128];
Reply
#4

Quote:
Originally Posted by Dutheil
Посмотреть сообщение
Look this : https://sampforum.blast.hk/showthread.php?tid=55261
pawn Код:
new sendername[MAX_PLAYER_NAME+1], str[128];
You don't need to put MAX_PLAYER_NAME+1 as a number of cells because MAX_PLAYER_NAME is enough.
Reply
#5

Quote:
Originally Posted by dominik523
Посмотреть сообщение
You don't need to put MAX_PLAYER_NAME+1 as a number of cells because MAX_PLAYER_NAME is enough.
But the lenght of the name is 24 (MAX_PLAYER_NAME), but you forget the nullbyte. So MAX_PLAYER_NAME+1 is better
Reply
#6

I forgot to post full Timer with TaxiMeter (for TAXI job) and PhoneCallCheck

Код:
task TimerForAll[1000]()
{
	new sendername[MAX_PLAYER_NAME], str[256];
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    if(TaxiTime[i] > 0 && TaxiDriver[i] < 999 && IsPlayerInAnyVehicle(i) && IsATaxiJobVehicle(GetPlayerVehicleID(i)))
	    {
	        if(GetPlayerMoney(i) <= TaxiTime[i])
	        {
             	GivePlayerMoney(i, -TaxiTime[i]);
             	RemovePlayerFromVehicle(i);
             	TaxiMoney[TaxiDriver[i]] += TaxiTime[i];
	            format(str, sizeof(str), "Nemate dovoljno novca da nastavite voznju, platili ste %d$", TaxiTime[i]);
	            SCM(i, BOJA_NARANDZASTA, str);
				format(str, sizeof(str), "Putnik nema dovoljno novca da nastavi voznju. Napustio je vozilo i platio (20)+%d$", TaxiTime[i]);
				SCM(TaxiDriver[i], BOJA_NARANDZASTA, str);
				TaxiTime[i] = 0;
				TaxiDriver[i] = 0;
			}
			else
			{
			    TaxiTime[i] += 1;
				format(str, sizeof(str), "CENA VOZNJE: %d", TaxiTime[i]);
				GameTextForPlayer(i, str, 1000, 6);
			}
		}
	 	else if(InCall[i] != 999 && iCall[i] != 999)
		{
		    if(PlayerInfo[i][pMobileCredit] == 0)
		    {
		        iCall[i] = 999;
		        InCall[i] = 999;
		        InCall[CalledPlayer[i]] = 999;
		        SCM(i, BOJA_CRVENA, "Nemate dovoljno kredita da nastavite razgovor!");
		        GetPlayerName(i, sendername, sizeof(sendername));
		        format(str, sizeof(str), "%s nema dovoljno kredita da nastavi razgovor!", sendername);
		        SCM(CalledPlayer[i], BOJA_CRVENA, str);
		        Caller[CalledPlayer[i]] = 999;
		        CalledPlayer[i] = 999;
			}
			else
			{
			    PlayerInfo[i][pMobileCredit] -= 1;
			    SavePlayer(i);
			}
		}
	}
}
Should i do the same, to call the Timer when player JOIN ?
Reply
#7

Quote:
Originally Posted by Dutheil
Посмотреть сообщение
But the lenght of the name is 24 (MAX_PLAYER_NAME), but you forget the nullbyte. So MAX_PLAYER_NAME+1 is better
Well I've seen it here:
http://forum.sa-mp.com/showthread.ph...48#post1161048
But it's okay, one cell isn't a big deal.
Reply
#8

Quote:
Originally Posted by dominik523
Посмотреть сообщение
Well I've seen it here:
http://forum.sa-mp.com/showthread.ph...48#post1161048
But it's okay, one cell isn't a big deal.
We never know ^^'
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)