Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <math>
- #include <zcmd>
- #if !defined IsValidVehicle
- native IsValidVehicle(vehicleid);
- #endif
- new
- attach_trailer[MAX_VEHICLES] = 0,
- attach_vehicle[MAX_VEHICLES] = 0,
- attach_timer[MAX_VEHICLES] = 0
- ;
- stock DFT30_TrailerAttach(vehicleid, trailerid)
- {
- if(!IsValidVehicle(vehicleid) || GetVehicleModel(vehicleid) != 578) return 0;
- if(!IsValidVehicle(trailerid) || GetVehicleModel(trailerid) == 578) return 0;
- if(attach_trailer[vehicleid] || attach_vehicle[trailerid]) return 0;
- attach_trailer[vehicleid] = trailerid;
- attach_vehicle[trailerid] = vehicleid;
- attach_timer[vehicleid] = SetTimerEx("DFT30_UpdateTrailer", 15, true, "d", vehicleid);
- return 1;
- }
- stock DFT30_DetachTrailer(vehicleid)
- {
- if(!attach_timer[vehicleid]) return 0;
- new trailerid = attach_trailer[vehicleid];
- KillTimer(attach_timer[vehicleid]);
- attach_trailer[vehicleid] = 0;
- attach_vehicle[trailerid] = 0;
- return 1;
- }
- forward DFT30_UpdateTrailer(vehicleid);
- public DFT30_UpdateTrailer(vehicleid)
- {
- new Float:x, Float:y, Float:z, Float:angle;
- GetVehicleZAngle(vehicleid, angle);
- GetVehiclePos(vehicleid, x, y, z);
- GetXYFromAngle(x, y, angle, -1.8);
- new trailerid = attach_trailer[vehicleid];
- SetVehiclePos(trailerid, x, y, (z + 1.2));
- GetVehicleZAngle(vehicleid, angle);
- SetVehicleZAngle(trailerid, angle);
- // Melhor usar (Get/Set)VehicleRot
- // https://github.com/Leonardo541/matrix
- return 1;
- }
- CMD:guinchar(playerid, params[])
- {
- new
- vehicleid = GetPlayerVehicleID(playerid),
- trailerid = strval(params)
- ;
- if(!DFT30_TrailerAttach(vehicleid, trailerid))
- {
- new Float:x, Float:y, Float:z, Float:rot;
- GetVehiclePos(vehicleid, x, y, z);
- GetVehicleZAngle(vehicleid, rot);
- GetXYFromAngle(x, y, rot, 10.0);
- DFT30_DetachTrailer(vehicleid);
- SetVehicleZAngle(vehicleid, rot);
- SetVehiclePos(vehicleid, x, y, z);
- }
- return 1;
- }
- main() { print("SA-MP ANDROID 2021"); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement