SmartNPC

Započeo Galardo, Avgust 01, 2021, 14:43:49 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 2 gostiju pregledaju ovu temu.




Da li si testirao da se SmartNPC udari u vozilo od pravog igraca?

Citat: bandodior poslato Avgust 02, 2021, 19:22:20 POSLE PODNE
Da li si testirao da se SmartNPC udari u vozilo od pravog igraca?
Radi na svima, samo ako ima neki lik msm da se zove Srdjan, njega pregazi vise put  :(



Citat: Galardo poslato Avgust 02, 2021, 19:25:24 POSLE PODNE
Radi na svima, samo ako ima neki lik msm da se zove Srdjan, njega pregazi vise put  :(
I Inel sa njim.


brutala

[Filterscript] Simple Treasure Hunt
[Filterscript] Sistem pecanja
[Filterscript] Meditacija
[Filterscript] Molitva
[Include] Alarm
[Include] Posao Taxi


Prastaj bratski ali to je primer u filterscriptama jos od kad su uvedeni NPC-evi (to jest od prve 0.3 verzije)...

Ime fajla, taxi_ls_test u npcmodes (default samp paket).
[pawn]
//
// A test driver NPC with very basic AI
// Kye 2009
//

#include <a_npc>

new gStoppedForTraffic = 0;
new gPlaybackActive = 0;

public ScanTimer();

#define AHEAD_OF_CAR_DISTANCE    11.0
#define SCAN_RADIUS            11.0

//------------------------------------------

main(){}

//------------------------------------------

stock GetXYInfrontOfMe(Float:distance, &Float:x, &Float:y)
{
    new Float:z, Float:angle;
    GetMyPos(x,y,z);
    GetMyFacingAngle(angle);
    x += (distance * floatsin(-angle, degrees));
    y += (distance * floatcos(-angle, degrees));
}

//------------------------------------------

public OnNPCModeInit()
{
   SetTimer("ScanTimer",200,1);
}

//------------------------------------------

LookForAReasonToPause()
{
     new Float:X,Float:Y,Float:Z;
   new x=0;
   
   GetMyPos(X,Y,Z);
   GetXYInfrontOfMe(AHEAD_OF_CAR_DISTANCE,X,Y);
   
   while(x!=MAX_PLAYERS) {
       if(IsPlayerConnected(x) && IsPlayerStreamedIn(x)) {
         if( GetPlayerState(x) == PLAYER_STATE_DRIVER ||
             GetPlayerState(x) == PLAYER_STATE_ONFOOT )
         {
            if(IsPlayerInRangeOfPoint(x,SCAN_RADIUS,X,Y,Z)) {
               return 1;
            }
         }
      }
      x++;
   }
   
   //new msg[256];
   //new Float:angle;
   //GetMyFacingAngle(angle);
   //format(msg,256,"My yaw/heading = %f",angle);
   //SendChat(msg);
   
   return 0;
}


//------------------------------------------

public ScanTimer()
{
   //new ticker = GetTickCount() - g_LastTick;
    //printf("npctest: timer (%d)ms", ticker);
    //g_LastTick = GetTickCount();
   
    new ReasonToPause = LookForAReasonToPause();
   
   if(ReasonToPause && !gStoppedForTraffic)
   {
       //SendChat("I'm pausing");
      PauseRecordingPlayback();
      gStoppedForTraffic = 1;
   }
   else if(!ReasonToPause && gStoppedForTraffic)
   {
       //SendChat("I'm resuming");
       ResumeRecordingPlayback();
       gStoppedForTraffic = 0;
   }
}


//------------------------------------------

StartPlayback()
{
   StartRecordingPlayback(PLAYER_RECORDING_TYPE_DRIVER,"taxi_test_1282");
   gStoppedForTraffic = 0;
   gPlaybackActive = 1;
}
   

//------------------------------------------

public OnRecordingPlaybackEnd()
{
    StartPlayback();
}

//------------------------------------------

public OnNPCEnterVehicle(vehicleid, seatid)
{
    StartPlayback();
}

//------------------------------------------

public OnNPCExitVehicle()
{
    StopRecordingPlayback();
}

//------------------------------------------

[/pawn]

graphic designer / music producer
          
instagram:
          
last release on streaming platforms:


Citat: Deleted User poslato Avgust 07, 2021, 11:34:00 PRE PODNE
Prastaj bratski ali to je primer u filterscriptama jos od kad su uvedeni NPC-evi (to jest od prve 0.3 verzije)...

Ime fajla, taxi_ls_test u npcmodes (default samp paket).
[pawn]
//
// A test driver NPC with very basic AI
// Kye 2009
//

#include <a_npc>

new gStoppedForTraffic = 0;
new gPlaybackActive = 0;

public ScanTimer();

#define AHEAD_OF_CAR_DISTANCE    11.0
#define SCAN_RADIUS            11.0

//------------------------------------------

main(){}

//------------------------------------------

stock GetXYInfrontOfMe(Float:distance, &Float:x, &Float:y)
{
    new Float:z, Float:angle;
    GetMyPos(x,y,z);
    GetMyFacingAngle(angle);
    x += (distance * floatsin(-angle, degrees));
    y += (distance * floatcos(-angle, degrees));
}

//------------------------------------------

public OnNPCModeInit()
{
   SetTimer("ScanTimer",200,1);
}

//------------------------------------------

LookForAReasonToPause()
{
     new Float:X,Float:Y,Float:Z;
   new x=0;
   
   GetMyPos(X,Y,Z);
   GetXYInfrontOfMe(AHEAD_OF_CAR_DISTANCE,X,Y);
   
   while(x!=MAX_PLAYERS) {
       if(IsPlayerConnected(x) && IsPlayerStreamedIn(x)) {
         if( GetPlayerState(x) == PLAYER_STATE_DRIVER ||
             GetPlayerState(x) == PLAYER_STATE_ONFOOT )
         {
            if(IsPlayerInRangeOfPoint(x,SCAN_RADIUS,X,Y,Z)) {
               return 1;
            }
         }
      }
      x++;
   }
   
   //new msg[256];
   //new Float:angle;
   //GetMyFacingAngle(angle);
   //format(msg,256,"My yaw/heading = %f",angle);
   //SendChat(msg);
   
   return 0;
}


//------------------------------------------

public ScanTimer()
{
   //new ticker = GetTickCount() - g_LastTick;
    //printf("npctest: timer (%d)ms", ticker);
    //g_LastTick = GetTickCount();
   
    new ReasonToPause = LookForAReasonToPause();
   
   if(ReasonToPause && !gStoppedForTraffic)
   {
       //SendChat("I'm pausing");
      PauseRecordingPlayback();
      gStoppedForTraffic = 1;
   }
   else if(!ReasonToPause && gStoppedForTraffic)
   {
       //SendChat("I'm resuming");
       ResumeRecordingPlayback();
       gStoppedForTraffic = 0;
   }
}


//------------------------------------------

StartPlayback()
{
   StartRecordingPlayback(PLAYER_RECORDING_TYPE_DRIVER,"taxi_test_1282");
   gStoppedForTraffic = 0;
   gPlaybackActive = 1;
}
   

//------------------------------------------

public OnRecordingPlaybackEnd()
{
    StartPlayback();
}

//------------------------------------------

public OnNPCEnterVehicle(vehicleid, seatid)
{
    StartPlayback();
}

//------------------------------------------

public OnNPCExitVehicle()
{
    StopRecordingPlayback();
}

//------------------------------------------

[/pawn]
Svakako nisam se vodio tim fajlom, nisam znao ni da postoji.

Citat: // fejza poslato Avgust 07, 2021, 12:28:58 POSLE PODNE
UUUUUUUUU Jebeno, svaka cast 10/10
Zahvaljujem.

Da li je to Galardo otac ili???