SA-MP Forums Archive
OnPlayerPause - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: OnPlayerPause (/showthread.php?tid=235877)



OnPlayerPause - Gertin - 06.03.2011

pawn Код:
public OnPlayerPause(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    Away[ playerid ] = Create3DTextLabel("{33FF66}I'm AFK,{FF3300} sorry ! {6633FF}Don't shoot me .",-1,30.0,40.0,50.0,40.0,0);
    Attach3DTextLabelToPlayer( Away[ playerid ], playerid, 0.0, 0.0, 0.7);
    GetPlayerPos(playerid,AFKX,AFKY,AFKZ);
    SetPlayerFacingAngle(playerid,273.2784);
    SetPlayerPos(playerid,-2673.5120,1410.2698,907.5703);
    SetPlayerInterior(playerid,3);
    SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerid) + 123);
    printf("ID %d paused the game.", playerid);
    return 0;
}
//-------------------------------------------------------------
public OnPlayerUnPause(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    Delete3DTextLabel( Away[ playerid ] );
    SetPlayerInterior(playerid,0);
    SetPlayerPos(playerid,AFKX,AFKY,AFKZ);
    SetPlayerVirtualWorld(playerid, 0);
    printf("ID %d unpaused the game.", playerid);
    return 0;
}

I use :
new Text3D:Away[ MAX_PLAYERS ];
1)It the code . First i need, how i can text, when player press ESC . I wan't the text over the head .

2)If player press ESC, he go in interior . That work but, if i stay in 1 place, he teleport me to interior. How i can fix that ?

Sry for my bad english .


Re: OnPlayerPause - alpha500delta - 06.03.2011

1) Download the 'OnPlayerPause' include
2) No idea... what exactly do you mean?


Re: OnPlayerPause - Stigg - 06.03.2011

This is a nice and neat way:

pawn Код:
new bool:bPaused[MAX_PLAYERS];

public OnGameModeInit()
{
    SetTimer("pauseCheck", 1000, true);
    return 1;
}

public pauseCheck()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(bPaused[i]) SetPlayerChatBubble(playerid, "Paused", 0xFF0000FF, 100.0, 1000);
            //do your stuff hear
            bPaused[i] = true;
        }
    }
    return 1;
}

public OnPlayerUpdate(playerid)
{
    bPaused[playerid] = false;
    return 1;
}



Re: OnPlayerPause - Gertin - 06.03.2011

Quote:
Originally Posted by alpha500delta
Посмотреть сообщение
1) Download the 'OnPlayerPause' include
2) No idea... what exactly do you mean?
1) I have that include, but name dont come,
2)WHen i press ESC , then player go away from other people, like he go in interior . Other ppl dont see him .


Re: OnPlayerPause - Gertin - 06.03.2011

Quote:
Originally Posted by Stigg
Посмотреть сообщение
if(bPaused[i]) SetPlayerChatBubble(playerid, "Paused", 0xFF0000FF, 100.0, 1000);
//do your stuff hear
bPaused[i] = true;

}
What stuff ? Like
pawn Код:
SetPlayerFacingAngle(playerid,273.2784);
    SetPlayerPos(playerid,-2673.5120,1410.2698,907.5703);
    SetPlayerInterior(playerid,3);
That ?

Or

pawn Код:
Away[ playerid ] = Create3DTextLabel("{33FF66}I'm AFK,{FF3300} sorry ! {6633FF}Don't shoot me .",-1,30.0,40.0,50.0,40.0,0);
    Attach3DTextLabelToPlayer( Away[ playerid ], playerid, 0.0, 0.0, 0.7);



Re: OnPlayerPause - Stigg - 06.03.2011

Try it all and change my mesage to yours and test it, should work.


Re: OnPlayerPause - Gertin - 06.03.2011

With head text that work, but if i am ID 4 and i press ESC, then i have text, but if ID 5 press ESC then, he dont have text and, now i need that too, like when i come back , then text go ago !


Re: OnPlayerPause - Scrip - 06.03.2011

pawn Код:
forward pauseCheck(playerid);

new bool:bPaused[MAX_PLAYERS];

public OnGameModeInit()
{
    SetTimer("pauseCheck", 1000, true);
    return 1;
}

public pauseCheck(playerid)
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(bPaused[i]) SetPlayerChatBubble(playerid, "Paused", 0xFF0000FF, 100.0, 1000);
            SetPlayerFacingAngle(playerid,273.2784);
            SetPlayerPos(playerid,-2673.5120,1410.2698,907.5703);
            SetPlayerInterior(playerid,3);
            bPaused[i] = true;
        }
    }
    return 1;
}

public OnPlayerUpdate(playerid)
{
    bPaused[playerid] = false;
    return 1;
}



Re: OnPlayerPause - Gertin - 06.03.2011

