Wait on OnPlayerConnect -
KinderClans - 11.08.2018
So, what im trying to do is to set a timer of 5 seconds when a player connects, instead of showing him instantly class selection/any sort of things connected. I did in this way:
OnPlayerConnect:
pawn Код:
SendClientMessage(playerid, -1, ""GREEN"Please wait...estabilishing connection with "SERVER_NAME"");
SetTimerEx("ProcessPlayer", 5000, false, "i", playerid);
And the ProcessPlayer, after 5 seconds, processes everything (welcome messages, login/register dialog and so on).
The problem is: Doesn't work. I still get normal connect without waiting.
Why?
Re: Wait on OnPlayerConnect -
cdoubleoper - 11.08.2018
Show us the ProcessPlayer
Re: Wait on OnPlayerConnect -
KinderClans - 11.08.2018
pawn Код:
function ProcessPlayer(playerid)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "*Welcome to "SERVER_NAME"");
CheckPlayerAccount(playerid);
return 1;
}
Re: Wait on OnPlayerConnect -
cdoubleoper - 11.08.2018
Use stock
Re: Wait on OnPlayerConnect -
NeXTGoD - 11.08.2018
Use it as a public
Код:
forward ProcessPlayer(playerid);
public ProcessPlayer(playerid)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "*Welcome to "SERVER_NAME"");
CheckPlayerAccount(playerid);
return 1;
}
Re: Wait on OnPlayerConnect -
Dayrion - 12.08.2018
Quote:
Originally Posted by cdoubleoper
Use stock
|
ayyy
OT; SetTimer/SetTimerEx: "The function to be called must be public. That means it has to be forwarded."
https://sampwiki.blast.hk/wiki/SetTimerEx
Re: Wait on OnPlayerConnect -
KinderClans - 12.08.2018
Quote:
Originally Posted by NeXTGoD
Use it as a public
Код:
forward ProcessPlayer(playerid);
public ProcessPlayer(playerid)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "*Welcome to "SERVER_NAME"");
CheckPlayerAccount(playerid);
return 1;
}
|
pawn Код:
#define function%0(%1) forward %0(%1); public %0(%1)
Any ideas?
Re: Wait on OnPlayerConnect -
GangstaSunny. - 12.08.2018
The public has to be forwarded BEFORE the timer calls it.
And dont forget to return after the timer.
Re: Wait on OnPlayerConnect -
NaS - 12.08.2018
Quote:
Originally Posted by GangstaSunny.
The public has to be forwarded BEFORE the timer calls it.
And dont forget to return after the timer.
|
No it doesn't. It doesn't even have to be forwarded at all for it to work; it only forces a reparse if you don't forward them.
OT:
I understood it so that the message and dialog etc pop up correctly (so the timer works) but it doesn't prevent this buttons from spawning. Correct me if I'm wrong with that.
You need to actually prevent the class selection from popping up.
You can do it like this:
Create a global variable for checking if the player just connected. You only want to hide the Class Sel once otherwise it will be hidden every time a player enters the class selection:
Код:
new bool:gFirstConnect[MAX_PLAYERS];
and set it to true in OnPlayerConnect:
Код:
gFirstConnect[playerid] = true;
In OnPlayerRequestClass you check if it is the player's first class selection and if it is, toggle them spectating (which hides the class selection):
Код:
if(gFirstConnect[playerid]) TogglePlayerSpectating(playerid, 1);
Now, if you want to show the class selection again after a certain delay, add this to the timer:
Код:
gFirstConnect[playerid] = false;
ForceClassSelection(playerid); // This makes the class sel show after respawn. If you remove this, the player will spawn instantly
TogglePlayerSpectating(playerid, 0);
And the player will see the controls again after the delay.
Re: Wait on OnPlayerConnect -
DAKYSKYE - 12.08.2018
Quote:
Originally Posted by cdoubleoper
Use stock
|
stock can't be used for timers.