Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum vEnum
- {
- bool:vTrailer,
- vObject,
- vBase
- }
- new vInfo[MAX_VEHICLES][vEnum];
- CMD:trailer(playerid,params[])
- {
- new Float:x,Float:y,Float:z,Float:r;
- GetPlayerPos(playerid,x,y,z);
- GetPlayerFacingAngle(playerid,r);
- CreateTrailer(x,y,z,r);
- return 1;
- }
- CMD:attach(playerid,params[])
- {
- new Float:x,Float:y,Float:z;
- for(new i = 0; i < MAX_VEHICLES; i++)
- {
- if(!GetVehicleModel(i)) continue;
- GetVehiclePos(i,x,y,z);
- if(IsPlayerInRangeOfPoint(playerid,10,x,y,z))
- {
- if(vInfo[i][vTrailer] != true) continue;
- AttachTrailerToVehicle(i,GetPlayerVehicleID(playerid));
- return 1;
- }
- }
- return 1;
- }
- stock CreateTrailer(Float:x,Float:y,Float:z,Float:r,attach = INVALID_VEHICLE_ID)
- {
- new i = GetFreeVehicleID();
- vInfo[i][vTrailer] = true;
- vInfo[i][vBase] = CreateVehicle(606,x,y,z,r,-1,-1,-1); // Create the base of the caravan
- vInfo[i][vObject] = CreateObject(3171,0,0,0,0,0,180); // Create the caravan object to attach to the base
- AttachObjectToVehicle(vInfo[i][vObject],vInfo[i][vBase],0.00724,-1.84854,-0.96500,0,0,180);
- if(attach != INVALID_VEHICLE_ID) AttachTrailerToVehicle(vInfo[i][vBase],attach);
- return 1;
- }
- stock GetFreeVehicleID()
- {
- for(new i = 1; i < MAX_VEHICLES; i++) if(!GetVehicleModel(i)) return i;
- return INVALID_VEHICLE_ID;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement