Advertisement
Kyosaur

Teleport engine header

Jun 30th, 2011
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.02 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include "Main.h"
  4. #include "Player.h"
  5.  
  6. #include <vector>
  7. #include <string>
  8.  
  9. #define TELEPORT_TABLE "Teleport_table" //for testing
  10. #define CATEGORY_TABLE "Category_table"
  11. #define TELEPORT_BUILD_CONTINUE "continue"
  12.  
  13. //Information for our teleport parsing
  14. enum E_TELE_PARSE
  15. {
  16.     E_TELE_CATEGORY,
  17.     E_TELE_NAME,
  18.     E_TELE_X,
  19.     E_TELE_Y,
  20.     E_TELE_Z,
  21.     E_TELE_A,
  22.     E_TELE_VW,
  23.     E_TELE_INT,
  24.     E_TELE_REAL_TELE,
  25.     E_TELE_VEHICLE,
  26.     E_TELE_DM_VEHICLE,
  27.     E_TELE_FREEZE,
  28.     E_TELE_REMOVE_TELE_ARMOUR,
  29.     E_TELE_REMOVE_TELE_WEAPS,
  30.     E_TELE_FILL_HEALTH,
  31.     E_TELE_GAME_TELE_TEXT,
  32. };
  33.  
  34. enum E_CAT_PARSE
  35. {
  36.     E_CAT_NAME,
  37.     E_CAT_MAPICON,
  38.     E_CAT_ICON,
  39.     E_CAT_COLOR
  40. };
  41.  
  42. enum E_TELE_CODES
  43. {
  44.     E_SUCCESSFUL_TELE
  45. };
  46.  
  47. class TeleConfig;
  48.  
  49. //Vehicles that can NOT teleport (Even if its a valid vehicle teleport).
  50. extern const int g_BadVehicles[];
  51. extern const int g_DmVehicles[];
  52.  
  53. //Information for teleport building.
  54. extern const string g_MapIconInfo[];
  55. extern const string g_WeaponInfo[];
  56.  
  57. //A config vector for the end of the teleport builder
  58. extern map<int, vector<TeleConfig> > g_TeleBuildConfig;
  59.  
  60. //class for the config stuff at the end of the teleport builder.
  61. //friend to: Teleport
  62. class TeleConfig
  63. {
  64. private:
  65.     bool* m_Addr;
  66.     string m_Msg;
  67. public:
  68.     friend class Teleport;
  69.  
  70.     TeleConfig();
  71.     TeleConfig(const char* msg, bool* addr);
  72.     ~TeleConfig();
  73. };
  74.  
  75.  
  76. //friend to: Teleport
  77. class Category
  78. {
  79. private:
  80.     string m_Name;
  81.     bool m_MapIcon;
  82.     int
  83.         m_Icon,
  84.         m_Color;
  85. public:
  86.     friend class Teleport;
  87.  
  88.     Category();
  89.     Category(const char* name, bool mapicon, int icon, int color);
  90.     ~Category();
  91. };
  92.  
  93.  
  94. //Teleport is a frind of: Player, Category
  95. class Teleport
  96. {
  97. private:
  98.     string
  99.         m_Name,
  100.         m_ClientMessage,
  101.         m_GameText,
  102.         m_Category;
  103.     float
  104.         m_X,
  105.         m_Y,
  106.         m_Z,
  107.         m_Angle,
  108.         m_VX,
  109.         m_VY,
  110.         m_VZ,
  111.         m_VAngle;
  112.     bool
  113.         m_RealTele,
  114.         m_Vehicle,
  115.         m_DmVehicle,
  116.         m_Freeze,
  117.         m_GiveWeap,
  118.         m_RemoveArmour,
  119.         m_RemoveWeapons,
  120.         m_FillHealth,
  121.         m_AdminTele,
  122.         m_NewCat;
  123.     int
  124.         m_VirtualWorld,
  125.         m_Interior,
  126.         m_MessageColor,
  127.         m_Weapon,
  128.         m_Ammo;
  129.  
  130.     static map<int, Player*> m_Builders;
  131.     static map<int, Teleport> m_BuildTeles;
  132.     static map<const char*, Category> m_Categories;
  133.  
  134. public:
  135.     Teleport();
  136.     ~Teleport();
  137.    
  138.     template<typename T> static inline int ParseTeleData(T* data, const char* str)
  139.     {
  140.         if(strlen(str))
  141.         {
  142.             stringstream s(str);
  143.             s >> *data;
  144.             return 1;
  145.         }
  146.         return 0;
  147.     }
  148.  
  149.     int TeleportPlayer(Player* player);
  150.     int ListTeleports(Player* player);
  151.     void SendTeleportMessage(Player* player,int code);
  152.  
  153.     static int AddTeleport(Player* p);
  154.     static void BuildTeleport(Player* player);
  155.     static void RemoveTeleport(Teleport& teleport);
  156.     static int ParseTeleports(map<const char*, Teleport>& TeleData);
  157.     static int CheckTeleportTable();
  158.  
  159.     //callbacks
  160.     static int OnDialogResponse(int playerid, int dialogid, int response, int listitem, const char* inputtext);
  161.     static int OnPlayerText(int playerid, const char* text);
  162. };
  163.  
  164. extern map<const char*, Teleport> g_Teleport;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement