Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <streamer>
- #define TANK (432)
- native IsValidVehicle(vehicleid);
- new safeVehs[] = {417, 425, 427, 428, 430, 432, 446, 447, 449, 450, 452, 453, 454, 460, 464, 469, 472, 473, 476, 484, 487, 488, 493, 497, 511, 512, 513, 519, 520, 537, 538, 548, 533,
- 563, 569, 570, 577, 590, 591, 592, 593, 595, 606, 607, 608, 610, 611};
- new t_tank[MAX_PLAYERS], debris[MAX_VEHICLES], vw, v;
- stock Float:GetDistanceBetweenPoints(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2)
- {
- return VectorSize(x1-x2, y1-y2, z1-z2);
- }
- stock GetVehicleIDInRange(Float:radius, Float:x, Float:y, Float:z)
- {
- new Float:pos[3];
- for(v = 0; v < MAX_VEHICLES; v++)
- {
- if(!IsValidVehicle(v)) continue;
- GetVehiclePos(v, pos[0], pos[1], pos[2]);
- if(GetDistanceBetweenPoints(pos[0], pos[1], pos[2], x, y, z) <= radius) return v;
- }
- return -1;
- }
- stock IsASafeCar(vehicleid)
- {
- if(!IsValidVehicle(vehicleid)) return false;
- for(new i = 0; i < sizeof(safeVehs); i++)
- {
- if(safeVehs[i] == GetVehicleModel(vehicleid)) return true;
- }
- return false;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- if(GetVehicleModel(vehicleid) == TANK) t_tank[playerid] = SetTimerEx("CheckTank", 500, true, "i", playerid);
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- if(GetVehicleModel(vehicleid) == TANK) KillTimer(t_tank[playerid]);
- return 1;
- }
- forward CheckTank(playerid);
- public CheckTank(playerid)
- {
- new Float:pos[3];
- GetVehiclePos(GetPlayerVehicleID(playerid), pos[0], pos[1], pos[2]);
- if(IsAnyVehicleInRangeOfPoint(1.5, pos[0], pos[1], pos[2]))
- {
- v = GetVehicleIDInRange(1.5, pos[0], pos[1], pos[2]);
- if(IsASafeCar(v)) return 1;
- new Float:pos1[4];
- GetVehiclePos(v, pos1[0], pos1[1], pos1[2]);
- if(pos1[2] >= floatadd(pos[2], 1.0))
- {
- GetVehicleZAngle(v, pos1[3]);
- vw = GetVehicleVirtualWorld(v);
- if(GetVehicleModel(v) != 584)
- {
- DestroyVehicle(v);
- CreateExplosion(pos1[0], pos1[1], pos1[2], 2, 10.0);
- debris[v] = CreateDynamicObject(3594, pos1[0], pos1[1], pos1[2], 0.0, 0.0, pos1[3], vw);
- }
- else
- {
- DestroyVehicle(v);
- CreateExplosion(pos1[0], pos1[1], pos1[2], 3, 15.0);
- }
- }
- }
- return 1;
- }
- stock IsAnyVehicleInRangeOfPoint(Float:range, Float:x, Float:y, Float:z)
- {
- new Float:pos[3];
- for(v = 0; v < MAX_VEHICLES; v++)
- {
- if(!IsValidVehicle(v)) continue;
- GetVehiclePos(v, pos[0], pos[1], pos[2]);
- if(GetDistanceBetweenPoints(pos[0], pos[1], pos[2], x, y, z) <= range) return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement