NPC Skin+Stop Problem -
akrogames - 25.12.2013
Hi,
I would like that my NPC may have id skin 253 for bus System but doesn't work with my source code below because my NPC have a CJ default skin. I would also my NPC and bus vehicle must stop when player approching.
Do you have link or can you offer your help ?
Thanks and merry christmas.
Код:
#define FILTERSCRIPT
#include <a_samp>
new bus1, bus2;
new idnpc[2];
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" NPC BUS FILTERSCRIPT");
print("--------------------------------------\n");
// NPCS
ConnectNPC("chauffeura","busa");
ConnectNPC("chauffeurb","busb");
bus1 = CreateVehicle(431,-2002.5649,166.4715,27.6280,0.2747,6,1,5000);
bus2 = CreateVehicle(431,-2002.4308,123.6647,27.6393,359.6707,6,1,5000);
SetTimer("BusCollision",1000,1);
return 1;
}
forward BusCollision();
public BusCollision() {
new Float:x, Float:y, Float:z;
//printf("TIMER BUS COLLISION");
for(new i=0;i<2;i++) {
GetPlayerPos(idnpc[i], x, y, z);
//printf("BOT %d : POSITION %d %d %d",idnpc[i], x, y, z);
if(IsPlayerInRangeOfPoint(idnpc[i], 7.0, x, y, z)) {
new Float:X, Float:Y, Float:Z, VehicleID;
//printf("ATTENTION COLLISION !!!");
VehicleID = GetPlayerVehicleID(idnpc[i]);
GetVehicleVelocity(VehicleID, X, Y, Z);
SetVehicleVelocity(VehicleID, -X, -Y, -Z);
} else {
new Float:X, Float:Y, Float:Z, VehicleID;
VehicleID = GetPlayerVehicleID(idnpc[i]);
GetVehicleVelocity(VehicleID, X, Y, Z);
SetVehicleVelocity(VehicleID, 20, 20, 20);
}
}
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
if(IsPlayerNPC(playerid))
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname));
SetPlayerSkin(playerid, 253);
if(!strcmp(npcname, "chauffeura", true))
{
PutPlayerInVehicle(playerid, bus1, 0);
idnpc[0] = playerid;
}
else if(!strcmp(npcname, "chauffeurb", true))
{
PutPlayerInVehicle(playerid, bus2, 0);
idnpc[1] = playerid;
}
SpawnPlayer(playerid);
return 1;
}
return 1;
}
Re : NPC Skin+Stop Problem -
akrogames - 27.12.2013
Hi all,
Nobody can help me ?
Thanks friends
Re: NPC Skin+Stop Problem -
Smileys - 27.12.2013
check if a player is infront of the bot, if it is, use:
https://sampwiki.blast.hk/wiki/NPC:PauseRecordingPlayback
as for the skin,
SetSkin( playerid, 253 );
pawn Код:
public OnPlayerSpawn( playerid )
{
if( IsPlayerNPC( playerid ) )
{
if( !strcmp( name, /*yourbotname here */, true ) )
{
SetSkin( playerid, 253 );
}
}
// rest of stuff here
return 1;
}
^^ untested, but should work.
Re : NPC Skin+Stop Problem -
akrogames - 27.12.2013
Thanks for your response.
This method that you present, i use this method too with SetPlayerSkin on my Skin NPC. But doesn't work and i dont understand.
In my GM :
Код:
public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid)) {
SetPlayerSkin(playerid, 253);
return 1;
}
}
In my filterscript :
Код:
#define FILTERSCRIPT
#include <a_samp>
new bus1, bus2;
new idnpc[2];
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" NPC BUS FILTERSCRIPT");
print("--------------------------------------\n");
// NPCS
ConnectNPC("chauffeura","busa");
ConnectNPC("chauffeurb","busb");
bus1 = CreateVehicle(431,-2002.5649,166.4715,27.6280,0.2747,6,1,5000);
bus2 = CreateVehicle(431,-2002.4308,123.6647,27.6393,359.6707,6,1,5000);
SetTimer("BusCollision",1000,1);
return 1;
}
forward BusCollision();
public BusCollision() {
new Float:x, Float:y, Float:z;
//printf("TIMER BUS COLLISION");
for(new i=0;i<2;i++) {
GetPlayerPos(idnpc[i], x, y, z);
//printf("BOT %d : POSITION %d %d %d",idnpc[i], x, y, z);
if(IsPlayerInRangeOfPoint(idnpc[i], 7.0, x, y, z)) {
new Float:X, Float:Y, Float:Z, VehicleID;
//printf("ATTENTION COLLISION !!!");
VehicleID = GetPlayerVehicleID(idnpc[i]);
GetVehicleVelocity(VehicleID, X, Y, Z);
SetVehicleVelocity(VehicleID, -X, -Y, -Z);
} else {
new Float:X, Float:Y, Float:Z, VehicleID;
VehicleID = GetPlayerVehicleID(idnpc[i]);
GetVehicleVelocity(VehicleID, X, Y, Z);
SetVehicleVelocity(VehicleID, 20, 20, 20);
}
}
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
if(IsPlayerNPC(playerid))
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname));
SetPlayerSkin(playerid, 253);
if(!strcmp(npcname, "chauffeura", true))
{
PutPlayerInVehicle(playerid, bus1, 0);
idnpc[0] = playerid;
}
else if(!strcmp(npcname, "chauffeurb", true))
{
PutPlayerInVehicle(playerid, bus2, 0);
idnpc[1] = playerid;
}
SpawnPlayer(playerid);
return 1;
}
return 1;
}
But it's always CJ default skin... It's very strange. During the record my skin is 253 and not CJ skin.
Re : NPC Skin+Stop Problem -
akrogames - 27.12.2013
My script for NPC Collision that's work :
Код:
#define RECORDING "busa"
#define RECORDING_TYPE 1
#include <a_npc>
forward BusECU();
new pause=0;
main(){
SetTimer("BusECU",1000,true);
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:x, Float:y, Float:z;
GetMyPos(x,y,z);
for (new a = 0; a <= MAX_PLAYERS; a++)
{
if (IsPlayerConnected(a)) {
if (IsPlayerInRangeOfPoint(a,12.00,x,y,z)) {
trigger = 1;
}
}
}
if (trigger == 1) {
PauseRecordingPlayback();
pause = 1;
} else if(trigger == 0 && pause == 1) {
ResumeRecordingPlayback();
pause=0;
}
return 1;
}
But it's always default CJ's skin. Very strange.