NPC Bus Driver Anti-Squish - help needed :)
#1

Hi - not sure whether this is the right place to spam this but here goes:

Basically I've added this to a previously working bus:

Quote:

#define RECORDING "Route1376" //This is the filename of your recording without the extension.
#define RECORDING_TYPE 1 //1 for in vehicle and 2 for on foot.

#include <a_npc>

forward BusECU();

main()
{
SetTimer("BusECU",1000,1);
return 1;
}

public OnRecordingPlaybackEnd() StartRecordingPlayback(RECORDING_TYPE, RECORDING);

#if RECORDING_TYPE == 1
public OnNPCEnterVehicle(vehicleid, seatid) StartRecordingPlayback(RECORDING_TYPE, RECORDING);
public OnNPCExitVehicle() StopRecordingPlayback();
#else
public OnNPCSpawn() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
#endif

public BusECU()
{
new trigger = 0;
new Float, Float:y, Float:z;
GetMyPos(x,y,z);
for (new a = 0; a <= 63; a++)
{
if (IsPlayerConnected(a))
{
new name[64];
GetPlayerName(a,name,64);
if (strcmp(name,"NPC",false,3))
{
SendChat("Player is not an NPC");
if (GetPlayerVehicleID(a) != 1376)
{
if (IsPlayerInRangeOfPoint(a,50.00000,x,y,z))
{
trigger = 1;
SendChat("Player is in the way");
}
}
}
}
}

if (trigger == 1)
{
PauseRecordingPlayback();
SendChat("Bus Paused");
}
else
{
ResumeRecordingPlayback();
SendChat("Bus Running");
}

return 1;
}

Since I've added the detection for real players the bus lags/warps everywhere and I can't see why, I know the script is crude but it is just a theory tester. Doesn't appear to use any excessive CPU.. any ideas? Has anyone ever made this work?

Cheers,

ozzie
Reply
#2

OK - did a second test, disabled the above and added the below - the bus now runs perfectly smoothly and pause and resume work without warp - so I'll make an efficient for statement in the main script or a filterscript and send the pause/resume securely to the NPC

If anyone does fix it the other way it'd be good to know

Quote:

public OnPlayerText(playerid, text[])
{
if (!strcmp(text,"pause"))
{
PauseRecordingPlayback();
SendChat("Bus Paused");
return 1;
}
else if (!strcmp(text,"resume"))
{
ResumeRecordingPlayback();
SendChat("Bus Resumed");
return 1;
}
return 0;
}

Reply
#3

Just want to point out, I assume 64 players is the ammount of players in your server, A better way (and easier) way to do that is this..

#undef MAX_PLAYERS
#define MAX_PLAYERS 64

That way if you upgrade/downgrade it can be easily changed, As for your question I'm still trying to understand it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)