SupperRobin6394

Untitled

Dec 4th, 2015
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.52 KB | None | 0 0
  1. new RoadBlock[MAX_PLAYERS];
  2. new RoadBlockObject[MAX_PLAYERS];
  3.  
  4. GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance) // Add somewhere
  5. {
  6.     new Float:a;
  7.     GetPlayerPos(playerid, x, y, a);
  8.     GetPlayerFacingAngle(playerid, a);
  9.     if (GetPlayerVehicleID(playerid))
  10.     {
  11.       GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  12.     }
  13.     x += (distance * floatsin(-a, degrees));
  14.     y += (distance * floatcos(-a, degrees));
  15.     return 1;
  16. }
  17.  
  18. COMMAND:rb(playerid,params[])
  19. {
  20.     new vehicleid= GetPlayerVehicleID(playerid);
  21.     if(!IsPlayerInVehicle(playerid, vehicleid))
  22.     {
  23.         if(RoadBlock[playerid] == 0)
  24.         {
  25.             new Float:X, Float:Y, Float:Z,Float:Angle;
  26.             GetPlayerPos(playerid, X, Y, Z);
  27.             GetPlayerFacingAngle(playerid, Angle);
  28.             GetXYInFrontOfPlayer(playerid, X, Y, 1.5); // 1.5 Units in front of the player
  29.             RoadBlockObject[playerid] = CreateObject(979, X, Y, Z-0.3, 0, 0, Angle);
  30.             RoadBlock[playerid] = 1;
  31.             SendClientMessage(playerid, COLOR_GREEN, "You placed the RoadBlock!");
  32.         }
  33.         else SendClientMessage(playerid, COLOR_RED, "ERROR: You already placed a RoadBlock!");
  34.     }
  35.     else SendClientMessage(playerid, COLOR_RED, "You can not place a RoadBlock while in a Vehicle!");
  36. }
  37.  
  38. COMMAND:drb(playerid,params[])
  39. {
  40.     if(RoadBlock[playerid] == 0)
  41.     {
  42.         SendClientMessage(playerid, COLOR_RED, "You did not place a RoadBlock!");
  43.         return 1;
  44.     }
  45.     RoadBlock[playerid] = 0;
  46.     DestroyObject(RoadBlockObject[playerid]);
  47.     SendClientMessage(playerid, COLOR_GREEN, "You removed the RoadBlock!");
  48.     return 1;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment