Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // /$$$$$$$$ /$$ /$$ /$$$$$$$$
- // | $$_____/ |__/| $$ |_____ $$
- // | $$ /$$$$$$ /$$| $$ /$$$$$$ /$$$$$$ /$$/
- // | $$$$$ |____ $$| $$| $$ /$$__ $$ /$$__ $$ /$$/
- // | $$__/ /$$$$$$$| $$| $$| $$$$$$$$| $$ \__/ /$$/
- // | $$ /$$__ $$| $$| $$| $$_____/| $$ /$$/
- // | $$ | $$$$$$$| $$| $$| $$$$$$$| $$ /$$$$$$$$
- // |__/ \_______/|__/|__/ \_______/|__/ |________/
- /*******************************************************************************
- * Labels Creator [LC] - by FailerZ *
- * Copyright © *
- *******************************************************************************/
- //================================ [Includes] ==================================
- #include <a_samp> //Credits to Kalcor/Kye
- //================================ [Defines] ===================================
- //Settings
- #define LABELS_PATH "/Labels.txt"
- #define DELAY_DELETE 10000 //[10 Seconds] - The time before the label will be deleted (it will still saved in scriptfiles)
- //Colors
- #define COL_GREY "{8C8C8C}"
- #define COLOR_GREY 0x8C8C8CFF
- #define COL_WHITE "{FAFAFA}"
- #define COLOR_WHITE 0xFAFAFAFF
- #define COL_ORANGE "{FF6E00}"
- #define COLOR_ORANGE 0xFF6E00FF
- #define COL_RED "{FF0005}"
- #define COLOR_RED 0xFF0005FF
- #define COL_BLUE "{0087FF}"
- #define COLOR_BLUE 0x0087FFFF
- #define COL_GREEN "{0FFF00}"
- #define COLOR_GREEN 0x0FFF00FF
- #define COL_PURPLE "{B400FF}"
- #define COLOR_PURPLE 0xB400FFFF
- #define COL_YELLOW "{F5FF00}"
- #define COLOR_YELLOW 0xF5FF00FF
- //Dialogs
- /* Note: Change the dialog values if these number used in any other GM/FS */
- #define DIALOG_STRING 1000
- #define DIALOG_STRINGCON 1100
- #define DIALOG_COLOR 2000
- #define DIALOG_COLORCON 2200
- #define DIALOG_COLOR1 2220
- #define DIALOG_COLOR2 2222
- #define DIALOG_LOS 3000
- //Easy Codes
- #define SCM SendClientMessage
- #define function%0(%1) forward%0(%1); public%0(%1)
- #define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- //Others
- //================================= [Script] ===================================
- //Variables
- new IsCreating[MAX_PLAYERS], IsPickingPos[MAX_PLAYERS];
- new Text3D:CLabel;
- //------------------------------------------------------------------------------
- //CallBacks & Publics
- public OnFilterScriptInit()
- {
- print("-----------------------------");
- print("| Labels Creator by FailerZ |");
- print("| Loaded |");
- print("-----------------------------");
- Delete3DTextLabel(CLabel);
- if(!fexist(LABELS_PATH))
- {
- new File:intro = fopen(LABELS_PATH, io_write);
- if(intro)
- {
- fwrite(intro, "---------------------------------------------------------------");
- fwrite(intro, "\r\n| * ** Labels Creator | By FailerZ | Thanks For Using It ** * |");
- fwrite(intro, "\r\n| Copy + Paste These Codes In Your GameMode/FilterScript |");
- fwrite(intro, "\r\n---------------------------------------------------------------");
- fclose(intro);
- }
- }
- return 1;
- }
- //------------------------------------------------------------------------------
- public OnFilterScriptExit()
- {
- print("-----------------------------");
- print("| Labels Creator by FailerZ |");
- print("| Unloaded |");
- print("-----------------------------");
- Delete3DTextLabel(CLabel);
- return 1;
- }
- //------------------------------------------------------------------------------
- public OnPlayerDisconnect(playerid)
- {
- ResetAllPVars(playerid);
- Delete3DTextLabel(CLabel);
- return 1;
- }
- //------------------------------------------------------------------------------
- function OnPlayerFinishCreating(playerid)
- {
- new string[75];
- GetPVarString(playerid, "LString", string, sizeof(string));
- CLabel = Create3DTextLabel(string, GetPVarInt(playerid, "LColor"), GetPVarFloat(playerid, "LPosX"), GetPVarFloat(playerid, "LPosY"), GetPVarFloat(playerid, "LPosZ"), 30.0, GetPVarInt(playerid, "LVWorld"), GetPVarInt(playerid, "LOS"));
- new File:labels = fopen(LABELS_PATH, io_append);
- if(labels)
- {
- new str[128];
- format(str, sizeof(str), "\r\nCreate3DTextLabel(\"%s\", 0x%x, %.2f, %.2f, %.2f, 30, %d, %d);", string, GetPVarInt(playerid, "LColor"), GetPVarFloat(playerid, "LPosX"), GetPVarFloat(playerid, "LPosY"), GetPVarFloat(playerid, "LPosZ"), GetPVarInt(playerid, "LVWorld"), GetPVarInt(playerid, "LOS"));
- fwrite(labels, str);
- fclose(labels);
- }
- SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_BLUE"Label Successfully Created, Check Your Scriptfiles.");
- SetTimerEx("DeleteLabel", DELAY_DELETE, false,"i", playerid);
- new dstr[100];
- format(dstr, sizeof(dstr), ""COL_ORANGE"[LC] "COL_YELLOW"You Need To Wait %d Seconds Before You Can Create Another One.", DELAY_DELETE/1000);
- SCM(playerid, -1, dstr);
- return 1;
- }
- //------------------------------------------------------------------------------
- function DeleteLabel(playerid)
- {
- Delete3DTextLabel(CLabel);
- ResetAllPVars(playerid);
- return 1;
- }
- //------------------------------------------------------------------------------
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(PRESSED(KEY_SECONDARY_ATTACK))
- {
- if(IsPickingPos[playerid] == 1)
- {
- new Float:lPos[3], World;
- GetPlayerPos(playerid, lPos[0], lPos[1], lPos[2]);
- World = GetPlayerVirtualWorld(playerid);
- SetPVarFloat(playerid, "LPosX", lPos[0]);
- SetPVarFloat(playerid, "LPosY", lPos[1]);
- SetPVarFloat(playerid, "LPosZ", lPos[2]);
- SetPVarInt(playerid, "LVWorld", World);
- IsPickingPos[playerid] = 0;
- SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_GREEN"Position Saved!");
- ShowPlayerDialog(playerid, DIALOG_STRING, DIALOG_STYLE_INPUT, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_WHITE"Type Your 3D Text Label String", "Ok", "Cancel");
- }
- }
- return 1;
- }
- //================================== [Dialogs] =================================
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new cstr[300];
- strcat(cstr, ""COL_WHITE"White\n"COL_BLUE"Blue\n"COL_PURPLE"Purple\n"COL_RED"Red\n"COL_GREEN"Green\n"COL_ORANGE"Orange\n"COL_GREY"Grey\n"COL_YELLOW"Yellow");
- switch(dialogid)
- {
- case DIALOG_STRING:
- {
- if(response) // 'Ok'
- {
- if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_STRING, DIALOG_STYLE_INPUT, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_WHITE"Type Your 3D Text Label String", "Ok", "Cancel");
- SetPVarString(playerid, "LString", inputtext);
- SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_GREEN"String Saved!");
- ShowPlayerDialog(playerid, DIALOG_COLOR, DIALOG_STYLE_LIST, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", "Select Color\nType Hex Code", "Ok", "Cancel");
- }
- else // 'Cancel'
- {
- ShowPlayerDialog(playerid, DIALOG_STRINGCON, DIALOG_STYLE_MSGBOX, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_RED"Are You Sure You Want To Cancel Creating ?", "Yes", "No");
- }
- }
- //------------------------------------------------------------------------------
- case DIALOG_STRINGCON:
- {
- if(response) // 'Yes'
- {
- ResetAllPVars(playerid);
- SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_RED"You Canceled Creating.");
- }
- else // 'No'
- {
- ShowPlayerDialog(playerid, DIALOG_STRING, DIALOG_STYLE_INPUT, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_WHITE"Type Your 3D Text Label String", "Ok", "Cancel");
- }
- }
- //------------------------------------------------------------------------------
- case DIALOG_COLOR:
- {
- if(response) // 'Ok'
- {
- switch(listitem)
- {
- case 0: // 'Select Color'
- {
- ShowPlayerDialog(playerid, DIALOG_COLOR1, DIALOG_STYLE_LIST, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", cstr, "Select", "Back");
- }
- case 1: // 'Type Hex Code'
- {
- ShowPlayerDialog(playerid, DIALOG_COLOR2, DIALOG_STYLE_INPUT, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_WHITE"Type Your Hex Color Code Here\n"COL_YELLOW"Example: "COL_WHITE"0xFAFAFAFF", "Use", "Back");
- }
- }
- }
- else // 'Cancel'
- {
- ShowPlayerDialog(playerid, DIALOG_COLORCON, DIALOG_STYLE_MSGBOX, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_RED"Are You Sure You Want To Cancel Creating ?", "Yes", "No");
- }
- }
- //------------------------------------------------------------------------------
- case DIALOG_COLORCON:
- {
- if(response) // 'Yes'
- {
- ResetAllPVars(playerid);
- SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_RED"You Canceled Creating.");
- }
- else // 'No'
- {
- ShowPlayerDialog(playerid, DIALOG_COLOR, DIALOG_STYLE_LIST, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", "Select Color\nType Hex Code", "Ok", "Cancel");
- }
- }
- //------------------------------------------------------------------------------
- case DIALOG_COLOR1:
- {
- if(response) // 'Select'
- {
- switch(listitem)
- {
- case 0: // 'White'
- {
- SetPVarInt(playerid, "LColor", COLOR_WHITE);
- SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_GREEN"Color Saved!");
- ShowPlayerDialog(playerid, DIALOG_LOS, DIALOG_STYLE_MSGBOX, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_WHITE"Want The Label To Be Visible Through Objects ?", "Yes", "No");
- }
- case 1: // 'Blue'
- {
- SetPVarInt(playerid, "LColor", COLOR_BLUE);
- SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_GREEN"Color Saved!");
- ShowPlayerDialog(playerid, DIALOG_LOS, DIALOG_STYLE_MSGBOX, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_WHITE"Want The Label To Be Visible Through Objects ?", "Yes", "No");
- }
- case 2: // 'Purple'
- {
- SetPVarInt(playerid, "LColor", COLOR_PURPLE);
- SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_GREEN"Color Saved!");
- ShowPlayerDialog(playerid, DIALOG_LOS, DIALOG_STYLE_MSGBOX, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_WHITE"Want The Label To Be Visible Through Objects ?", "Yes", "No");
- }
- case 3: // 'Red'
- {
- SetPVarInt(playerid, "LColor", COLOR_RED);
- SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_GREEN"Color Saved!");
- ShowPlayerDialog(playerid, DIALOG_LOS, DIALOG_STYLE_MSGBOX, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_WHITE"Want The Label To Be Visible Through Objects ?", "Yes", "No");
- }
- case 4: // 'Green'
- {
- SetPVarInt(playerid, "LColor", COLOR_GREEN);
- SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_GREEN"Color Saved!");
- ShowPlayerDialog(playerid, DIALOG_LOS, DIALOG_STYLE_MSGBOX, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_WHITE"Want The Label To Be Visible Through Objects ?", "Yes", "No");
- }
- case 5: // 'Orange'
- {
- SetPVarInt(playerid, "LColor", COLOR_ORANGE);
- SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_GREEN"Color Saved!");
- ShowPlayerDialog(playerid, DIALOG_LOS, DIALOG_STYLE_MSGBOX, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_WHITE"Want The Label To Be Visible Through Objects ?", "Yes", "No");
- }
- case 6: // 'Grey'
- {
- SetPVarInt(playerid, "LColor", COLOR_GREY);
- SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_GREEN"Color Saved!");
- ShowPlayerDialog(playerid, DIALOG_LOS, DIALOG_STYLE_MSGBOX, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_WHITE"Want The Label To Be Visible Through Objects ?", "Yes", "No");
- }
- case 7: // 'Yellow'
- {
- SetPVarInt(playerid, "LColor", COLOR_YELLOW);
- SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_GREEN"Color Saved!");
- ShowPlayerDialog(playerid, DIALOG_LOS, DIALOG_STYLE_MSGBOX, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_WHITE"Want The Label To Be Visible Through Objects ?", "Yes", "No");
- }
- }
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_COLOR, DIALOG_STYLE_LIST, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", "Select Color\nType Hex Code", "Ok", "Cancel");
- }
- }
- //------------------------------------------------------------------------------
- case DIALOG_COLOR2:
- {
- if(response) // 'Use'
- {
- if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_COLOR2, DIALOG_STYLE_INPUT, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_WHITE"Type Your Hex Color Code Here\n"COL_YELLOW"Example: "COL_WHITE"0xFAFAFAFF", "Use", "Back");
- if(strlen(inputtext) < 8 || strlen(inputtext) > 10) return ShowPlayerDialog(playerid, DIALOG_COLOR2, DIALOG_STYLE_INPUT, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_WHITE"Type Your Hex Color Code Here\n"COL_YELLOW"Example: "COL_WHITE"0xFAFAFAFF", "Use", "Back");
- if(IsHex(inputtext))
- {
- SetPVarInt(playerid, "LColor", HexStr(inputtext));
- SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_GREEN"Color Saved!");
- ShowPlayerDialog(playerid, DIALOG_LOS, DIALOG_STYLE_MSGBOX, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_WHITE"Want The Label To Be Visible Through Objects ?", "Yes", "No");
- }
- else return ShowPlayerDialog(playerid, DIALOG_COLOR2, DIALOG_STYLE_INPUT, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", ""COL_WHITE"Type Your Hex Color Code Here\n"COL_YELLOW"Example: "COL_WHITE"0xFAFAFAFF", "Use", "Back");
- }
- else // 'Back'
- {
- ShowPlayerDialog(playerid, DIALOG_COLOR, DIALOG_STYLE_LIST, ""COL_ORANGE"Labels Creator "COL_WHITE"- "COL_RED"By FailerZ", "Select Color\nType Hex Code", "Ok", "Cancel");
- }
- }
- //------------------------------------------------------------------------------
- case DIALOG_LOS:
- {
- if(response) // 'Yes'
- {
- SetPVarInt(playerid ,"LOS", 0);
- SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_GREEN"LOS Saved!");
- CallLocalFunction("OnPlayerFinishCreating", "i", playerid);
- }
- else // 'No'
- {
- SetPVarInt(playerid ,"LOS", 1);
- SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_GREEN"Line Of Sight Saved!");
- CallLocalFunction("OnPlayerFinishCreating", "i", playerid);
- }
- }
- }
- return 1;
- }
- //================================= [Commands] =================================
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/label", cmdtext, true, 10) == 0)
- {
- if(IsPlayerInAnyVehicle(playerid)) return SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_RED"You Cannot Create Labels In Car.");
- if(IsCreating[playerid] == 1) return SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_RED"Finish Creating Your Label First.");
- if(IsPickingPos[playerid] == 1) return SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_RED"Finish Choosing Position First.");
- IsCreating[playerid] = 1;
- IsPickingPos[playerid] = 1;
- SCM(playerid, -1, ""COL_ORANGE"[LC] "COL_BLUE"Walk To The Place That You Want Your Label To Be Created At, Then.."COL_WHITE" [Press: Enter]");
- return 1;
- }
- return 0;
- }
- //================================= [Stocks] ===================================
- stock ResetAllPVars(playerid)
- {
- IsCreating[playerid] = 0;
- IsPickingPos[playerid] = 0;
- DeletePVar(playerid, "LVWorld");
- DeletePVar(playerid, "LPosX");
- DeletePVar(playerid, "LPosY");
- DeletePVar(playerid, "LPosZ");
- DeletePVar(playerid, "LString");
- DeletePVar(playerid, "LColor");
- DeletePVar(playerid, "LOS");
- return 1;
- }
- //------------------------------------------------------------------------------
- /* ** Credits to Y_Less ** */
- stock IsHex(str[])
- {
- new
- i,
- cur;
- if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) i = 2;
- while (str[i])
- {
- cur = str[i++];
- if (!(('0' <= cur <= '9') || ('A' <= cur <= 'F') || ('a' <= cur <= 'f'))) return 0;
- //if ((cur < '0') || ('9' < cur < 'A') || ('F' < cur < 'a') || (cur > 'f')) return 0;
- }
- return 1;
- }
- //---------->
- stock HexStr(string[])
- {
- new
- ret,
- val,
- i;
- if (string[0] == '0' && string[1] | 0x20 == 'x') i = 2;
- for ( ; ; )
- {
- switch ((val = string[i++]))
- {
- case '0' .. '9':
- {
- val -= '0';
- }
- case 'a' .. 'f':
- {
- val -= 'a' - 10;
- }
- case 'A' .. 'F':
- {
- val -= 'A' - 10;
- }
- default: break;
- }
- ret = ret << 4 | val;
- }
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment