Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////////////
- //
- //
- // #### ######## ###### ######## ######## ### ## ##
- // ## ## ## ## ## ## ## ## ## ### ###
- // ## ## ## ## ## ## ## ## #### ####
- // ## ######## ###### ## ###### ## ## ## ### ##
- // ## ## ## ## ## ######### ## ##
- // ## ## ## ## ## ## ## ## ## ##
- // #### ## ###### ## ######## ## ## ## ##
- //
- //
- // GzEditor v1.0
- //
- /* ______ ______ _
- // | ___ \ | ___ \ | |
- // | |_/ /_ _ | |_/ /_ _ _ _| | ___
- // | ___ \ | | | | __/ _` | | | | |/ _ \
- // | |_/ / |_| |_ | | | (_| | |_| | | (_) |
- // \____/ \__, (_) \_| \__,_|\__,_|_|\___/
- // __/ |
- // |___/
- */
- // !!! Crie e Edite suas Gz's Facilmente com esse FS !!!
- //
- // [iPs]TeaM soluções de programação em geral (agora com cursos)
- //
- // http://ips-team.forumeiros.com/ (contate-nos)
- //
- /////////////////////////////////////////////////////////////////////////////////
- #include <a_samp>
- #define MAX_GZ 50
- #define DialogID 1996
- new pCount,
- pMaxPlayers,
- pGzSave,
- Float: pX,
- Float: pY,
- Float: pZ,
- pGzName[MAX_GZ][24],
- pGz[MAX_GZ] = {0xFFFF, ...},
- pEditGz = 0xFFFF,
- Float: pMinX[MAX_GZ],
- Float: pMinY[MAX_GZ],
- Float: pMaxX[MAX_GZ],
- Float: pMaxY[MAX_GZ],
- pColor[MAX_GZ] = {0xFF0000AA, ...};
- public OnPlayerConnect(playerid) {
- if(pMaxPlayers) SendClientMessage(playerid, -1, "Info: Máximo 1 Player conectado!!"), Kick(playerid);
- for(new i = (pCount - 1); i > -1; --i) GangZoneShowForPlayer(playerid, pGz[i], pColor[i]);
- pMaxPlayers++;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason) {
- pMaxPlayers--;
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
- switch(dialogid) {
- case DialogID: {
- if(response) {
- switch(listitem) {
- case 0: {
- if(pGz[pCount] != 0xFFFF) return SendClientMessage(playerid, -1, "Erro: Salve essa Gz Primeiro.");
- GetPlayerPos(playerid, pX, pY, pZ);
- pGz[pCount] = GangZoneCreate(pX, pY, pX, pY);
- SendClientMessage(playerid, -1, "Info: Agora vá até a outra ponta da Gz, formando um Retângulo.");
- } case 1: {
- if(pGz[pCount] != 0xFFFF) return SendClientMessage(playerid, -1, "Erro: Salve essa Gz Primeiro.");
- new Str[1200], i;
- for(; i != pCount; ++i) {
- strcat(Str, pGzName[i]);
- strcat(Str, "\n");
- }
- ShowPlayerDialog(playerid, (DialogID + 1), DIALOG_STYLE_LIST, "GzEditor » By Paulo", Str, "Ok", "Voltar");
- } case 2: {
- if(pGz[pCount] != 0xFFFF) return SendClientMessage(playerid, -1, "Erro: Salve essa Gz Primeiro.");
- new Str[1200], i;
- for(; i != pCount; ++i) {
- strcat(Str, pGzName[i]);
- strcat(Str, "\n");
- }
- ShowPlayerDialog(playerid, (DialogID + 2), DIALOG_STYLE_LIST, "GzEditor » By Paulo", Str, "Ok", "Voltar");
- } case 3: {
- if(pEditGz == 0xFFFF) ShowPlayerDialog(playerid, (DialogID + 3), DIALOG_STYLE_INPUT, "GzEditor » By Paulo", "Digite o Nome da Gz.", "Ok", "Voltar");
- else {
- if(strlen(inputtext) > 23) return SendClientMessage(playerid, -1, "Erro: Máximo de Caracteres atingido.");
- new Float: gX, Float: gY, Float: gZ;
- GetPlayerPos(playerid, gX, gY, gZ);
- pMinX[pEditGz] = (pX > gX ? gX : pX), pMinY[pEditGz] = (pY > gY ? gY : pY);
- pMaxX[pEditGz] = (pX < gX ? gX : pX), pMaxY[pEditGz] = (pY < gY ? gY : pY);
- pEditGz = 0xFFFF;
- SendClientMessage(playerid, -1, "Info: Gz refeita com Sucesso!!");
- }
- } case 4: {
- if(pGz[pCount] != 0xFFFF) return SendClientMessage(playerid, -1, "Erro: Salve essa Gz Primeiro.");
- new Str[1200], i;
- for(; i != pCount; ++i) {
- strcat(Str, pGzName[i]);
- strcat(Str, "\n");
- }
- ShowPlayerDialog(playerid, (DialogID + 5), DIALOG_STYLE_LIST, "GzEditor » By Paulo", Str, "Ok", "Voltar");
- } case 5: {
- if(!pCount) return SendClientMessage(playerid, -1, "Erro: Você não criou nenhuma Gz.");
- new File: pFile = fopen("GzEditor_By.Paulo.pwn", io_write), i, pStr[128];
- if(pCount > 1) {
- format(pStr, 128, "new pGz[%i];\r\n\r\n", pCount);
- fwrite(pFile, pStr);
- fwrite(pFile, "main() {\r\n");
- fwrite(pFile, " print(\"|---------------------------|\");\r\n");
- fwrite(pFile, " print(\"| -- GzEditor By Paulo -- |\");\r\n");
- fwrite(pFile, " print(\"|---------------------------|\");\r\n");
- fwrite(pFile, "}\r\n\r\n");
- fwrite(pFile, "public OnGameModeInit() {\r\n");
- for(; i != pCount; ++i) {
- format(pStr, 128, " pGz[%i] = GangZoneCreate(%f, %f, %f, %f); // %s\r\n", i, pMinX[i], pMinY[i], pMaxX[i], pMaxY[i], pGzName[i]);
- fwrite(pFile, pStr);
- }
- fwrite(pFile, " return 1;\r\n}\r\n\r\n");
- fwrite(pFile, "public OnPlayerConnect(playerid) {\r\n");
- for(i = 0; i != pCount; ++i) {
- format(pStr, 128, " GangZoneShowForPlayer(playerid, pGz[%i], %s); // %s\r\n", i, HexForStr(pColor[i]), pGzName[i]);
- fwrite(pFile, pStr);
- }
- fwrite(pFile, " return 1;\r\n}\r\n\r\n");
- fclose(pFile);
- } else {
- fwrite(pFile, "new pGz;\r\n\r\n");
- fwrite(pFile, "main() {\r\n");
- fwrite(pFile, " print(\"|---------------------------|\");\r\n");
- fwrite(pFile, " print(\"| -- GzEditor By Paulo -- |\");\r\n");
- fwrite(pFile, " print(\"|---------------------------|\");\r\n");
- fwrite(pFile, "}\r\n\r\n");
- fwrite(pFile, "public OnGameModeInit() {\r\n");
- format(pStr, 128, " pGz = GangZoneCreate(%f, %f, %f, %f); // %s\r\n", pMinX[0], pMinY[0], pMaxX[0], pMaxY[0], pGzName[0]);
- fwrite(pFile, pStr);
- fwrite(pFile, " return 1;\r\n}\r\n\r\n");
- fwrite(pFile, "public OnPlayerConnect(playerid) {\r\n");
- format(pStr, 128, " GangZoneShowForPlayer(playerid, pGz, %s); // %s\r\n", HexForStr(pColor[0]), pGzName[0]);
- fwrite(pFile, pStr);
- fwrite(pFile, " return 1;\r\n}\r\n\r\n");
- fclose(pFile);
- }
- SendClientMessage(playerid, -1, "Info: Gz's exportadas com Sucesso!!");
- }
- }
- }
- } case (DialogID + 1): {
- if(response) {
- pGzSave = listitem;
- ShowPlayerDialog(playerid, (DialogID + 4), DIALOG_STYLE_INPUT, "GzEditor » By Paulo", "Digite a Cor na forma \"0xFFFFFFFF\"", "Ok", "Voltar");
- } else ShowPlayerDialog(playerid, DialogID, DIALOG_STYLE_LIST, "GzEditor » By Paulo", "Criar\nCor\nRefazer\nSalvar\nExcluir\nExportar", "Ok", "Sair");
- } case (DialogID + 2): {
- if(response) {
- if(pGz[pCount] != 0xFFFF) return SendClientMessage(playerid, -1, "Erro: Salve essa Gz Primeiro.");
- GangZoneDestroy(pGz[listitem]);
- GetPlayerPos(playerid, pX, pY, pZ);
- pGz[(pEditGz = listitem)] = GangZoneCreate(pX, pY, pX, pY);
- SendClientMessage(playerid, -1, "Info: Agora vá até a outra ponta da Gz, formando um Retângulo.");
- } else ShowPlayerDialog(playerid, DialogID, DIALOG_STYLE_LIST, "GzEditor » By Paulo", "Criar\nCor\nRefazer\nSalvar\nExcluir\nExportar", "Ok", "Sair");
- } case (DialogID + 3): {
- if(response) {
- if(strlen(inputtext) > 23) return SendClientMessage(playerid, -1, "Erro: Máximo de Caracteres atingido.");
- new Float: gX, Float: gY, Float: gZ;
- strcat(pGzName[pCount], inputtext);
- GetPlayerPos(playerid, gX, gY, gZ);
- pMinX[pCount] = (pX > gX ? gX : pX), pMinY[pCount] = (pY > gY ? gY : pY);
- pMaxX[pCount] = (pX < gX ? gX : pX), pMaxY[pCount] = (pY < gY ? gY : pY);
- pCount++;
- SendClientMessage(playerid, -1, "Info: Gz salva com Sucesso!!");
- } else ShowPlayerDialog(playerid, DialogID, DIALOG_STYLE_LIST, "GzEditor » By Paulo", "Criar\nCor\nRefazer\nSalvar\nExcluir\nExportar", "Ok", "Sair");
- } case (DialogID + 4): {
- if(response) {
- if(pGz[pCount] != 0xFFFF) return SendClientMessage(playerid, -1, "Erro: Salve essa Gz Primeiro.");
- new Str[1200], i;
- for(; i != pCount; ++i) {
- strcat(Str, pGzName[i]);
- strcat(Str, "\n");
- }
- if(strfind(inputtext, "0x") == -1 || strlen(inputtext) != 10) return ShowPlayerDialog(playerid, (DialogID + 1), DIALOG_STYLE_INPUT, "GzEditor » By Paulo", Str, "Ok", "Voltar");
- pColor[pGzSave] = StrForHex(inputtext);
- GangZoneHideForPlayer(playerid, pGz[pGzSave]);
- GangZoneShowForPlayer(playerid, pGz[pGzSave], pColor[pGzSave]);
- } else ShowPlayerDialog(playerid, DialogID, DIALOG_STYLE_LIST, "GzEditor » By Paulo", "Criar\nCor\nRefazer\nSalvar\nExcluir\nExportar", "Ok", "Sair");
- } case (DialogID + 5): {
- if(response) {
- if(pGz[pCount] != 0xFFFF) return SendClientMessage(playerid, -1, "Erro: Salve essa Gz Primeiro.");
- GangZoneHideForPlayer(playerid, pGz[listitem]);
- GangZoneDestroy(pGz[listitem]);
- if(listitem != --pCount) {
- pGzName[listitem] = pGzName[pCount];
- pMinX[listitem] = pMinX[pCount];
- pMinY[listitem] = pMinY[pCount];
- pMaxX[listitem] = pMaxX[pCount];
- pMaxY[listitem] = pMaxY[pCount];
- pColor[listitem] = pColor[pCount];
- GangZoneHideForPlayer(playerid, pGz[pCount]);
- GangZoneDestroy(pGz[pCount]);
- pGzName[pCount] = pGzName[(pCount + 1)];
- pGz[pCount] = 0xFFFF;
- pMinX[pCount] = 0.0;
- pMinY[pCount] = 0.0;
- pMaxX[pCount] = 0.0;
- pMaxY[pCount] = 0.0;
- pColor[pCount] = 0xFF0000AA;
- pGz[listitem] = GangZoneCreate(pMinX[listitem], pMinY[listitem], pMaxX[listitem], pMaxY[listitem]);
- GangZoneShowForPlayer(playerid, pGz[listitem], pColor[listitem]);
- } else {
- pGzName[listitem] = pGzName[(listitem + 1)];
- pGz[listitem] = 0xFFFF;
- pMinX[listitem] = 0.0;
- pMinY[listitem] = 0.0;
- pMaxX[listitem] = 0.0;
- pMaxY[listitem] = 0.0;
- pColor[listitem] = 0xFF0000AA;
- }
- SendClientMessage(playerid, -1, "Info: Gz deletada com sucesso!!");
- }
- }
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[]) {
- if(!strcmp(cmdtext, "/gz")) {
- if(pCount == MAX_GZ) return SendClientMessage(playerid, -1, "Erro: Você já criou o Máximo de Gz's, Salve-as para criar mais.");
- return ShowPlayerDialog(playerid, DialogID, DIALOG_STYLE_LIST, "GzEditor » By Paulo", "Criar\nCor\nRefazer\nSalvar\nExcluir\nExportar", "Ok", "Sair");
- }
- return 0;
- }
- public OnPlayerUpdate(playerid) {
- if(pGz[pCount] != 0xFFFF || pEditGz != 0xFFFF) {
- new Float: gX, Float: gY, Float: gZ, i = (pEditGz == 0xFFFF ? pCount : pEditGz);
- GangZoneHideForPlayer(playerid, pGz[i]);
- GangZoneDestroy(pGz[i]);
- GetPlayerPos(playerid, gX, gY, gZ);
- pGz[i] = GangZoneCreate((pX > gX ? gX : pX), (pY > gY ? gY : pY), (pX < gX ? gX : pX), (pY < gY ? gY : pY));
- GangZoneShowForPlayer(playerid, pGz[i], pColor[i]);
- }
- return 1;
- }
- HexForStr(Hex) {
- new Caracters[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }, Var[11] = "0x";
- for (new i = 0; i < 8; ++i) Var[(i + 2)] = Caracters[(Hex >>> ((7 - i) << 2)) & 0x0F];
- return Var;
- }
- StrForHex(Str[]) {
- new i, Hex;
- if(Str[0] == '0' && (Str[1] == 'x' || Str[1] == 'X')) i = 2;
- for(; Str[i]; ++i) {
- Hex <<= 4;
- switch(Str[i]) {
- case '0' .. '9': Hex |= (Str[i] - '0');
- case 'A' .. 'F': Hex |= ((Str[i] - 'A') + 10);
- case 'a' .. 'f': Hex |= ((Str[i] - 'a') + 10);
- default: return 0;
- }
- }
- return Hex;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement