DragonZafiro666

Teleport System [Dialog] + Add your own

Mar 5th, 2016
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.35 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include "../include/gl_common.inc" // For PlayerName() Func
  4.  
  5. #define DIALOG_TELEPORTS 20
  6. new first[MAX_PLAYERS];
  7. enum teleInfo
  8. {
  9.     Name[50],
  10.     Float:tx,
  11.     Float:ty,
  12.     Float:tz,
  13.     Float:rad
  14. };
  15. new Teleports[][teleInfo] =
  16. {
  17.     // Add your own: (Name, X, Y, Z, angle)
  18.     {"Las Venturas", 2114.524414, 1863.202758, 10.671875, 259.017700},
  19.     {"Los Santos", 2487.428710, -1671.656127, 13.335947, 274.707855},
  20.     {"San Fierro", -2243.251220, 319.896331, 35.171875, 272.201202}
  21. };
  22. // Command
  23. CMD:teleports(playerid, params[])
  24. {
  25.     new teleString[400];
  26.     for(new i = 0; i < sizeof(Teleports); i++)
  27.     {
  28.         strcat(teleString, Teleports[i][Name]);
  29.         strcat(teleString, "\n");
  30.     }
  31.     ShowPlayerDialog(playerid, DIALOG_TELEPORTS, DIALOG_STYLE_LIST, "Choose your place:", teleString, "Choose", "Cancel");
  32.     return 1;
  33. }
  34. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  35. {
  36.     switch(dialogid)
  37.     {
  38.         case DIALOG_TELEPORTS:
  39.         {
  40.             if(response)
  41.             {
  42.                                     // Time in secs,
  43.                 GotoPlace(playerid, 3, Teleports[listitem][tx], Teleports[listitem][ty], Teleports[listitem][tz], Teleports[listitem][rad], 0);
  44.                 new str[300];
  45.                 format(str, 300, "%s Has been teleported to %s! [/Tele]", PlayerName(playerid), Teleports[listitem][Name]);
  46.                 SendClientMessageToAll(-1, str);
  47.             }
  48.             return 1;
  49.         }
  50.     }
  51.     return 0;
  52. }
  53. // Teleport Function
  54. forward GotoPlace(playerid, time, Float:x, Float:y, Float:z, Float:angle, interior);
  55. public GotoPlace(playerid, time, Float:x, Float:y, Float:z, Float:angle, interior)
  56. {
  57.     if(first[playerid] != 1) // First time player TP
  58.     {
  59.         if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
  60.         {
  61.             SetPlayerPos(playerid, x, y, z + 2);
  62.             SetPlayerFacingAngle(playerid, angle);
  63.         }
  64.         else if(IsPlayerInAnyVehicle(playerid))
  65.         {
  66.             SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z + 8); // + 8 due cars doesn't freeze
  67.             SetVehicleZAngle(GetPlayerVehicleID(playerid), angle);
  68.         }
  69.         SetPlayerInterior(playerid, interior);
  70.         TogglePlayerControllable(playerid, 0);
  71.         first[playerid] = 1;
  72.     }
  73.     if(time == 0) // Time ends, player unfreezed
  74.     {
  75.         TogglePlayerControllable(playerid, 1);
  76.         GameTextForPlayer(playerid,"~n~~n~~n~~n~~w~Unfreezed!", 3000, 4);
  77.         first[playerid] = 0;
  78.     }
  79.     else
  80.         SetTimerEx("GotoPlace", 1000, 0, "ddffffd", playerid, time - 1, x, y, z, angle, interior);
  81.     return 1;
  82. }
Add Comment
Please, Sign In to add comment