Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-------------------------------------------------
- //
- // Player Labels (/pl) filterscript; Now allow players to view other player statics from 3D labels
- // Just relevant to /dl (default cmd by SAMP)
- //
- // Gammix 2015
- // Thanks Incognito for streamer plugin
- // Thanks Zeex for zcmd include
- //
- //-------------------------------------------------
- #define FILTERSCRIPT//
- //-------------------------------------------------
- #include <a_samp>
- #include <streamer>
- #include <zcmd>
- //-------------------------------------------------
- //labels configuration
- #define LABEL_COLOR 0x20B2AAFF//light sea green
- #define LABEL_DRAW_DISTANCE 40.0
- #define LABEL_STREAM_DISTANCE 100.0
- #define LABEL_STRING_SIZE 256
- //-------------------------------------------------
- enum PlayerLabelEnum
- {
- bool:E_LABEL_TOGGLED,
- Text3D:E_3D_TEXT_LABEL[MAX_PLAYERS],
- Float:E_POS[3],
- E_WEAPON,
- Float:E_HEALTH,
- Float:E_ARMOUR,
- E_MONEY,
- E_SCORE,
- E_PING
- }
- new gPlayerLabel[MAX_PLAYERS][PlayerLabelEnum];
- //-------------------------------------------------
- stock GetWeaponNameEx(weaponid, weapon[], len = sizeof(weapon))
- {
- switch(weaponid)
- {
- case 0: return strcat(weapon, "Fist", len);
- case 18: return strcat(weapon, "Molotov Cocktail", len);
- case 44: return strcat(weapon, "Night Vision Goggles", len);
- case 45: return strcat(weapon, "Thermal Goggles", len);
- default: return GetWeaponName(weaponid, weapon, len);
- }
- return false;
- }
- SetLabelString(string[], playerid, extraid, len = sizeof(string))
- {
- new Float:player_hp;
- GetPlayerHealth(extraid, player_hp);
- new Float:player_ar;
- GetPlayerArmour(extraid, player_ar);
- new Float:player_distance;
- player_distance = GetPlayerDistanceFromPoint(playerid, gPlayerLabel[extraid][E_POS][0], gPlayerLabel[extraid][E_POS][1], gPlayerLabel[extraid][E_POS][2]);
- new player_weapon[32];
- GetWeaponNameEx(GetPlayerWeapon(extraid), player_weapon, sizeof(player_weapon));
- new Float:player_angle;
- GetPlayerFacingAngle(playerid, player_angle);
- format( string,//puttins the values into the string
- len,
- "[id: %i, health: %0.2f, armour: %0.2f, ping: %i]\n\
- skin: %i, team: %i, money: $%i, score: %i\n\
- distance: %0.2f\n\
- weapon: %s (%i), ammo: %i\n\
- interior: %i, world: %i\n\
- pos: %0.4f, %0.4f, %0.4f, %0.4f",
- playerid, player_hp, player_ar, GetPlayerPing(extraid),
- GetPlayerSkin(extraid), GetPlayerTeam(extraid), GetPlayerMoney(extraid), GetPlayerScore(extraid),
- player_distance,
- player_weapon, GetPlayerWeapon(extraid), GetPlayerAmmo(extraid),
- GetPlayerInterior(extraid), GetPlayerVirtualWorld(extraid),
- gPlayerLabel[extraid][E_POS][0], gPlayerLabel[extraid][E_POS][1], gPlayerLabel[extraid][E_POS][2], player_angle
- );
- }
- UpdatePlayersLabels(ofplayerid)
- {
- new string[LABEL_STRING_SIZE];
- for(new i; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(gPlayerLabel[i][E_LABEL_TOGGLED])
- {
- if(i != ofplayerid)
- {
- SetLabelString(string, i, ofplayerid, sizeof(string));
- UpdateDynamic3DTextLabelText(gPlayerLabel[i][E_3D_TEXT_LABEL][ofplayerid], LABEL_COLOR, string);
- }
- }
- }
- }
- }
- //-------------------------------------------------
- public OnPlayerConnect(playerid)
- {
- gPlayerLabel[playerid][E_LABEL_TOGGLED] = false;
- gPlayerLabel[playerid][E_WEAPON] = 0;
- gPlayerLabel[playerid][E_HEALTH] = 0.0;
- gPlayerLabel[playerid][E_ARMOUR] = 0.0;
- GetPlayerPos(playerid, gPlayerLabel[playerid][E_POS][0], gPlayerLabel[playerid][E_POS][1], gPlayerLabel[playerid][E_POS][2]);
- new string[LABEL_STRING_SIZE];
- for(new i; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(i != playerid)
- {
- SetLabelString(string, playerid, i, sizeof(string));
- gPlayerLabel[i][E_3D_TEXT_LABEL][playerid] = CreateDynamic3DTextLabel(string, LABEL_COLOR, 0.0, 0.0, 0.0, LABEL_DRAW_DISTANCE, i, _, 0, _, _, playerid, LABEL_STREAM_DISTANCE);
- }
- }
- }
- return 1;
- }
- //-------------------------------------------------
- public OnPlayerDisconnect(playerid, reason)
- {
- for(new i; i < MAX_PLAYERS; i++)//destroy the labels if any
- {
- if(IsValidDynamic3DTextLabel(gPlayerLabel[playerid][E_3D_TEXT_LABEL][i]))
- {
- DestroyDynamic3DTextLabel(gPlayerLabel[playerid][E_3D_TEXT_LABEL][i]);
- }
- }
- for(new i; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(gPlayerLabel[i][E_LABEL_TOGGLED])
- {
- if(i != playerid)
- {
- DestroyDynamic3DTextLabel(gPlayerLabel[i][E_3D_TEXT_LABEL][playerid]);
- }
- }
- }
- }
- return 1;
- }
- //-------------------------------------------------
- public OnPlayerSpawn(playerid)
- {
- GetPlayerPos(playerid, gPlayerLabel[playerid][E_POS][0], gPlayerLabel[playerid][E_POS][1], gPlayerLabel[playerid][E_POS][2]);
- gPlayerLabel[playerid][E_WEAPON] = GetPlayerWeapon(playerid);
- GetPlayerHealth(playerid, gPlayerLabel[playerid][E_HEALTH]);
- GetPlayerArmour(playerid, gPlayerLabel[playerid][E_ARMOUR]);
- gPlayerLabel[playerid][E_MONEY] = GetPlayerMoney(playerid);
- gPlayerLabel[playerid][E_SCORE] = GetPlayerScore(playerid);
- gPlayerLabel[playerid][E_PING] = GetPlayerPing(playerid);
- UpdatePlayersLabels(playerid);
- return 1;
- }
- //-------------------------------------------------
- public OnPlayerUpdate(playerid)
- {
- new Float:player_hp;
- GetPlayerHealth(playerid, player_hp);
- new Float:player_ar;
- GetPlayerArmour(playerid, player_ar);
- new Float:new_player_pos[3];
- GetPlayerPos(playerid, new_player_pos[0], new_player_pos[1], new_player_pos[2]);
- if( new_player_pos[0] != gPlayerLabel[playerid][E_POS][0] ||
- new_player_pos[1] != gPlayerLabel[playerid][E_POS][1] ||
- new_player_pos[2] != gPlayerLabel[playerid][E_POS][2] ||// OnPlayerPosUpdate
- gPlayerLabel[playerid][E_WEAPON] != GetPlayerWeapon(playerid) ||// OnPlayerswitchWeapon
- gPlayerLabel[playerid][E_HEALTH] != player_hp ||//OnPlayerHealthChange
- gPlayerLabel[playerid][E_ARMOUR] != player_ar ||//OnPlayerArmourChange
- gPlayerLabel[playerid][E_MONEY] != GetPlayerMoney(playerid) ||//OnPlayerMoneyChange
- gPlayerLabel[playerid][E_SCORE] != GetPlayerScore(playerid) ||//OnPlayerScoreChange
- gPlayerLabel[playerid][E_PING] != GetPlayerPing(playerid))//OnPlayerPingChange
- {
- //update player data to new one !
- GetPlayerPos(playerid, gPlayerLabel[playerid][E_POS][0], gPlayerLabel[playerid][E_POS][1], gPlayerLabel[playerid][E_POS][2]);
- gPlayerLabel[playerid][E_WEAPON] = GetPlayerWeapon(playerid);
- GetPlayerHealth(playerid, gPlayerLabel[playerid][E_HEALTH]);
- GetPlayerArmour(playerid, gPlayerLabel[playerid][E_ARMOUR]);
- gPlayerLabel[playerid][E_MONEY] = GetPlayerMoney(playerid);
- gPlayerLabel[playerid][E_SCORE] = GetPlayerScore(playerid);
- gPlayerLabel[playerid][E_PING] = GetPlayerPing(playerid);
- UpdatePlayersLabels(playerid);
- }
- return 1;
- }
- //-------------------------------------------------
- public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
- {
- UpdatePlayersLabels(playerid);
- return 1;
- }
- //-------------------------------------------------
- public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
- {
- UpdatePlayersLabels(playerid);
- return 1;
- }
- //-------------------------------------------------
- CMD:pl(playerid)
- {
- if(! gPlayerLabel[playerid][E_LABEL_TOGGLED])//enable labels
- {
- new string[LABEL_STRING_SIZE];
- for(new i; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(i != playerid)
- {
- SetLabelString(string, playerid, i, sizeof(string));
- gPlayerLabel[playerid][E_3D_TEXT_LABEL][i] = CreateDynamic3DTextLabel(string, LABEL_COLOR, 0.0, 0.0, 0.0, LABEL_DRAW_DISTANCE, i, _, _, _, _, playerid, LABEL_STREAM_DISTANCE);
- }
- }
- }
- }
- else//disable labels
- {
- for(new i; i < MAX_PLAYERS; i++)
- {
- if(IsValidDynamic3DTextLabel(gPlayerLabel[playerid][E_3D_TEXT_LABEL][i]))
- {
- DestroyDynamic3DTextLabel(gPlayerLabel[playerid][E_3D_TEXT_LABEL][i]);
- }
- }
- }
- gPlayerLabel[playerid][E_LABEL_TOGGLED] = ! gPlayerLabel[playerid][E_LABEL_TOGGLED];
- return 1;
- }
- //-------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement