13.09.2009, 09:59
All my combinations with filterscripts works, but only when i add xObjects filterscript than NPCs wont work.
theres a xObjects filterscript:
and there is Taxi filterscript:
Theres a npcscript:
Thank you very much for help, i tryed everything, but result is nothing...
theres a xObjects filterscript:
pawn Код:
#include <a_samp>
forward Timer();
forward SetPlayerPosWithObjects(playerid,Float:x,Float:y,Float:z);
/*
SetPlayerPosWithObjects usage in your gamemode:
CallRemoteFunction("SetPlayerPosWithObjects","ifff",playerid,newx,newy,newz);
*/
//------------------------------------------------------------------------------
enum object_info
{
modelid,
Float:ox,
Float:oy,
Float:oz,
Float:orx,
Float:ory,
Float:orz,
Float:viewdist
}
new Objects[][object_info] = {
{11490, 2154.2290, 1039.0209, 9.7744, 0.0000, 0.0000, 180.0000, 500.0},
{3279, 2138.5488, 1046.9165, 9.7604, 0.0000, 0.0000, 0.0000, 500.0},
{11491, 2154.2241, 1050.0718, 11.2699, 0.0000, 0.0000, 180.0000, 500.0},
};
enum player_info
{
objid[sizeof(Objects)],
bool:view[sizeof(Objects)]
}
new Player[MAX_PLAYERS][player_info];
//------------------------------------------------------------------------------
bool:IsInReach(Float:x,Float:y,Float:z,Float:x2,Float:y2,Float:z2,Float:dist)
{
x = (x > x2) ? x - x2 : x2 - x;
if(x > dist) return false;
y = (y > y2) ? y - y2 : y2 - y;
if(y > dist) return false;
z = (z > z2) ? z - z2 : z2 - z;
if(z > dist) return false;
return true;
}
//------------------------------------------------------------------------------
new timer;
public OnFilterScriptInit()
{
CreateObject(3749, 1452.1573, 3069.4517, 588.9497, 0.0000, 0.0000, 0.0000);
CreateObject(8040, 1452.4481, 3107.3931, 584.0987, 0.0000, 0.0000, 270.0000);
CreateObject(8040, -2774.2954, 3139.4285, 2185.9839, 0.0000, 0.0000, 0.0000);
CreateObject(8040, -2806.3997, 716.9072, 3340.9138, 0.0000, 0.0000, 90.0000);
CreateObject(8040, 601.4331, 684.8004, 4628.4258, 0.0000, 0.0000, 180.0000);
timer = SetTimer("Timer",200,1);
return 1;
}
public OnFilterScriptExit()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
for(new o = 0; o < sizeof(Objects); o++)
{
if(Player[i][view][o])
{
Player[i][view][o] = false;
DestroyPlayerObject(i,Player[i][objid][o]);
}
}
}
KillTimer(timer);
}
//------------------------------------------------------------------------------
public OnPlayerConnect(playerid)
{
for(new i = 0; i < sizeof(Objects); i++) Player[playerid][view][i] = false;
}
public OnPlayerDisconnect(playerid)
{
for(new i = 0; i < sizeof(Objects); i++)
{
if(Player[playerid][view][i])
{
Player[playerid][view][i] = false;
DestroyPlayerObject(playerid,Player[playerid][objid][i]);
}
}
}
//------------------------------------------------------------------------------
public Timer()
{
for(new i = 0; i < MAX_PLAYERS; i++)
if(IsPlayerConnected(i))
PlayerObjectUpdate(i);
}
PlayerObjectUpdate(playerid)
{
new Float:pos[3];
GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
for(new i = 0; i < sizeof(Objects); i++)
{
if(!Player[playerid][view][i])
{
if(IsInReach(pos[0],pos[1],pos[2],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
{
Player[playerid][view][i] = true;
Player[playerid][objid][i] = CreatePlayerObject(playerid,Objects[i][modelid],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][orx],Objects[i][ory],Objects[i][orz]);
}
} else if(!IsInReach(pos[0],pos[1],pos[2],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
{
Player[playerid][view][i] = false;
DestroyPlayerObject(playerid,Player[playerid][objid][i]);
}
}
}
public SetPlayerPosWithObjects(playerid,Float:x,Float:y,Float:z)
{
for(new i = 0; i < sizeof(Objects); i++)
{
if(!Player[playerid][view][i])
{
if(IsInReach(x,y,z,Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
{
Player[playerid][view][i] = true;
Player[playerid][objid][i] = CreatePlayerObject(playerid,Objects[i][modelid],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][orx],Objects[i][ory],Objects[i][orz]);
}
} else if(!IsInReach(x,y,z,Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
{
Player[playerid][view][i] = false;
DestroyPlayerObject(playerid,Player[playerid][objid][i]);
}
}
SetPlayerPos(playerid,Float:x,Float:y,Float:z);
}
public OnPlayerSpawn(playerid)
PlayerObjectUpdate(playerid);
pawn Код:
/*(---------------------------------)
( __ ___ ___ _ _ )
( \ \ / / |__ ___ / __/ | |_ _ _ )
( \ V /| / _/ -_) (__| | _| || | )
( \_/ |_\__\___|\___|_|\__|\_, | )
( |__/ )
( FS Made By V1ceC1ty )
( )
( Credits To: )
( All The SA-MP Team )
( wiki.sa-mp.com )
( Some of kc's NPC Tutorial )
(---------------------------------)*/
#include <a_samp>
new TaxiCar;
public OnGameModeInit()
{
ConnectNPC("Driver","Taxi");
TaxiCar = AddStaticVehicle(420,2044.8854,1473.2106,10.4494,181.3339,6,1); // Taxi
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid)) //Checks if the player is an NPC.
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname)); //Gets the NPC's name
if(!strcmp(npcname, "Driver", true)) //Checks if the NPC's name is Driver
{
PutPlayerInVehicle(playerid, TaxiCar, 0); //Puts the NPC into the Taxi.
SetSpawnInfo( playerid, 0, 255, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0 );
}
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
pawn Код:
#define RECORDING "Taxi" // Name of the .rec file (Without the Extension)
#define RECORDING_TYPE 1 //1 for in vehicle and 2 for on foot.
#include <a_npc>
main(){}
public OnRecordingPlaybackEnd() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
public OnNPCEnterVehicle(vehicleid, seatid) StartRecordingPlayback(RECORDING_TYPE, RECORDING);
public OnNPCExitVehicle() StopRecordingPlayback();