[HELP] Quastion about OnPlayerSpawn
#1

Hi, I just got my Register system to work, but if players not login or not register, they will be killed and a message should pop up that explains what to do...
So, how should I do that?

Here is my script with only the register system installed.

http://pastebin.com/f38c0e32e

Thanks!
Reply
#2

You could just start a timer in OnPlayerConnect that will check in one minute if the player has logged in, if he has not, warn him, then kick him in one more minute.

I think this will work, no guarantees, it compiles but I have not tested.

pawn Код:
forward LoginWarn();
forward LoginKick();
pawn Код:
new NotLoggedIn[MAX_PLAYERS];
new LoginWarned[MAX_PLAYERS];
pawn Код:
public OnPlayerConnect(playerid)
{
    NotLoggedIn[playerid] = 1;
    SetTimer("LoginWarn",60000,false);
    return 1;
}
pawn Код:
public LoginWarn()
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(NotLoggedIn[i] == 1)
        {
            GameTextForPlayer(i,"WARNING: You will be kicked in sixty seconds if you do not login!",5000,5);
            LoginWarned[i] = 1;
            SetTimer("LoginKick",60000,false);
        }
   
    }
    return 1;
}
pawn Код:
public LoginKick()
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(NotLoggedIn[i] == 1)
        {
            if(LoginWarned[i] == 1)
            {
                GameTextForPlayer(i,"You have been kicked for being idle!",5000,5);
                Kick(i);
            }
            else
            {
                LoginWarn();
            }
      }

    }
    return 1;
}
Now just add:
pawn Код:
NotLoggedIn[playerid] = 1;
In the login command where ever it confirms you have logged in.

Let me know if there are any problems.


EDIT: I just realized thats not what you asked for, I misread 'kill' as kick.

When do you want it to kill him, when he tries to spawn? You can just keep him from spawning until he has logged in. Let me know.
Reply
#3

Quote:
Originally Posted by yeswecanchange09
You could just start a timer in OnPlayerConnect that will check in one minute if the player has logged in, if he has not, warn him, then kick him in one more minute.

I think this will work, no guarantees, it compiles but I have not tested.

pawn Код:
forward LoginWarn();
forward LoginKick();
pawn Код:
new NotLoggedIn[MAX_PLAYERS];
new LoginWarned[MAX_PLAYERS];
pawn Код:
public OnPlayerConnect(playerid)
{
    NotLoggedIn[playerid] = 1;
    SetTimer("LoginWarn",60000,false);
    return 1;
}
pawn Код:
public LoginWarn()
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(NotLoggedIn[i] == 1)
        {
            GameTextForPlayer(i,"WARNING: You will be kicked in sixty seconds if you do not login!",5000,5);
            LoginWarned[i] = 1;
            SetTimer("LoginKick",60000,false);
        }
   
    }
    return 1;
}
pawn Код:
public LoginKick()
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(NotLoggedIn[i] == 1)
        {
            if(LoginWarned[i] == 1)
            {
                GameTextForPlayer(i,"You have been kicked for being idle!",5000,5);
                Kick(i);
            }
            else
            {
                LoginWarn();
            }
      }

    }
    return 1;
}
Now just add:
pawn Код:
NotLoggedIn[playerid] = 1;
In the login command where ever it confirms you have logged in.

Let me know if there are any problems.


EDIT: I just realized thats not what you asked for, I misread 'kill' as kick.

When do you want it to kill him, when he tries to spawn? You can just keep him from spawning until he has logged in. Let me know.
I'm sorry for late reply.
When the Not Logged In player selects a skin and pushes the spawn button, he should just spawn dead and it will repeat untill he gets it, aha, I need to login

I used this script before on OnPlayerSpawn, but it dont work right now :/

Код:
if(gPlayerLogged[playerid] == 0)
SendClientMessage(playerid, COLOR_RED, "Please /register or /login to your account.");
SetPlayerHealth(playerid, 0.0);
return 1;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)