Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Info panel for developers
- The panel in the form of textdraw, showing some details of the
- player(by himself). Designed for developers of game mods.
- How vividly the panel will look on the screen -
- x: 0.0 y: 0.0 z: 0.0 angle: 0.0 world: 0 int: 0
- where:
- x, y, z - position;
- angle - angle of rotation;
- world - virtual world;
- int - interior.
- */
- // Includes
- #include <a_samp>
- // Settings
- #define INFO_VERSION 1.0
- #define TIME_UPDATE_DI 500// update time (msec.)
- #define MAX_STRING_DI 164// max size string
- #define TD_COORD 132.000000, 428.000000
- #define TD_FONT 1
- #define TD_LETTER_SIZE 0.259999, 1.499999
- #define TD_SET_OUTLINE 1
- #define TD_SET_PROPORTIONAL 1
- #define TD_TEXT_STRING\
- "~w~~h~x: ~y~~h~%.4f ~w~~h~y: ~y~~h~%.4f ~w~~h~z: ~y~~h~%.4f \
- ~w~~h~angle: ~y~~h~%.4f \
- ~w~~h~world: ~y~~h~%d ~w~~h~int: ~y~~h~%d"
- #define TXT_CMD_DI "/info"
- #define TXT_SHOW_DI "Info panel on"
- #define TXT_HIDE_DI "Info panel off"
- #define COLOR_MSG_ON (0x00ff00ff)
- #define COLOR_MSG_OFF (0xff0000ff)
- // Variables
- static Text:td_id[MAX_PLAYERS] = {Text:INVALID_TEXT_DRAW, ...};
- static timer_id[MAX_PLAYERS];
- // Change the text in the info
- ChangeStringDevInfo(playerid)
- {
- new Float: data[4];
- GetPlayerPos(playerid, data[0], data[1], data[2]);
- GetPlayerFacingAngle(playerid, data[3]);
- new string_current[MAX_STRING_DI];
- format
- (
- string_current, sizeof string_current, TD_TEXT_STRING,
- data[0], data[1], data[2], data[3],
- GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)
- );
- static string_buffer[MAX_STRING_DI] = ' ';
- if (strcmp(string_buffer, string_current, true))
- {
- TextDrawSetString(td_id[playerid], string_current);
- }
- string_buffer = string_current;
- }
- // Updates the text in the info
- forward UpdateDevInfo(playerid);
- public UpdateDevInfo(playerid)
- {
- ChangeStringDevInfo(playerid);
- }
- // Callbacks
- public OnFilterScriptInit()
- {
- print("Info panel for developers \
- v"#INFO_VERSION" loaded");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("Info panel for developers \
- v"#INFO_VERSION" unloaded");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- timer_id[playerid] = -1;
- if (td_id[playerid] == Text:INVALID_TEXT_DRAW)
- {
- td_id[playerid] = TextDrawCreate(TD_COORD, " ");
- TextDrawFont(td_id[playerid], TD_FONT);
- TextDrawLetterSize(td_id[playerid], TD_LETTER_SIZE);
- TextDrawSetOutline(td_id[playerid], TD_SET_OUTLINE);
- TextDrawSetProportional(td_id[playerid], TD_SET_PROPORTIONAL);
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- #pragma unused reason
- if (timer_id[playerid] != -1)
- {
- TextDrawHideForPlayer(playerid, td_id[playerid]);
- KillTimer(timer_id[playerid]);
- timer_id[playerid] = -1;
- }
- if (td_id[playerid] != Text:INVALID_TEXT_DRAW)
- {
- TextDrawDestroy(td_id[playerid]);
- td_id[playerid] = Text:INVALID_TEXT_DRAW;
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp(cmdtext, TXT_CMD_DI, true) == 0)
- {
- if (timer_id[playerid] == -1)
- {
- ChangeStringDevInfo(playerid);
- TextDrawShowForPlayer(playerid, td_id[playerid]);
- timer_id[playerid] = SetTimerEx("UpdateDevInfo",\
- TIME_UPDATE_DI, 1, "d", playerid);
- SendClientMessage(playerid, COLOR_MSG_ON, TXT_SHOW_DI);
- }
- else
- {
- TextDrawHideForPlayer(playerid, td_id[playerid]);
- KillTimer(timer_id[playerid]);
- timer_id[playerid] = -1;
- SendClientMessage(playerid, COLOR_MSG_OFF, TXT_HIDE_DI);
- }
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement