[Include] Controllable NPC
#41

The old plugin which was CNPC was deleted due to license violating. You can try the new one HERE
Reply
#42

Thank You.
Reply
#43

Nice one.
Reply
#44

One of the best includes ever
Reply
#45

EDIT: I found a bug in your code:

pawn Code:
stock Npc: GetClosestNPC(playerid) // This function contributes to the above, as said, to chase a player :D
{
        new
        Float: fDistance,
        Float: fHighest,
        Npc: iPlayer = INVALID_CNPC
    ;
    foreachcnpc(npcid)
    {
        fDistance = GetDistanceBetweenPlayerAndNPC(playerid, npcid);
        if(fDistance > fHighest) fHighest = fDistance, iPlayer = Npc: npcid;
    }
    return iPlayer;
}
It was getting the highest distance, not the lowest lol, I lost a lot of time with my GM, I was trying to understand what made my bot not to work good. However that code will work if someone has only 1 CNPC.

The good code is:

pawn Code:
new Float: fDistance,
        Float: fLowest = 10000.0,
        Npc: iPlayer = INVALID_CNPC
    ;
    foreachcnpc(npcid)
    {
        fDistance = GetDistanceBetweenPlayerAndNPC(playerid, npcid);
        if(fDistance < fLowest) fLowest = fDistance, iPlayer = Npc: npcid;
    }
    return iPlayer;
And will work also with 10 npcs
Reply
#46

This think is INCREDIBLE!The SA:MP team should replace the "a_npc" include with this one!!!I will test soon...Thanks!
Reply
#47

Hello.
The Npc is created and everything, but when I order it to my position
(SetNPCPos) it is as if it was invisible.

Regards.
Reply
#48

an easy way to create NPC's nice job man
Reply
#49

Nice Job!
Reply
#50

The code is shocking, very sloppy, let alone no damage or death detection, and did you even think about NPC's attacking other players? lol...other than that good try.
Reply
#51

Thanks alot! I'll use this.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)