Quote:
Originally Posted by Scrip
Посмотреть сообщение
pawn Код:
forward pauseCheck(playerid);

new bool:bPaused[MAX_PLAYERS];

public OnGameModeInit()
{
    SetTimer("pauseCheck", 1000, true);
    return 1;
}

public pauseCheck(playerid)
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(bPaused[i]) SetPlayerChatBubble(playerid, "Paused", 0xFF0000FF, 100.0, 1000);
            SetPlayerFacingAngle(playerid,273.2784);
            SetPlayerPos(playerid,-2673.5120,1410.2698,907.5703);
            SetPlayerInterior(playerid,3);
            bPaused[i] = true;
        }
    }
    return 1;
}

public OnPlayerUpdate(playerid)
{
    bPaused[playerid] = false;
    return 1;
}
ITS DOSENT WORK !

I have
pawn Код:
public pauseCheck(playerid)
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(bPaused[i]) SetPlayerChatBubble(playerid, "Paused", 0xFF0000FF, 100.0, 1000);
            GetPlayerPos(playerid,AFKX,AFKY,AFKZ);
            SetPlayerFacingAngle(playerid,273.2784);
            SetPlayerPos(playerid,-2673.5120,1410.2698,907.5703);
            SetPlayerInterior(playerid,3);
            SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerid) + 123);
            Away[ playerid ] = Create3DTextLabel("{33FF66}I'm AFK,{FF3300} sorry ! {6633FF}Don't shoot me .",-1,30.0,40.0,50.0,40.0,0);
            Attach3DTextLabelToPlayer( Away[ playerid ], playerid, 0.0, 0.0, 0.7);
            bPaused[i] = true;
        }
    }
    return 1;
}
There nametag working . I need if you came back , your message on head go away and that, if you press ESC you go to interior . and if you came back, then you came back .


Re: OnPlayerPause - alpha500delta - 06.03.2011

It's supposed to be this I believe

pawn Код:
forward pauseCheck(playerid);

new bPaused[MAX_PLAYERS] = 0;

public OnGameModeInit()
{
    SetTimer("pauseCheck", 1000, true);
    return 1;
}

public pauseCheck(playerid)
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(bPaused[i] == 1)
            {
                   SetPlayerChatBubble(i, "Paused", 0xFF0000FF, 100.0, 1000);
                   SetPlayerFacingAngle(i,273.2784);
                   SetPlayerPos(i,-2673.5120,1410.2698,907.5703);
                   SetPlayerInterior(i,3);
             }
        }
    }
    return 1;
}

public OnPlayerUpdate(playerid)
{
    bPaused[playerid] = 0;
    else return bPaused[i] = 1;
    return 1;
}



Re: OnPlayerPause - Gertin - 07.03.2011

pawn Код:
else return bPaused[i] = 1;
There is mistake in OnPlayerUpdate ...


Re: OnPlayerPause - Davz*|*Criss - 07.03.2011

No idea we could not help you in this case.


Re: OnPlayerPause - Gertin - 07.03.2011

pawn Код:
public OnPlayerUpdate(playerid)
{
    //P_OnPlayerUpdate(playerid);
    //Delete3DTextLabel( Away[ playerid ] );
    bPaused[playerid] = 0;
    return bPaused[i] = 1;
}
When i use that, come error :
Код:
C:\Users\Gertin\Desktop\afkFS.pwn(261) : error 017: undefined symbol "i"
and that is line in :
pawn Код:
return bPaused[i] = 1;



Re: OnPlayerPause - Unknown123 - 07.03.2011

Quote:
Originally Posted by Gertin
Посмотреть сообщение
pawn Код:
public OnPlayerUpdate(playerid)
{
    //P_OnPlayerUpdate(playerid);
    //Delete3DTextLabel( Away[ playerid ] );
    bPaused[playerid] = 0;
    return bPaused[i] = 1;
}
When i use that, come error :
Код:
C:\Users\Gertin\Desktop\afkFS.pwn(261) : error 017: undefined symbol "i"
and that is line in :
pawn Код:
return bPaused[i] = 1;
pawn Код:
return bPaused[i] = 1;
to
pawn Код:
return bPaused[playerid] = 1;



Re: OnPlayerPause - Davz*|*Criss - 07.03.2011

pawn Код:
Include <sscanf>



Re: OnPlayerPause - alpha500delta - 07.03.2011

You can use "i" but then you need a loop, wich will lagg.

@Above: This has nothing to do with sscanf...


Re: OnPlayerPause - Gertin - 07.03.2011

now its work, but that have big bug everytime he tele me in that interior i think that thing is invisible


Re: OnPlayerPause - Stigg - 07.03.2011

When you tele to an interior, you have to set player interior, when you leave an interior you have to set player interior to:

Код:
SetPlayerInterior(playerid, 0);