pawn Код:
//========================================================//
//=============[MidoStream - Object Streamer]=============//
//=====================[by MidoBan]=======================//
//========================================================//
#include <a_samp>
#define MAX_STREAM_OBJECTS 5000
enum object_enum
{
modelid,
Float:xpos,
Float:ypos,
Float:zpos,
Float:xrot,
Float:yrot,
Float:zrot,
Float:viewdist,
attached,
Float:xoff,
Float:yoff,
Float:zoff,
bool:moving,
Float:movx,
Float:movy,
Float:movz,
Float:speed,
movetimer,
id
}
enum player_enum
{
pobjects[MAX_STREAM_OBJECTS],
bool:seen[MAX_STREAM_OBJECTS],
seeing
}
new Objects[MAX_STREAM_OBJECTS][object_enum];
new PlayerObjects[MAX_PLAYERS][player_enum];
new created;
PointToPoint(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, Float:dist)
{
x1 -= x2;
y1 -= y2;
z1 -= z2;
return ((x1 * x1) + (y1 * y1) + (z1 * z1) <= dist * dist);
}
Float:GetDistance(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2)
{
return Float:floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
forward Core_CreateStreamObject(modelid2,Float:xpos2,Float:ypos2,Float:zpos2,Float:xrot2,Float:yrot2,Float:zrot2,Float:viewdist2);
public Core_CreateStreamObject(modelid2,Float:xpos2,Float:ypos2,Float:zpos2,Float:xrot2,Float:yrot2,Float:zrot2,Float:viewdist2)
{
new i;
for (i=0; i<MAX_STREAM_OBJECTS; i++)
{
if (Objects[i][modelid] == 0)
{
Objects[i][modelid] = modelid2;
Objects[i][xpos] = xpos2;
Objects[i][ypos] = ypos2;
Objects[i][zpos] = zpos2;
Objects[i][xrot] = xrot2;
Objects[i][yrot] = yrot2;
Objects[i][zrot] = zrot2;
Objects[i][viewdist] = viewdist2;
Objects[i][attached] = -1;
Objects[i][moving] = false;
Objects[i][id] = i;
if (created < i)
{
created = i;
}
break;
}
}
return i;
}
forward Core_DestroyStreamObject(id2);
public Core_DestroyStreamObject(id2)
{
Objects[id2][modelid] = 0;
KillTimer(Objects[id2][movetimer]);
for (new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if (PlayerObjects[i][seen][id2] == true)
{
DestroyPlayerObject(i,PlayerObjects[i][pobjects][id2]);
PlayerObjects[i][seen][id2] = false;
PlayerObjects[i][seeing] -= 1;
}
}
}
}
forward Float:Core_GetXPos(id2);
public Float:Core_GetXPos(id2)
{
return Objects[id2][xpos];
}
forward Float:Core_GetYPos(id2);
public Float:Core_GetYPos(id2)
{
return Objects[id2][ypos];
}
forward Float:Core_GetZPos(id2);
public Float:Core_GetZPos(id2)
{
return Objects[id2][zpos];
}
forward Float:Core_GetXRot(id2);
public Float:Core_GetXRot(id2)
{
return Objects[id2][xrot];
}
forward Float:Core_GetYRot(id2);
public Float:Core_GetYRot(id2)
{
return Objects[id2][yrot];
}
forward Float:Core_GetZRot(id2);
public Float:Core_GetZRot(id2)
{
return Objects[id2][zrot];
}
forward Core_SetStreamObjectPos(id2,Float:xpos2,Float:ypos2,Float:zpos2);
public Core_SetStreamObjectPos(id2,Float:xpos2,Float:ypos2,Float:zpos2)
{
Objects[id2][xpos] = xpos2;
Objects[id2][ypos] = ypos2;
Objects[id2][zpos] = zpos2;
for (new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if (PlayerObjects[i][seen][id2] == true)
{
SetPlayerObjectPos(i,PlayerObjects[i][pobjects][id2],xpos2,ypos2,zpos2);
}
}
}
}
forward Core_SetStreamObjectRot(id2,Float:xrot2,Float:yrot2,Float:zrot2);
public Core_SetStreamObjectRot(id2,Float:xrot2,Float:yrot2,Float:zrot2)
{
Objects[id2][xrot] = xrot2;
Objects[id2][yrot] = yrot2;
Objects[id2][zrot] = zrot2;
for (new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if (PlayerObjects[i][seen][id2] == true)
{
SetPlayerObjectRot(i,PlayerObjects[i][pobjects][id2],xrot2,yrot2,zrot2);
}
}
}
}
forward Core_AttachStreamObjectToPlayer(id2,playerid,Float:xoff2,Float:yoff2,Float:zoff2,Float:xrot2,Float:yrot2,Float:zrot2);
public Core_AttachStreamObjectToPlayer(id2,playerid,Float:xoff2,Float:yoff2,Float:zoff2,Float:xrot2,Float:yrot2,Float:zrot2)
{
Objects[id2][attached] = playerid;
Objects[id2][xoff] = xoff2;
Objects[id2][yoff] = yoff2;
Objects[id2][zoff] = zoff2;
Objects[id2][xrot] = xrot2;
Objects[id2][yrot] = yrot2;
Objects[id2][zrot] = zrot2;
for (new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if (PlayerObjects[i][seen][id2] == true)
{
AttachPlayerObjectToPlayer(i,PlayerObjects[i][pobjects][id2],playerid,xoff2,yoff2,zoff2,xrot2,yrot2,zrot2);
}
}
}
}
forward Core_MoveStreamObject(id2,Float:movx2,Float:movy2,Float:movz2,Float:speed2);
public Core_MoveStreamObject(id2,Float:movx2,Float:movy2,Float:movz2,Float:speed2)
{
Objects[id2][moving] = true;
Objects[id2][movx] = movx2;
Objects[id2][movy] = movy2;
Objects[id2][movz] = movz2;
Objects[id2][speed] = speed2;
for (new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if (PlayerObjects[i][seen][id2] == true)
{
MovePlayerObject(i,PlayerObjects[i][pobjects][id2],movx2,movy2,movz2,speed2);
}
}
}
new Float:time = (GetDistance(Objects[id2][xpos],Objects[id2][ypos],Objects[id2][zpos],movx2,movy2,movz2)/speed2)/1.17;
new bool:xisbigger = (movx2 >= Objects[id2][xpos]) ? true : false;
new bool:yisbigger = (movy2 >= Objects[id2][ypos]) ? true : false;
new bool:zisbigger = (movz2 >= Objects[id2][zpos]) ? true : false;
new xadd = (time == 0.0) ? 0 : (xisbigger) ? floatround(((movx2 - Objects[id2][xpos])/time),floatround_ceil) : floatround(((movx2 - Objects[id2][xpos])/time),floatround_floor);
new yadd = (time == 0.0) ? 0 : (yisbigger) ? floatround(((movy2 - Objects[id2][ypos])/time),floatround_ceil) : floatround(((movy2 - Objects[id2][ypos])/time),floatround_floor);
new zadd = (time == 0.0) ? 0 : (zisbigger) ? floatround(((movz2 - Objects[id2][zpos])/time),floatround_ceil) : floatround(((movz2 - Objects[id2][zpos])/time),floatround_floor);
KillTimer(Objects[id2][movetimer]);
Objects[id2][movetimer] = SetTimerEx("MoveTimer",1000,1,"iiiibbb",id2,xadd,yadd,zadd,xisbigger,yisbigger,zisbigger);
}
forward Core_MidoStreamDisconnect(playerid);
public Core_MidoStreamDisconnect(playerid)
{
for (new i=0; i<=created; i++)
{
if (PlayerObjects[playerid][seen][i] == true)
{
DestroyPlayerObject(playerid,PlayerObjects[playerid][pobjects][i]);
PlayerObjects[playerid][seen][i] = false;
}
}
PlayerObjects[playerid][seeing] = 0;
}
public OnFilterScriptInit()
{
CreateStreamObject(4654, -1118.1845703125, 459.7919921875, 1340.7841796875, 0, 0, 89.681396484375, 500);
CreateStreamObject(4870, -992.220703125, 459.0576171875, 1340.0328369141, 0, 356.02844238281, 0, 500);
CreateStreamObject(5013, -1217.9909667969, 459.62261962891, 1338.3841552734, 350.07501220703, 0, 89.730010986328, 500);
CreateStreamObject(5013, -1250.2061767578, 459.76138305664, 1336.0233154297, 359.99877929688, 0, 89.725341796875, 500);
CreateStreamObject(5442, -1269.5888671875, 424.75, 1335.9963378906, 0, 0, 89.725341796875, 500);
CreateStreamObject(5442, -1269.8837890625, 364.908203125, 1335.9963378906, 0, 0, 89.725341796875, 500);
CreateStreamObject(5442, -1234.8433837891, 383.17407226563, 1336.0213623047, 0, 0, 179.41015625, 500);
CreateStreamObject(5442, -1176.232421875, 382.5615234375, 1335.9963378906, 0, 0, 179.40673828125, 500);
CreateStreamObject(5442, -1118.7567138672, 381.91195678711, 1335.8712158203, 0, 0, 179.40673828125, 500);
CreateStreamObject(5442, -1113.2822265625, 346.908203125, 1335.8952636719, 0, 0, 89.675903320313, 500);
CreateStreamObject(5442, -1077.9683837891, 339.52090454102, 1335.9202880859, 0, 0, 179.40588378906, 500);
CreateStreamObject(5442, -1018.6581420898, 338.89889526367, 1335.8702392578, 0, 0, 179.40124511719, 500);
CreateStreamObject(5442, -990.64147949219, 338.6247253418, 1335.8452148438, 0, 0, 179.40124511719, 500);
CreateStreamObject(5442, -971.10437011719, 373.48931884766, 1336.689453125, 0, 1.9849853515625, 269.13110351563, 500);
CreateStreamObject(5442, -970.38018798828, 420.20706176758, 1339.3388671875, 0, 3.968017578125, 269.12658691406, 500);
CreateStreamObject(6285, -1044.3804931641, 317.75894165039, 1341.4542236328, 0, 0, 180.54052734375, 500);
CreateStreamObject(6522, -1090.9364013672, 304.84817504883, 1344.3128662109, 0, 0, 0, 500);
CreateStreamObject(5442, -1113.5439453125, 287.125, 1335.8702392578, 0, 0, 89.67041015625, 500);
CreateStreamObject(5442, -1093.4437255859, 301.90014648438, 1335.8702392578, 0, 0, 89.675903320313, 500);
CreateStreamObject(5442, -1073.7254638672, 301.75827026367, 1335.8702392578, 0, 0, 89.675903320313, 500);
CreateStreamObject(9576, -944.18664550781, 274.19415283203, 1340.4348144531, 0.75, 0, 282.22521972656, 500);
CreateStreamObject(17880, -969.58721923828, 319.73260498047, 1336.1453857422, 0, 3.9700012207031, 0, 500);
CreateStreamObject(17880, -975.68090820313, 312.05963134766, 1336.2204589844, 1.280029296875, 359.99609375, 167.59509277344, 500);
CreateStreamObject(17880, -972.97528076172, 291.76870727539, 1336.1453857422, 1.2799072265625, 359.99450683594, 267.29077148438, 500);
CreateStreamObject(4279, -967.99908447266, 371.31719970703, 1333.2191162109, 356.02844238281, 0, 89.725341796875, 500);
CreateStreamObject(5442, -951.3681640625, 358.00015258789, 1335.6936035156, 178.92004394531, 0, 269.61596679688, 500);
CreateStreamObject(5274, -921.50756835938, 573.67779541016, 1337.3383789063, 0, 0, 359.5, 500);
CreateStreamObject(5442, -970.708984375, 496.970703125, 1339.5881347656, 4.229736328125, 356.02294921875, 269.12109375, 500);
CreateStreamObject(5442, -970.96124267578, 501.88531494141, 1341.1875, 0.25973510742188, 359.99291992188, 269.60607910156, 500);
CreateStreamObject(5420, -743.45336914063, 579.16772460938, 1349.0212402344, 0, 350.07495117188, 19.894958496094, 500);
CreateStreamObject(3907, -622.67755126953, 524.15582275391, 1347.5157470703, 350.07507324219, 358.01501464844, 101.68502807617, 500);
CreateStreamObject(3907, -641.55084228516, 398.50955200195, 1321.4221191406, 359.99877929688, 358.01147460938, 11.954040527344, 500);
CreateStreamObject(1662, -989.74444580078, 578.90521240234, 1335.3752441406, 0, 0, 7.93994140625, 500);
CreateStreamObject(5442, -622.25091552734, 378.70831298828, 1330.1695556641, 356.03002929688, 338.16516113281, 190.04614257813, 500);
CreateStreamObject(5390, -763.53997802734, 335.61297607422, 1342.9421386719, 0, 0, 0, 500);
CreateStreamObject(5442, -678.79119873047, 368.05276489258, 1345.4188232422, 356.0280456543, 352.05725097656, 189.32507324219, 500);
CreateStreamObject(5400, -769.32073974609, 365.81582641602, 1344.482421875, 0, 0, 0, 500);
CreateStreamObject(10405, -741.94573974609, 234.70336914063, 1348.6684570313, 0, 0, 79.760009765625, 500);
CreateStreamObject(11493, -749.34606933594, 291.20614624023, 1341.8673095703, 5.9549865722656, 0, 241.17468261719, 500);
CreateStreamObject(14387, -810.24090576172, 395.18545532227, 1336.7236328125, 0, 348.08996582031, 270.36022949219, 500);
CreateStreamObject(14387, -810.21160888672, 397.51705932617, 1337.6978759766, 1.9849853515625, 346.10501098633, 270.35705566406, 500);
CreateStreamObject(14387, -810.16784667969, 400.61639404297, 1339.1475830078, 0, 354.04501342773, 270.35705566406, 500);
CreateStreamObject(14387, -810.14916992188, 403.16836547852, 1340.3975830078, 0, 354.03991699219, 270.3515625, 500);
CreateStreamObject(14387, -810.18707275391, 405.72259521484, 1341.6728515625, 0, 354.03991699219, 270.3515625, 500);
CreateStreamObject(14387, -809.93151855469, 408.42129516602, 1342.7216796875, 0, 354.03991699219, 270.3515625, 500);
CreateStreamObject(14387, -809.96276855469, 411.31314086914, 1344.1713867188, 0, 354.03991699219, 270.3515625, 500);
CreateStreamObject(14387, -809.98962402344, 413.96246337891, 1345.1708984375, 1.9849853515625, 348.0849609375, 270.3515625, 500);
CreateStreamObject(14387, -809.99078369141, 416.51211547852, 1346.1704101563, 1.9830322265625, 348.07983398438, 270.3515625, 500);
CreateStreamObject(14387, -810.09088134766, 418.91030883789, 1347.2457275391, 359.998046875, 356.01977539063, 270.3515625, 500);
CreateStreamObject(14387, -810.09655761719, 421.42761230469, 1348.4451904297, 359.99450683594, 342.12255859375, 270.3515625, 500);
CreateStreamObject(14387, -810.02514648438, 423.7353515625, 1349.4461669922, 359.98901367188, 356.0146484375, 270.3515625, 500);
CreateStreamObject(14387, -809.86083984375, 426.41009521484, 1350.5460205078, 359.98352050781, 342.11706542969, 270.3515625, 500);
CreateStreamObject(14387, -809.85485839844, 428.17065429688, 1351.3455810547, 359.97802734375, 352.03918457031, 270.3515625, 500);
CreateStreamObject(14387, -809.78631591797, 430.67919921875, 1352.5960693359, 359.97802734375, 342.10998535156, 270.3515625, 500);
CreateStreamObject(14387, -809.78814697266, 433.44799804688, 1353.7962646484, 359.97802734375, 352.03369140625, 270.3515625, 500);
CreateStreamObject(14387, -809.54858398438, 435.73498535156, 1354.6713867188, 359.97802734375, 344.08947753906, 270.3515625, 500);
CreateStreamObject(14387, -809.90661621094, 437.92395019531, 1355.5960693359, 359.97802734375, 354.01123046875, 270.3515625, 500);
CreateStreamObject(14387, -810.00616455078, 441.20880126953, 1356.5450439453, 3.947998046875, 326.21716308594, 270.3515625, 500);
CreateStreamObject(14387, -809.84619140625, 444.20361328125, 1356.6959228516, 5.9290771484375, 326.21704101563, 270.3515625, 500);
CreateStreamObject(14387, -810.00225830078, 448.13024902344, 1356.8460693359, 9.8971252441406, 322.2470703125, 270.3515625, 500);
CreateStreamObject(14387, -810.25170898438, 450.86846923828, 1356.6959228516, 9.8931884765625, 322.24548339844, 270.3515625, 500);
CreateStreamObject(14387, -810.35778808594, 452.86669921875, 1356.6959228516, 9.8931884765625, 322.24548339844, 270.3515625, 500);
CreateStreamObject(14387, -810.44140625, 454.06353759766, 1356.6959228516, 9.8931884765625, 322.24548339844, 270.3515625, 500);
CreateStreamObject(14387, -810.44140625, 454.0634765625, 1356.6959228516, 9.8931884765625, 322.24548339844, 270.3515625, 500);
SetTimer("StreamTimer", 500, 1);
return 1;
}
public OnFilterScriptExit()
{
for (new i=0; i<MAX_PLAYERS; i++)
{
for (new p=0; p<=created; p++)
{
if (PlayerObjects[i][seen][p] == true)
{
DestroyPlayerObject(i,PlayerObjects[i][pobjects][p]);
}
}
}
return 1;
}
forward StreamTimer();
public StreamTimer()
{
new Float:x,Float:y,Float:z;
new Float:x2,Float:y2,Float:z2;
for (new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
GetPlayerPos(i,x,y,z);
for (new p=0; p<=created; p++)
{
if (Objects[p][modelid] != 0)
{
if (Objects[p][attached] != -1)
{
GetPlayerPos(Objects[p][attached],x2,y2,z2);
Objects[p][xpos] = x2+Objects[p][xoff];
Objects[p][ypos] = y2+Objects[p][yoff];
Objects[p][zpos] = z2+Objects[p][zoff];
}
if (PointToPoint(x,y,z,Objects[p][xpos],Objects[p][ypos],Objects[p][zpos],Objects[p][viewdist]))
{
if (PlayerObjects[i][seen][p] == false && PlayerObjects[i][seeing] <= 254)
{
PlayerObjects[i][pobjects][p] = CreatePlayerObject(i,Objects[p][modelid],Objects[p][xpos],Objects[p][ypos],Objects[p][zpos],Objects[p][xrot],Objects[p][yrot],Objects[p][zrot]);
if (Objects[p][attached] != -1)
{
AttachPlayerObjectToPlayer(i,PlayerObjects[i][pobjects][p],Objects[p][attached],Objects[p][xoff],Objects[p][yoff],Objects[p][zoff],Objects[p][xrot],Objects[p][yrot],Objects[p][zrot]);
}
else if (Objects[p][moving] == true)
{
MovePlayerObject(i,PlayerObjects[i][pobjects][p],Objects[p][movx],Objects[p][movy],Objects[p][movz],Objects[p][speed]);
}
PlayerObjects[i][seen][p] = true;
PlayerObjects[i][seeing] += 1;
}
}
else if (PlayerObjects[i][seen][p] == true)
{
DestroyPlayerObject(i,PlayerObjects[i][pobjects][p]);
PlayerObjects[i][seen][p] = false;
PlayerObjects[i][seeing] -= 1;
}
}
}
}
}
}
forward MoveTimer(id2,xadd,yadd,zadd,bool:xisbigger,bool:yisbigger,bool:zisbigger);
public MoveTimer(id2,xadd,yadd,zadd,bool:xisbigger,bool:yisbigger,bool:zisbigger)
{
new bool:reached = false;
reached = xisbigger ? ((Objects[id2][xpos] >= Objects[id2][movx]) ? true : false) : ((Objects[id2][xpos] <= Objects[id2][movx]) ? true : false);
if (reached)
{
reached = yisbigger ? ((Objects[id2][ypos] >= Objects[id2][movy]) ? true : false) : ((Objects[id2][ypos] <= Objects[id2][movy]) ? true : false);
if (reached)
{
reached = zisbigger ? ((Objects[id2][zpos] >= Objects[id2][movz]) ? true : false) : ((Objects[id2][zpos] <= Objects[id2][movz]) ? true : false);
}
}
if (reached)
{
Objects[id2][moving] = false;
for (new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if (PlayerObjects[i][seen][id2] == true && Objects[id2][moving] == true)
{
MovePlayerObject(i,PlayerObjects[i][pobjects][id2],Objects[id2][movx],Objects[id2][movy],Objects[id2][movz],Objects[id2][speed]);
}
}
}
Objects[id2][xpos] = Objects[id2][movx];
Objects[id2][ypos] = Objects[id2][movy];
Objects[id2][zpos] = Objects[id2][movz];
KillTimer(Objects[id2][movetimer]);
}
else
{
new bool:found = false;
for (new i=0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if (PlayerObjects[i][seen][id2] == true)
{
GetPlayerObjectPos(i,PlayerObjects[i][pobjects][id2],Objects[id2][xpos],Objects[id2][ypos],Objects[id2][zpos]);
found = true;
break;
}
}
}
if (!found)
{
Objects[id2][xpos] = Objects[id2][xpos]+xadd;
Objects[id2][ypos] = Objects[id2][ypos]+yadd;
Objects[id2][zpos] = Objects[id2][zpos]+zadd;
}
}
}