Aim at NPC to start Rob!
#1

Can you show me the code to rob with time when i aimed at the NPC?
Reply
#2

For actors: GetPlayerTargetActor(playerid)
For NPC: GetPlayerTargetPlayer(playerid)

Use it in OnPlayerUpdate or timer.
Reply
#3

I created one like this:
pawn Code:
forward RobCluckin(playerid);

public RobCluckin(playerid)
{
    new rand = random(5000)+0;
    GivePlayerMoney(playerid,rand);
    new pname[MAX_PLAYER_NAME], string[80 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(string, sizeof(string), ""COLOR_RED"[ROBBERY] %s has robbed Cluckin Bell (Downtown) and received %i.", pname, rand);
    SendClientMessageToAll(-1, string);
    return 1;
}

public OnGameModeInit()
{
    ConnectNPC("CluckinBOT","Cluckin");
    CreatePickup(1318, 1, -1816.5437,618.0901,35.1719, 0);
    CreatePickup(1318, 1, 364.8150,-11.6074,1001.8516, 9);
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_SECONDARY_ATTACK)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, -1816.5437,618.0901,35.1719))
        {
            SetPlayerPos(playerid, 364.8150,-11.6074,1001.8516);
            SetPlayerInterior(playerid, 9);
        }
        else if(IsPlayerInRangeOfPoint(playerid, 3.0, 364.8150,-11.6074,1001.8516))
        {
            SetPlayerPos(playerid, -1816.5437,618.0901,35.1719);
            SetPlayerInterior(playerid, 0);
        }
    }
    if(PRESSED(KEY_HANDBRAKE))
    {
        new wid = GetPlayerWeapon(playerid);
        if(wid > 10)
        {
            new NPCID = GetPlayerIDFromName("CluckinBOT");
            if(IsPlayerFacingPlayer(playerid,NPCID,10) == 1)
            {
                ApplyAnimation(NPCID,"ped","handsup",3.0,0,0,0,1,0);
                SendClientMessage(playerid, -1, ""COLOR_YELLOW"[WANTED LEVEL] {FFFFFF}Your wanted level is increased by four. (Robbing Cluckin Bell)");
                SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid)+4);
                SetTimerEx("RobCluckin", 25000, false, "i", playerid);
                SetTimerEx("After1", 50000, false, "i", playerid);
            }
        }
    }
    return 1;
}
How can i get the timer showing like this in a gamemodetext?
"Robbery Time: timer
Please wait until the robbery is done."
Reply
#4

Use actors for such purposes instead of NPCs, and there are some includes that provide you with callbacks such as "OnPlayerAimActor(playerid, actorid)".
Reply
#5

Quote:
Originally Posted by iLearner
View Post
Use actors for such purposes instead of NPCs, and there are some includes that provide you with callbacks such as "OnPlayerAimActor(playerid, actorid)".
And, which include is that?
Reply
#6

Quote:
Originally Posted by ChandraLouis
View Post
And, which include is that?
Extended Actor Functions by Emmet.

https://sampforum.blast.hk/showthread.php?tid=573504
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)