SA-MP Forums Archive
NPC position - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: NPC position (/showthread.php?tid=277351)



NPC position - marrcko - 17.08.2011

hi, i would like to know what is the best way to check npc position (like PlayerToPoint()).It should be onPlayerUpdate or maybe timer?Something else?


Re: NPC position - Jeffry - 17.08.2011

You could try a checkpoint set for the NPC only. (Didn't test this, just an idea).

If this doesn't work, a timer would be the best. OnPlayerUpdate is called too often.


Re: NPC position - marrcko - 17.08.2011

Yes, i tried it, but it was alot cp with progress, but when i read your post i had an idea...thx


Re: NPC position - Jeffry - 17.08.2011

Quote:
Originally Posted by marrcko
Посмотреть сообщение
Yes, i tried it, but it was alot cp with progress, but when i read your post i had an idea...thx
Alright. Good luck.


Re: NPC position - marrcko - 17.08.2011

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    DisablePlayerCheckpoint(playerid);
    if(IsPlayerNPC(playerid))
        {
        SendClientMessageToAll(MELSVA,"NPC ENTERED CP");
        if(IsPlayerInMission[playerid]==6)
            {
            IsNPCWinner=true;
            for(new p=0; p<MAX_PLAYERS; p++)
                {
                new names[26];
                GetPlayerName(p,names,sizeof(names));
                if(!strcmp(names,"NPC_Racer"))
                    {
                    SendClientMessageToAll(MELSVA,"NPC WINS RACES");
                    IsNPCInRace=false;
                    IsPlayerInMission[p]=0;
                    Kick(p);
                    ConnectNPC("NPC_Racer","steady");
                    }
                }
            }
        return 1;
        }
return 1;
}
Whats wrong, 'cause i don't get messages?
Oh, maybe this helps
pawn Код:
stock RaceStart(playerid)
    {
    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~g~-~y~ 3 ~g~-",1000,3);
    TogglePlayerControllable(playerid,false);
    VehiclePlayerPos(playerid,-2274.1875,-120.1094,35.1253,272.8494);
    if(IsPlayerInRace[playerid]== 1)
        {
        for(new p=0; p<MAX_PLAYERS; p++)
            {
            new names[26];
            GetPlayerName(p,names,sizeof(names));
            if(!strcmp(names,"NPC_Racer"))
                {
                Kick(p);
                }
            }
        ConnectNPC("NPC_Racer","race1");
        for(new p=0; p<MAX_PLAYERS; p++)
            {
            new names[26];
            GetPlayerName(p,names,sizeof(names));
            if(!strcmp(names,"NPC_Racer"))
                {
                IsPlayerInMission[p]=6;
                SetPlayerCheckpoint(p,-1735.4344,-580.2195,16.0630,15);
                }
            }
        }
        }