17.02.2013, 13:35
Heey all,
I use the taxi vehicle streamer but i have a problem with trailers.
When i attach a trailer to my truck and i driver away from the spawn the trailer gets respawned.
Code:
How can i fix this?
Admigo
I use the taxi vehicle streamer but i have a problem with trailers.
When i attach a trailer to my truck and i driver away from the spawn the trailer gets respawned.
Code:
pawn Код:
/*
This code was designed to allow users to have a larger number of vehicle spawns in their script than
sa-mp will normally allow. The script will allow you to have in theory up to 9999 vehicle
spawns in your gamemode but only 700 of these can be active at any one point simultaneously...basically the script
will only create vehicles if there is somebody around to see them.
The default distance it will spawn a car for u is set at 100 meters but you can change that very simply by changing
SPAWN_DISTANCE
In order to add streaming vehicle spawns u must add your vehicle spawns into this fs under OnFilterscriptInit using:
AddStreamingVehicle(modelid,x,y,z,angle,color1,color2);
rather than addstaticvehicle.
This script and all code contained within was designed by <tAxI> and is released to the public as freeware.
Any attempts to claim this code as your own will not be taken lightly so don't even try it :-P
HOPE U ALL LIKE IT...ENJOY!!!!
<tAxI>
*/
#include <a_samp>
#define SPAWN_DISTANCE 150
#define MAX_ACTIVE_VEHICLES 675
#define MODEL_LIMIT 212
#define MAX_ACTIVE_MODELS 65
forward proxcheck();
new modelcount[MODEL_LIMIT];
new vehcount = 0;
new streamcount = 0;
new vehused[MAX_ACTIVE_VEHICLES];
enum vInfo2
{
model,
Float:x_spawn,
Float:y_spawn,
Float:z_spawn,
Float:za_spawn,
color_1,
color_2,
spawned,
idnum,
};
new VehicleInfo2[9999][vInfo2];
public OnFilterScriptInit()
{
//cars
AddStreamingVehicle(523,1560.7695,-1694.4358,5.6122,32.7235,-1,-1);//cop bike
AddStreamingVehicle(523,1563.5020,-1694.8240,5.4627,21.6809,-1,-1);//cop bike
AddStreamingVehicle(420,1713.9504,-2323.2983,12.9492,273.7584,-1,-1);//car taxi
AddStreamingVehicle(565,2489.3066,-2605.5688,13.3711,0.4802,-1,-1);
AddStreamingVehicle(596,1570.5022,-1710.5771,5.6091,179.8262,-1,-1);//cop car
// -----------------------------------------------------------------------------
SetTimer("proxcheck",1000,1);
new string[256];
print(" ");
print(" ");
print("tAxI's Dynamic Vehicle Streamer v0.1");
print(" ");
print("-----------------------------------------------------------------");
print(" ");
format(string,sizeof(string),"tAxI's Dynamic Vehicle Streamer has detected %d Vehicle Spawns...",vehcount);
printf(string);
print(" ");
format(string,sizeof(string),"Only %d spawns may be activated at any one time simultaneously...",MAX_ACTIVE_VEHICLES);
printf(string);
print(" ");
print("tAxI's Dynamic Vehicle Streamer is now running...ENJOY!!!");
print(" ");
print("-----------------------------------------------------------------");
print(" ");
print(" ");
print(" ");
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
SetTimerEx("DeactivateStreamedVehicle",6000,0,"x",vehicleid);
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
vehused[vehicleid] = 1;
return 1;
}
public proxcheck()
{
for(new i = 1;i<vehcount;i++) {
if(VehicleInfo2[i][spawned] == 0){
if(IsPlayerClose(i,SPAWN_DISTANCE) == 1){
if(streamcount <= MAX_ACTIVE_VEHICLES) {
if(modelcount[VehicleInfo2[i][model]-400] < MAX_ACTIVE_MODELS) {
VehicleInfo2[i][idnum] = CreateVehicle(VehicleInfo2[i][model], VehicleInfo2[i][x_spawn], VehicleInfo2[i][y_spawn], VehicleInfo2[i][z_spawn], VehicleInfo2[i][za_spawn], VehicleInfo2[i][color_1], VehicleInfo2[i][color_2],11000);
VehicleInfo2[i][spawned] = 1;
modelcount[VehicleInfo2[i][model]-400]++;
streamcount++;
}
}
}
}
else {
if(vehused[VehicleInfo2[i][idnum]] == 0) {
if(IsPlayerClose(i,SPAWN_DISTANCE) == 0) {
DestroyVehicle(VehicleInfo2[i][idnum]);
VehicleInfo2[i][spawned] = 0;
modelcount[VehicleInfo2[i][model]-400]--;
streamcount--;
}
}
}
}
}
stock AddStreamingVehicle(modelid,Float:x,Float:y,Float:z,Float:a,col1,col2)
{
vehcount++;
VehicleInfo2[vehcount][model] = modelid;
VehicleInfo2[vehcount][x_spawn] = x;
VehicleInfo2[vehcount][y_spawn] = y;
VehicleInfo2[vehcount][z_spawn] = z;
VehicleInfo2[vehcount][za_spawn] = a;
VehicleInfo2[vehcount][color_1] = col1;
VehicleInfo2[vehcount][color_2] = col2;
return 1;
}
stock DeactivateStreamedVehicle(vehicleid)
{
vehused[vehicleid] = 0;
return 1;
}
stock IsPlayerClose(streamid, Float:MAX)
{
for(new i = 0;i<MAX_PLAYERS;i++){
if(!IsPlayerConnected(i)) continue;
new Float:PPos[3];
GetPlayerPos(i, PPos[0], PPos[1], PPos[2]);
if (PPos[0] >= floatsub(VehicleInfo2[streamid][x_spawn], MAX) && PPos[0] <= floatadd(VehicleInfo2[streamid][x_spawn], MAX)
&& PPos[1] >= floatsub(VehicleInfo2[streamid][y_spawn], MAX) && PPos[1] <= floatadd(VehicleInfo2[streamid][y_spawn], MAX)
&& PPos[2] >= floatsub(VehicleInfo2[streamid][z_spawn], MAX) && PPos[2] <= floatadd(VehicleInfo2[streamid][z_spawn], MAX))
{
return 1;
}
}
return 0;
}
Admigo