Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define MAX_TRAILERS 10
- new TrailerID[MAX_TRAILERS] = {INVALID_VEHICLE_ID, ...},
- TrailerNum[MAX_VEHICLES] = {-1, ...};
- stock j_CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay)
- {
- new vehicleid = CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay);
- switch(modelid)
- {
- case 435, 450, 584, 591, 606, 607, 608, 610, 611:
- {
- new bool:f;
- for(new c; c < MAX_TRAILERS; c++)
- {
- if(TrailerID[c] == INVALID_VEHICLE_ID)
- {
- TrailerID[c] = vehicleid;
- TrailerNum[vehicleid] = c;
- f = true;
- break;
- }
- }
- if(!f) print("Increase MAX_TRAILERS value!");
- }
- }
- return vehicleid;
- }
- #define CreateVehicle j_CreateVehicle
- stock j_DestroyVehicle(vehicleid)
- {
- switch(GetVehicleModel(vehicleid))
- {
- case 435, 450, 584, 591, 606, 607, 608, 610, 611:
- {
- TrailerID[TrailerNum[vehicleid]] = INVALID_VEHICLE_ID;
- TrailerNum[vehicleid] = -1;
- }
- }
- return 1;
- }
- #define DestroyVehicle j_DestroyVehicle
- public OnGameModeInit()
- {
- SetTimer("CheckTrailers", 200, true);
- CreateVehicle(435,1626.2261,-1305.7869,17.5208,279.3670,19,50, -1); // tr1
- CreateVehicle(435,1644.1757,-1300.4391,16.1890,230.2410,102,6, -1); // tr2
- CreateVehicle(435,1607.9326,-1300.4973,17.9331,173.2703,91,47, -1); // tr3
- return 1;
- }
- forward CheckTrailers();
- public CheckTrailers()
- {
- new Float:tHP, trailerid;
- for(new c; c < MAX_TRAILERS; c++)
- {
- trailerid = TrailerID[c];
- if(trailerid == INVALID_VEHICLE_ID) continue;
- GetVehicleHealth(trailerid, tHP);
- if(tHP < 250)
- {
- CallLocalFunction("OnVehicleDeath", "dd", trailerid, INVALID_PLAYER_ID);
- }
- }
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- switch(GetVehicleModel(vehicleid))
- {
- case 435, 450, 584, 591, 606, 607, 608, 610, 611:
- {
- new str[32];
- format(str, 32, "OnVehicleDeath: TrailerID: %d", vehicleid);
- SendClientMessageToAll(-1, str);
- SetVehicleToRespawn(vehicleid);
- }
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp("/f", cmdtext, true, 2))
- {
- new trailerid;
- for(new c; c < MAX_TRAILERS; c++)
- {
- trailerid = TrailerID[c];
- if(trailerid == INVALID_VEHICLE_ID) continue;
- SetVehicleHealth(trailerid, 249);
- }
- return 1;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement