Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define FILTERSCRIPT
- // Change me: total number of players that can be on your server
- #define TOTAL_PLAYER_SLOTS 50
- new
- Text:Players[TOTAL_PLAYER_SLOTS],
- Text:You[TOTAL_PLAYER_SLOTS],
- bool:PlayerScan[TOTAL_PLAYER_SLOTS];
- public OnFilterScriptInit()
- {
- SetTimer("UpdateScan", 1000, 0);
- return 0;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext, "/scan", true))
- {
- PlayerScan[playerid] = !PlayerScan[playerid];
- return 1;
- }
- return 0;
- }
- forward UpdateScan();
- public UpdateScan()
- {
- new
- i,
- j,
- Float:x,
- Float:y,
- Float:z,
- name[MAX_PLAYER_NAME],
- strname[MAX_PLAYER_NAME + 1];
- // Clear the textdraws in a separate loop
- // Clearing them in the same one that creates them may cause bugs
- for(; i < TOTAL_PLAYER_SLOTS; ++i)
- {
- TextDrawHideForAll(Players[i]);
- TextDrawHideForAll(You[i]);
- TextDrawDestroy(Players[i]);
- TextDrawDestroy(You[i]);
- }
- for(i = 0; i < TOTAL_PLAYER_SLOTS; ++i)
- if(IsPlayerConnected(i))
- {
- GetPlayerPos(i, x, y, z);
- GetPlayerName(i, name, MAX_PLAYER_NAME);
- format(strname, MAX_PLAYER_NAME + 1, ".%s", name);
- // Math time
- // If players go beyond the given boundaries, use the default coordinates
- x = ((x < -3000.0) ? -2975.0 : x);
- x = ((x > 2500.0) ? 2500.0 : x);
- y = ((y < -2500.0) ? -2500.0 : y);
- y = ((y > 3000.0) ? 2975.0 : y);
- // Convert from a 3000x3000 coordinate 4-quadrant graph
- // To a single 6000x6000 graph
- x = ((x < 0) ? (3000.0 - floatabs(x)) : (x + 3000.0));
- y = ((y < 0) ? (3000.0 + floatabs(y)) : (3000.0 - y));
- // Scale the coordinates to fit the screen
- x /= 9.375;
- y /= 12.5;
- // Set up the textdraws
- Players[i] = TextDrawCreate(x, y, strname);
- TextDrawAlignment(Players[i],0);
- TextDrawBackgroundColor(Players[i],(IsPlayerNPC(i) ? 0x660000ff : 0x000000ff));
- TextDrawFont(Players[i],1);
- TextDrawLetterSize(Players[i],0.3, 0.4);
- TextDrawColor(Players[i],0xffffffff);
- TextDrawSetOutline(Players[i],1);
- TextDrawSetProportional(Players[i],1);
- TextDrawSetShadow(Players[i],10);
- for(j = 0; j < TOTAL_PLAYER_SLOTS; ++j)
- if(PlayerScan[j])
- {
- if(j != i)
- TextDrawShowForPlayer(j, Players[i]);
- else
- {
- You[j] = TextDrawCreate(x, y, strname);
- TextDrawAlignment(You[j],0);
- TextDrawBackgroundColor(You[j],0xffffffff);
- TextDrawFont(You[j],1);
- TextDrawLetterSize(You[j],0.3, 0.4);
- TextDrawColor(You[j],0x000000ff);
- TextDrawSetOutline(You[j],1);
- TextDrawSetProportional(You[j],1);
- TextDrawSetShadow(You[j],10);
- TextDrawShowForPlayer(j, You[j]);
- }
- }
- }
- return SetTimer("UpdateScan", 1000, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment