Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include < a_samp >
- #include < ZCMD >
- #include < DOF2 >
- #define MAX_PONTOS 100
- #define iMAX_PONTOS 100
- enum PDATA
- {
- TAG[128],
- PID,
- Text3D:PTEXT3D,
- Float:PPOS[3],
- }
- enum iDATA
- {
- TAG,
- PID,
- IV[2],
- Text3D:PTEXT3D,
- Float:PPOS[3],
- }
- new iPonto[iMAX_PONTOS][iDATA];
- new PPonto[MAX_PONTOS][PDATA];
- new PPontoPermitir = 1;
- public OnFilterScriptInit()
- {
- CarregarPPontos();
- return 1;
- }
- public OnFilterScriptExit()
- {
- DOF2_Exit();
- return 1;
- }
- CMD:criarponto(playerid, params [])
- {
- new opcao, tag[100];
- new Local[100];
- new Texto[100];
- new e = MAX_PONTOS+1;
- new i = iMAX_PONTOS+1;
- if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
- if(sscanf(params, "ds", opcao, tag)) return SendClientMessage(playerid, 0x33AA3300, "<opções = entrada(1), saida(2)><tag = nome>");
- if(opcao == 1)
- {
- if(PPontoPermitir == 1)
- {
- for(new a = 0; a < MAX_PONTOS; a++)
- {
- if(PPonto[a][PPOS][0] == 0.0)
- {
- e = a;
- break;
- }
- }
- PPontoPermitir = 2;
- if(e > MAX_PONTOS) return SendClientMessage(playerid, 0x33AA3300, "Você não pode criar mais.");
- printf("[Porta][1][id = %d]", e);
- SendClientMessage(playerid, 0x33AA3300, "[1][OK]");
- GetPlayerPos(playerid, PPonto[e][PPOS][0], PPonto[e][PPOS][1], PPonto[e][PPOS][2]);
- format(Local, sizeof(Local), "PPontos/Entradas/%d.txt", e);
- DOF2_CreateFile(Local);
- DOF2_SetString(Local, "TAG", tag);
- DOF2_SetFloat(Local, "POS0", PPonto[e][PPOS][0]);
- DOF2_SetFloat(Local, "POS1", PPonto[e][PPOS][1]);
- DOF2_SetFloat(Local, "POS2", PPonto[e][PPOS][2]);
- DOF2_SaveFile();
- format(Texto, sizeof(Texto), "%s\n[%d]\n<saida>",tag, e);
- PPonto[e][PID] = CreatePickup(19198, 1, PPonto[e][PPOS][0], PPonto[e][PPOS][1], PPonto[e][PPOS][2]+0.2, 0);
- PPonto[e][PTEXT3D] = Create3DTextLabel(Texto, -1, PPonto[e][PPOS][0], PPonto[e][PPOS][1], PPonto[e][PPOS][2]-0.2, 5.0, 0);
- }
- else
- {
- SendClientMessage(playerid, 0x33AA3300, "Você ja definio o ponto [1] defina o proximo(2).");
- }
- }
- if(opcao == 2)
- {
- if(PPontoPermitir == 2)
- {
- PPontoPermitir = 1;
- for(new a = 0; a < iMAX_PONTOS; a++)
- {
- if(iPonto[a][PPOS][0] == 0.0)
- {
- i = a;
- break;
- }
- }
- if(i > MAX_PONTOS) return SendClientMessage(playerid, 0x33AA3300, "Você não pode criar mais.");
- printf("[Porta][2][id = %d]",i);
- SendClientMessage(playerid, 0x33AA3300, "[2][OK]");
- GetPlayerPos(playerid, iPonto[i][PPOS][0], iPonto[i][PPOS][1], iPonto[i][PPOS][2]);
- iPonto[i][IV][0] = GetPlayerInterior(playerid);
- iPonto[i][IV][1] = i;
- format(Local, sizeof(Local), "PPontos/Saidas/%d.txt", i);
- DOF2_CreateFile(Local);
- DOF2_SetString(Local, "TAG", tag);
- DOF2_SetFloat(Local, "POS0", iPonto[i][PPOS][0]);
- DOF2_SetFloat(Local, "POS1", iPonto[i][PPOS][1]);
- DOF2_SetFloat(Local, "POS2", iPonto[i][PPOS][2]);
- DOF2_SetInt(Local, "INTERIOR", iPonto[i][IV][0]);
- DOF2_SetInt(Local, "MUNDO", iPonto[i][IV][1]);
- DOF2_SaveFile();
- format(Texto, sizeof(Texto), "%s\n[%d]\n<saida>", tag, i);
- iPonto[i][PID] = CreatePickup(19198, 1, iPonto[i][PPOS][0], iPonto[i][PPOS][1], iPonto[i][PPOS][2]+0.2, iPonto[i][IV][1]);
- iPonto[i][PTEXT3D] = Create3DTextLabel(Texto, -1, iPonto[i][PPOS][0], iPonto[i][PPOS][1], iPonto[i][PPOS][2]-0.2, 5.0, iPonto[i][IV][1]);
- }
- else
- {
- SendClientMessage(playerid, 0x33AA3300, "Você aida não definio o ponto [1], defina-o.");
- }
- }
- return 1;
- }
- CMD:apagarponto(playerid)
- {
- if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 1;
- new f = MAX_PONTOS+1;
- new i = iMAX_PONTOS+1;
- for(new a = 0; a < MAX_PONTOS; a++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 1.0, PPonto[a][PPOS][0], PPonto[a][PPOS][1], PPonto[a][PPOS][2]))
- {
- f = a;
- break;
- }
- }
- for(new a = 0; a < iMAX_PONTOS; a++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 1.0, PPonto[a][PPOS][0], PPonto[a][PPOS][1], PPonto[a][PPOS][2]))
- {
- i = a;
- break;
- }
- }
- if(f > MAX_PONTOS) return SendClientMessage(playerid, 0x33AA3300, "Fique acima da porta principal para apagar.");
- DestroyPickup(PPonto[f][PID]);
- Delete3DTextLabel(PPonto[f][PTEXT3D]);
- DestroyPickup(iPonto[i][PID]);
- Delete3DTextLabel(iPonto[i][PTEXT3D]);
- PPonto[f][PPOS][0] = 0.0;
- PPonto[f][PPOS][1] = 0.0;
- PPonto[f][PPOS][2] = 0.0;
- iPonto[i][PPOS][0] = 0.0;
- iPonto[i][PPOS][1] = 0.0;
- iPonto[i][PPOS][2] = 0.0;
- iPonto[i][IV][0] = 0;
- iPonto[i][IV][1] = 0;
- new Local[100];
- format(Local, sizeof(Local), "PPontos/Entradas/%d.txt", f);
- DOF2_RemoveFile(Local);
- format(Local, sizeof(Local), "PPontos/Saidas/%d.txt", i);
- DOF2_RemoveFile(Local);
- f = -1;
- return 1;
- }
- CMD:entrar(playerid)
- {
- new f = MAX_PONTOS+1;
- for(new a = 0; a < MAX_PONTOS; a++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 1.0, PPonto[a][PPOS][0], PPonto[a][PPOS][1], PPonto[a][PPOS][2]))
- {
- f = a;
- break;
- }
- }
- if(f > MAX_PONTOS) return 1;
- SetPlayerInterior(playerid, iPonto[f][IV][0]);
- SetPlayerVirtualWorld(playerid, iPonto[f][IV][1]);
- SetPlayerPos(playerid, iPonto[f][PPOS][0], iPonto[f][PPOS][1], iPonto[f][PPOS][2]);
- return 1;
- }
- CMD:sair(playerid)
- {
- new i = iMAX_PONTOS+1;
- for(new a = 0; a < iMAX_PONTOS; a++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 1.0, iPonto[a][PPOS][0], iPonto[a][PPOS][1], iPonto[a][PPOS][2]))
- {
- i = a;
- break;
- }
- }
- if(i > MAX_PONTOS) return 1;
- if(GetPlayerVirtualWorld(playerid) == i)
- {
- SetPlayerPos(playerid, PPonto[i][PPOS][0], PPonto[i][PPOS][1], PPonto[i][PPOS][2]);
- SetPlayerInterior(playerid, 0);
- SetPlayerVirtualWorld(playerid, 0);
- }
- return 1;
- }
- stock CarregarPPontos()
- {
- new Local[100];
- new Texto[100];
- for(new pontoid; pontoid < MAX_PONTOS; pontoid++)
- {
- format(Local, sizeof(Local), "PPontos/Entradas/%d.txt", pontoid);
- if(DOF2_FileExists(Local))
- {
- PPonto[pontoid][PPOS][0] = DOF2_GetFloat(Local, "POS0");
- PPonto[pontoid][PPOS][1] = DOF2_GetFloat(Local, "POS1");
- PPonto[pontoid][PPOS][2] = DOF2_GetFloat(Local, "POS2");
- format(PPonto[pontoid][TAG], 128, DOF2_GetString(Local, "TAG"));
- format(Texto, sizeof(Texto), "%s\n[%d]\n<entrada>", PPonto[pontoid][TAG], pontoid);
- PPonto[pontoid][PID] = CreatePickup(19198, 1, PPonto[pontoid][PPOS][0], PPonto[pontoid][PPOS][1], PPonto[pontoid][PPOS][2]+0.2, 0);
- PPonto[pontoid][PTEXT3D] = Create3DTextLabel(Texto, -1, PPonto[pontoid][PPOS][0], PPonto[pontoid][PPOS][1], PPonto[pontoid][PPOS][2]-0.2, 5.0, 0);
- printf("[ENTRADA] %s [%d]", PPonto[pontoid][TAG], pontoid);
- }
- }
- for(new pontoid; pontoid < iMAX_PONTOS; pontoid++)
- {
- format(Local, sizeof(Local), "PPontos/Saidas/%d.txt", pontoid);
- if(DOF2_FileExists(Local))
- {
- iPonto[pontoid][PPOS][0] = DOF2_GetFloat(Local, "POS0");
- iPonto[pontoid][PPOS][1] = DOF2_GetFloat(Local, "POS1");
- iPonto[pontoid][PPOS][2] = DOF2_GetFloat(Local, "POS2");
- iPonto[pontoid][IV][0] = DOF2_GetInt(Local, "INTERIOR");
- iPonto[pontoid][IV][1] = DOF2_GetInt(Local, "MUNDO");
- format(iPonto[pontoid][TAG], 128, DOF2_GetString(Local, "TAG"));
- format(Texto, sizeof(Texto), "%s\n[%d]\n<saida>", iPonto[pontoid][TAG], pontoid);
- iPonto[pontoid][PID] = CreatePickup(19198, 1, iPonto[pontoid][PPOS][0], iPonto[pontoid][PPOS][1], iPonto[pontoid][PPOS][2]+0.2, iPonto[pontoid][IV][1]);
- iPonto[pontoid][PTEXT3D] = Create3DTextLabel(Texto, -1, iPonto[pontoid][PPOS][0], iPonto[pontoid][PPOS][1], iPonto[pontoid][PPOS][2]-0.2, 5.0, iPonto[pontoid][IV][1]);
- printf("[SAIDA] %s [%d]", iPonto[pontoid][TAG], pontoid);
- }
- }
- }
- CMD:teste(playerid)
- {
- SetPlayerPos(playerid, 770.8033, -0.7033, 1000.7267);
- SetPlayerInterior(playerid, 5);
- return 1;
- }
- stock sscanf(string[], format[], {Float,_}:...)
- {
- #if defined isnull
- if (isnull(string))
- #else
- if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
- #endif
- {
- return format[0];
- }
- #pragma tabsize 4
- new
- formatPos = 0,
- stringPos = 0,
- paramPos = 2,
- paramCount = numargs(),
- delim = ' ';
- while (string[stringPos] && string[stringPos] <= ' ')
- {
- stringPos++;
- }
- while (paramPos < paramCount && string[stringPos])
- {
- switch (format[formatPos++])
- {
- case '\0':
- {
- return 0;
- }
- case 'i', 'd':
- {
- new
- neg = 1,
- num = 0,
- ch = string[stringPos];
- if (ch == '-')
- {
- neg = -1;
- ch = string[++stringPos];
- }
- do
- {
- stringPos++;
- if ('0' <= ch <= '9')
- {
- num = (num * 10) + (ch - '0');
- }
- else
- {
- return -1;
- }
- }
- while ((ch = string[stringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num * neg);
- }
- case 'h', 'x':
- {
- new
- num = 0,
- ch = string[stringPos];
- do
- {
- stringPos++;
- switch (ch)
- {
- case 'x', 'X':
- {
- num = 0;
- continue;
- }
- case '0' .. '9':
- {
- num = (num << 4) | (ch - '0');
- }
- case 'a' .. 'f':
- {
- num = (num << 4) | (ch - ('a' - 10));
- }
- case 'A' .. 'F':
- {
- num = (num << 4) | (ch - ('A' - 10));
- }
- default:
- {
- return -1;
- }
- }
- }
- while ((ch = string[stringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num);
- }
- case 'c':
- {
- setarg(paramPos, 0, string[stringPos++]);
- }
- case 'f':
- {
- new changestr[16], changepos = 0, strpos = stringPos;
- while(changepos < 16 && string[strpos] && string[strpos] != delim)
- {
- changestr[changepos++] = string[strpos++];
- }
- changestr[changepos] = '\0';
- setarg(paramPos,0,_:floatstr(changestr));
- }
- case 'p':
- {
- delim = format[formatPos++];
- continue;
- }
- case '\'':
- {
- new
- end = formatPos - 1,
- ch;
- while ((ch = format[++end]) && ch != '\'') {}
- if (!ch)
- {
- return -1;
- }
- format[end] = '\0';
- if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
- {
- if (format[end + 1])
- {
- return -1;
- }
- return 0;
- }
- format[end] = '\'';
- stringPos = ch + (end - formatPos);
- formatPos = end + 1;
- }
- case 'u':
- {
- new
- end = stringPos - 1,
- id = 0,
- bool:num = true,
- ch;
- while ((ch = string[++end]) && ch != delim)
- {
- if (num)
- {
- if ('0' <= ch <= '9')
- {
- id = (id * 10) + (ch - '0');
- }
- else
- {
- num = false;
- }
- }
- }
- if (num && IsPlayerConnected(id))
- {
- setarg(paramPos, 0, id);
- }
- else
- {
- #if !defined foreach
- #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
- #define __SSCANF_FOREACH__
- #endif
- string[end] = '\0';
- num = false;
- new
- name[MAX_PLAYER_NAME];
- id = end - stringPos;
- foreach (Player, playerid)
- {
- GetPlayerName(playerid, name, sizeof (name));
- if (!strcmp(name, string[stringPos], true, id))
- {
- setarg(paramPos, 0, playerid);
- num = true;
- break;
- }
- }
- if (!num)
- {
- setarg(paramPos, 0, INVALID_PLAYER_ID);
- }
- string[end] = ch;
- #if defined __SSCANF_FOREACH__
- #undef foreach
- #undef __SSCANF_FOREACH__
- #endif
- }
- stringPos = end;
- }
- case 's', 'z':
- {
- new
- i = 0,
- ch;
- if (format[formatPos])
- {
- while ((ch = string[stringPos++]) && ch != delim)
- {
- setarg(paramPos, i++, ch);
- }
- if (!i)
- {
- return -1;
- }
- }
- else
- {
- while ((ch = string[stringPos++]))
- {
- setarg(paramPos, i++, ch);
- }
- }
- stringPos--;
- setarg(paramPos, i, '\0');
- }
- default:
- {
- continue;
- }
- }
- while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
- {
- stringPos++;
- }
- while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
- {
- stringPos++;
- }
- paramPos++;
- }
- do
- {
- if ((delim = format[formatPos++]) > ' ')
- {
- if (delim == '\'')
- {
- while ((delim = format[formatPos++]) && delim != '\'') {}
- }
- else if (delim != 'z')
- {
- return delim;
- }
- }
- }
- while (delim > ' ');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment