How to make 'Paused' 3D Text Label when someone pauses?
#1

Like the topic said, I want to make a 'Paused' 3D Text Label when someone pauses, my gamemode is using DCMD command processor. Can someone teach me how to make it?
Reply
#2

I will show you a VERY BASIC pause system.
  1. Add these at top of your list.
    pawn Code:
    #include <a_samp>

    //UPDATE_TIME is the time interval to check if player is paused or not.
    #define UPDATE_TIME 2000

    //PauseTimerr is timer for each player.
    new PauseTimer[MAX_PLAYERS];

    //To check if player was paused earlier .
    new bool:Paused[MAX_PLAYERS];

    //This is your 3D Text Label
    new Text3D:PauseText[MAX_PLAYERS];
  2. To Start Timer , When Player Spawns
    pawn Code:
    public OnPlayerSpawn(playerid)
    {
        PauseTimer[playerid] = SetTimerEx("Pause_Check",UPDATE_TIME,true,"i",playerid);
        //When a player spawn we start a timer which repeats itself after UPDATE_TIME (2000 ms)
        return 1;
    }
  3. Our Function
    pawn Code:
    forward Pause_Check(playerid);

    public Pause_Check(playerid)
    {
        new Float:x,Float:y,Float:z,Float:a;//Get Player Location and facing Angle.
        GetPlayerPos(playerid,x,y,z);
        GetPlayerFacingAngle(playerid,a);
        //If player's location is same as it was before UPDATE_TIME (2000 ms)
        if(x == GetPVarFloat(playerid,"x") && y == GetPVarFloat(playerid,"y") && z == GetPVarFloat(playerid,"z") && a == GetPVarFloat(playerid,"a"))
        {
            if (Paused[playerid] == false)//If he was not paused before 2 sec
            {
                //Create a 3D Text label .
                PauseText[playerid] = Create3DTextLabel("Paused", -1, x, y,z+1.5,100, GetPlayerVirtualWorld(playerid), 0);
            }
            //We now know he have paused.
            //This will take sure that we do not create multiple 3D text labels.
            Paused[playerid] = true;
        }
        //If he have moved/updated
        else
        {
            if (Paused[playerid] == true)//If he was paused before 2 sec.
            {
                Delete3DTextLabel(PauseText[playerid]);//We will delete the Label we created when he paused.
            }
            //And make him un pause.
            Paused[playerid] = false;
        }

        //Setting Player varibles.
        SetPVarFloat(playerid,"x",x);
        SetPVarFloat(playerid,"y",y);
        SetPVarFloat(playerid,"z",z);
        SetPVarFloat(playerid,"a",a);
        return 1;
    }
  4. To Destroy Timer when player Dies
    pawn Code:
    public OnPlayerDeath(playerid, killerid, reason)
    {
        KillTimer(PauseTimer[playerid]);
        return 1;
    }
Full code : Pastebin

BUG : If you do not move for UPDATE_TIME , it will treat you as a paused player.
Reply
#3

First use this: https://sampforum.blast.hk/showthread.php?tid=281590
and then this:
https://sampwiki.blast.hk/wiki/Attach3DTextLabelToPlayer
Reply
#4

Quote:
Originally Posted by [MM]RoXoR[FS]
View Post
I will show you a VERY BASIC pause system.
  1. Add these at top of your list.
    pawn Code:
    #include <a_samp>

    //UPDATE_TIME is the time interval to check if player is paused or not.
    #define UPDATE_TIME 2000

    //PauseTimerr is timer for each player.
    new PauseTimer[MAX_PLAYERS];

    //To check if player was paused earlier .
    new bool:Paused[MAX_PLAYERS];

    //This is your 3D Text Label
    new Text3D:PauseText[MAX_PLAYERS];
  2. To Start Timer , When Player Spawns
    pawn Code:
    public OnPlayerSpawn(playerid)
    {
        PauseTimer[playerid] = SetTimerEx("Pause_Check",UPDATE_TIME,true,"i",playerid);
        //When a player spawn we start a timer which repeats itself after UPDATE_TIME (2000 ms)
        return 1;
    }
  3. Our Function
    pawn Code:
    forward Pause_Check(playerid);

    public Pause_Check(playerid)
    {
        new Float:x,Float:y,Float:z,Float:a;//Get Player Location and facing Angle.
        GetPlayerPos(playerid,x,y,z);
        GetPlayerFacingAngle(playerid,a);
        //If player's location is same as it was before UPDATE_TIME (2000 ms)
        if(x == GetPVarFloat(playerid,"x") && y == GetPVarFloat(playerid,"y") && z == GetPVarFloat(playerid,"z") && a == GetPVarFloat(playerid,"a"))
        {
            if (Paused[playerid] == false)//If he was not paused before 2 sec
            {
                //Create a 3D Text label .
                PauseText[playerid] = Create3DTextLabel("Paused", -1, x, y,z+1.5,100, GetPlayerVirtualWorld(playerid), 0);
            }
            //We now know he have paused.
            //This will take sure that we do not create multiple 3D text labels.
            Paused[playerid] = true;
        }
        //If he have moved/updated
        else
        {
            if (Paused[playerid] == true)//If he was paused before 2 sec.
            {
                Delete3DTextLabel(PauseText[playerid]);//We will delete the Label we created when he paused.
            }
            //And make him un pause.
            Paused[playerid] = false;
        }

        //Setting Player varibles.
        SetPVarFloat(playerid,"x",x);
        SetPVarFloat(playerid,"y",y);
        SetPVarFloat(playerid,"z",z);
        SetPVarFloat(playerid,"a",a);
        return 1;
    }
  4. To Destroy Timer when player Dies
    pawn Code:
    public OnPlayerDeath(playerid, killerid, reason)
    {
        KillTimer(PauseTimer[playerid]);
        return 1;
    }
Full code : Pastebin

BUG : If you do not move for UPDATE_TIME , it will treat you as a paused player.
Thanks for the response, can I use this as Filterscript?
Reply
#5

sure
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)