SetTimer
#1

So I had a command (/login) that would spawn the player automatically using
pawn Код:
SpawnPlayer(playerid);
but I decided the command was a bit old school so I added a dialog box instead. My only problem is that now after the player logs in it doesn't spawn them. I tried to make a timer to wait for a second after the box closes to spawn the player in hopes that this would fix the problem.

pawn Код:
forward OneSecondTimer(playerid);
public OneSecondTimer(playerid)
{
SpawnPlayer(playerid);
return 1;
}
pawn Код:
SetTimer(OneSecondTimer, 1000, false);
I think my problem is that I use (playerid) but I can't use SpawnPlayer without using playerid so I'm not sure why it won't allow me to use playerid. If anyone could shed some light that'd be great.

igdev.pwn(209) : error 076: syntax error in the expression, or invalid function call
Reply
#2

SetTimer is calling OneSecondTimer but is not passing playerid along with it. If you instead used SetTimerEx, parameters can be passed on to your function.
pawn Код:
SetTimerEx("OneSecondTimer",1000,0,"i",playerid);
But why don't you just spawn the player in OnDialogResponse?
Reply
#3

Quote:
Originally Posted by zDevon
Посмотреть сообщение
SetTimer is calling OneSecondTimer but is not passing playerid along with it. If you instead used SetTimerEx, parameters can be passed on to your function.
pawn Код:
SetTimerEx("OneSecondTimer",1000,0,"i",playerid);
But why don't you just spawn the player in OnDialogResponse?
The reason I don't spawn the player in OnDiablogResponse is because it seems to be easier the way I do it. If you look at my OnDialogResponse you might understand.

pawn Код:
if (dialogid == 2)//login
    {
    if (!response)
    {
    SendClientMessage(playerid, COLOR_RED, "SYSTEM: You must login to play.");
    Kick(playerid);
    return 1;
    }
    if (response)
    {
    LoginPlayer(playerid, inputtext);
    return 1;
    }
    }
    if (dialogid == 3)//register
    {
    if (!response)
    {
    SendClientMessage(playerid, COLOR_RED, "SYSTEM: You must register to play.");
    Kick(playerid);
    return 1;
    }
    if (response)
    {
    RegisterPlayer(playerid, inputtext);
    return 1;
    }
    }
    return 1;
Thanks for the suggestion btw.
Reply
#4

Well then you could spawn them in your login/register functions still instead of a timer. Did you try using SetTimerEx like I said?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)