Help with my OnPlayerPause , OnplayerUnpause code
#1

Can someone help me please?
I made when a player pauses it gets the word AFK on hes character.
But when he unpauses it don't remove.
HELP PLEASE
Код:
public OnPlayerPause(playerid)
{
	new Float:X, Float:Y, Float:Z;
	GetPlayerPos( playerid, X, Y, Z );
	label[playerid] = Create3DTextLabel("PLAYER AFK",0x008080FF,X,Y,Z,40.0);
    Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
    return 1;
}

public OnPlayerUnPause(playerid)
{
    Delete3DTextLabel(label[playerid]);
    return 1;
}
Reply
#2

How do your OnPlayerPause and OnPlayerUnpause functions get called?
Reply
#3

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
How do your OnPlayerPause and OnPlayerUnpause functions get called?
https://sampforum.blast.hk/showthread.php?tid=186129

I think this is the include he's using.
Reply
#4

Well assuming the include is working, I'm guessing MAYBE it's calling OnPlayerPause multiple times before he unpauses, therefore the 3D label is created multiple times. It might be a good idea to check if the label is already created. For example:

pawn Код:
public OnPlayerPause(playerid)
{
    if(lblCreated[playerid] == 1) return 1;
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos( playerid, X, Y, Z );
    label[playerid] = Create3DTextLabel("PLAYER AFK",0x008080FF,X,Y,Z,40.0);
    Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
    lblCreated[playerid] = 1;
    return 1;
}
Then just change lblCreated[playerid] to 0 in Unpause
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)