[Tutorial] Protection from 'Spawn button'
#1

Intro

This is very simple solution for very annoying problem.

Solution

Few days ago I had a problem like this (this is not my image, found it on the internet):

You see that 'spawn button' at the bottom?

While register dialog or login dialog or whatever is showed you can avoid it if 'spawn button' is visible.

Basically you are playing without registration or login.

So to avoid that I figured simple solution.

Add TogglePlayerSpectating(playerid, 1); under your OnPlayerConnect callback.

pawn Код:
public OnPlayerConnect(playerid)
{
    TogglePlayerSpectating(playerid, 1);
    // Rest of your code goes here.
    return 1;
}
A little explanation:

TogglePlayerSpectating = Toggle a player's spectate mode
playerid = The ID of the player
1 = TogglePlayerSpectating is ENABLED

While TogglePlayerSpectating is enabled 'spawn button' is hidden.

How to disable it?

We are going to disable it at Register dialog or Login dialog or at any dialog which will proceed to player spawning.

Examples:

pawn Код:
case DIALOG_REGISTER:
{
    // Your code goes here
    TogglePlayerSpectating(playerid, 0);
    return 1;
}
pawn Код:
case DIALOG_LOGIN:
{
    // Your code goes here
    TogglePlayerSpectating(playerid, 0);
    return 1;
}
pawn Код:
case DIALOG_WELCOME:
{
    // Your code goes here
    TogglePlayerSpectating(playerid, 0);
    return 1;
}
pawn Код:
case DIALOG_ANYTHING:
{
    // Your code goes here
    TogglePlayerSpectating(playerid, 0);
    return 1;
}
A little explanation:

TogglePlayerSpectating = Toggle a player's spectate mode
playerid = The ID of the player
0 = TogglePlayerSpectating is DISABLED

I prefer putting it at the end of your dialog.

Place it under Register dialog and Login dialog.

So that's it.

Please give a try and post your feedback.
Reply
#2

Nice trick.
Reply
#3

Yea.
Reply
#4

Yeah, a really nice trick, simple, but useful, good job.
Reply
#5

Good work, nice tutorial.

Thank you!
Reply
#6

Or just return 0 in OnPlayerRequestSpawn if not logged in. I should also remind you that TogglePlayerSpectating automatically calls OnPlayerSpawn when it's being disabled. This may or may not be useful to different types of server. Not everyone plays roleplay and some servers might actually want the class selection to appear.
Reply
#7

Somebody prefer that, somebody prefer TPS.

@Vince:

I can show you my code where TogglePlayerSpectating is being used with class selection. And it's working just great. I'm not saying that your words are wrong I just don't have that problem (using it side by side with class selection).
Reply
#8

After you enter your password to log in, my server still requires that you click spawn. I would really like to remove it and allow you to automatically log you in, How can I do this? Thanks.
Reply
#9

Can you send me your whole OnDialogResponse please?
Reply
#10

My ondialog response is massive, anything inparticular you want?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)