SA-MP Forums Archive
Alt-tabbing System. - 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)
+--- Thread: Alt-tabbing System. (/showthread.php?tid=379723)



Alt-tabbing System. - Bug. - 22.09.2012

How to Create a system
When a im Alt-tabbing its do a Afk Tag Like this: [AFK]
and when i come back its remove this afk tag
(( Sorry For bad English )).



Re: Alt-tabbing System. - Bug. - 22.09.2012

- Help Please, (( +Rep, For Helpers )).


Re: Alt-tabbing System. - SKAzini - 22.09.2012

Use SetPlayerName to set your name tag as [AFK].

Basically OnPlayerUpdate stops recieving when you're ALT + TAB:ed.


Re: Alt-tabbing System. - ikbenremco - 22.09.2012

this will apear above their head.
Код:
format(string, sizeof(string), "[AFK] %s [AFK]", Playerid);
                    new Text3D:label = Create3DTextLabel(string, COLOR_RED, 30.0, 40.0, 50.0, 40.0, 0, 0);
                    Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.7);



Re: Alt-tabbing System. - Bug. - 22.09.2012

Where i need put it?
Onplayerconnect?


Re: Alt-tabbing System. - mamorunl - 22.09.2012

OnPlayerUpdate, as told by SKAzini. Read all posts if you want your stuff to work.


Re: Alt-tabbing System. - Squirrel - 22.09.2012

Try using something like this

PHP код:
new afk[MAX_PLAYERS];
public 
OnGameModeInit()
{
    
// Don't use these lines if it's a filterscript
    
SetGameModeText("Blank Script");
    
AddPlayerClass(01958.37831343.157215.3746269.1425000000);
    
    
SetTimer("AFKTimer"10001);
    return 
1;
}
forward AFKTimer();
public 
AFKTimer()
{
    for (new 
0MAX_PLAYERSi++)
    {
        if (
IsPlayerConnected(i))
        {
            
afk[i]++;
            if (
afk[i] % 30 == 0)
            {
                new 
msg[60];
                
format(msg59"player %d is afk for %d seconds now!"iafk[i]);
                
SendClientMessageToAll(0xFFFFFF00msg);
            }
        }
    }
}
public 
OnPlayerUpdate(playerid)
{
    
afk[playerid] = 0;
    return 
1;




Re: Alt-tabbing System. - Bug. - 24.09.2012

Код:
public OnPlayerUpdate(playerid)
{
    format(string, sizeof(string), "[AFK] %s [AFK]", Playerid);
    new Text3D:label = Create3DTextLabel(string, 0xFF0000FF, 30.0, 40.0, 50.0, 40.0, 0, 0);
    Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.7);
	return 1;
}
Код:
G:\NpTDM[0.3e]\gamemodes\NpTDM.pwn(545) : error 017: undefined symbol "string"
G:\NpTDM[0.3e]\gamemodes\NpTDM.pwn(545) : error 017: undefined symbol "string"
G:\NpTDM[0.3e]\gamemodes\NpTDM.pwn(545) : error 029: invalid expression, assumed zero
G:\NpTDM[0.3e]\gamemodes\NpTDM.pwn(545) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
How to fix it?


Re: Alt-tabbing System. - Rimeau - 24.09.2012

Код:
//Where you create all your variables
new stringAFK[17];

public OnPlayerUpdate(playerid)
{
    format(stringAFK, sizeof(stringAFK), "[AFK] %d [AFK]", playerid);
    new Text3D:label = Create3DTextLabel(stringAFK, 0xFF0000FF, 30.0, 40.0, 50.0, 40.0, 0, 0);
    Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.7);
    return 1;
}
Try this.


Re: Alt-tabbing System. - mamorunl - 24.09.2012

Quote:
Originally Posted by Rimeau
Посмотреть сообщение
Код:
//Where you create all your variables
new stringAFK[16];

public OnPlayerUpdate(playerid)
{
    format(stringAFK, sizeof(stringAFK), "[AFK] %d [AFK]", playerid);
    new Text3D:label = Create3DTextLabel(stringAFK, 0xFF0000FF, 30.0, 40.0, 50.0, 40.0, 0, 0);
    Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.7);
    return 1;
}
Try this.
Why would you want a global variable for something that is only happening locally?