Wait on OnPlayerConnect
#1

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?
Reply
#2

Show us the ProcessPlayer
Reply
#3

pawn Код:
function ProcessPlayer(playerid)
{
    SendClientMessage(playerid, COLOR_LIGHTRED, "*Welcome to "SERVER_NAME"");
    CheckPlayerAccount(playerid);
    return 1;
}
Reply
#4

Use stock
Reply
#5

Use it as a public

Код:
forward ProcessPlayer(playerid);
public ProcessPlayer(playerid)
{
   	SendClientMessage(playerid, COLOR_LIGHTRED, "*Welcome to "SERVER_NAME"");
	CheckPlayerAccount(playerid);
    return 1;
}
Reply
#6

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
Reply
#7

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?
Reply
#8

The public has to be forwarded BEFORE the timer calls it.

And dont forget to return after the timer.
Reply
#9

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.
Reply
#10

Quote:
Originally Posted by cdoubleoper
Посмотреть сообщение
Use stock
stock can't be used for timers.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)