Hey, so I wanted to ask something.
if I have a line, and I'd like to add another "Text" to the line by a command. like /givetrusted and it will be added to stats as - " Your stats ( Trusted Player ) " and for the default it will show only " Your stats ". |
First of all create something like pIsTrusted in the players enum then make that command to switch between the variable.
Now to the actual question, When showing the stats use strcat to stick two strings together. |
#include <a_samp>
#include <sscanf2>
#include <zcmd>
enum pinfo
{
bool:pTrusted
}
new PlayerInfo[MAX_PLAYERS][pinfo];
// Loop
#define MaxLoop(%0) \
for(new %0 = 0, _%0 = GetPlayerPoolSize(); %0 <= _%0, IsPlayerConnected(%0); %0++)
// Get Player name
stock pName(playerid)
{
new PlayerName[MAX_PLAYERS][MAX_PLAYER_NAME];
GetPlayerName(playerid,PlayerName[playerid],MAX_PLAYER_NAME);
new string[64];
format(string, 64, "%s (%d)", PlayerName[playerid], playerid);
return string;
}
CMD:trust(playerid, params[]) // Trust your desired id
{
new id,str[250];
if (sscanf(params, "u", id)) return SendClientMessage(playerid, 0xFF0000FF, "- Error - USAGE: /Trust [ID]");
if(!IsPlayerConnected(id))return SendClientMessage(playerid, 0xFF0000FF, "- Error - Player is not connected!");
PlayerInfo[id][pTrusted] = true;
if(id != playerid)
format(str,sizeof(str),"- Admin Action - Congrats you have been added in trusted list by Admin %s",pName(playerid));
SendClientMessage(id, 0x00FF00FF, str);
format(str, sizeof(str), "- Admin Action - You have promoted %s to trusted member.", pName(id));
SendClientMessage(playerid, 0x00FF00FF, str);
return 1;
}
CMD:trusted(playerid,params[]) // Check the trusted faggots
{
new str[250];
new itrust=0;
MaxLoop(x)
{
if(IsPlayerConnected(x) && PlayerInfo[x][pTrusted] == true)
{
SendClientMessage(playerid,0x8C8C8CFF,"Trusted Players List");
format(str,sizeof(str),"%s\n",pName(x));
SendClientMessage(playerid,0x8C8C8CFF,str);
itrust++;
}
}
return 1;
}
public OnPlayerConnect(playerid)
{
PlayerInfo[playerid][pTrusted] = false; // put this line before mysql_tquery and mysql_format
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
PlayerInfo[playerid][pTrusted] = false; // clear the boolean
return 1;
}
public OnPlayerText(playerid, text[])
{
if(text[0] == '!' && (strlen(text) > 1))
{
strdel(text, 0, 1);
new str[144];
format(str,sizeof(str),"Trusted Chat: %s: %s",pName(playerid),text); // trusted maggots chat
MaxLoop(x)
{
if(PlayerInfo[x][pTrusted] == true)
{
SendClientMessage(x,0x1AFF00FF,str);
}
}
}
return 0;
}
PHP код:
|
ShowStatsForPlayer(playerid, targetid)
{
new
account[24],
origin[32],
string[128],
count;
for (new i = 0; i < MAX_INVENTORY; i ++) if (InventoryData[playerid][i][invExists]) {
count++;
}
if (PlayerData[targetid][pAdmin] > 0) account = "Admin";
else if (PlayerData[targetid][pTester] > 0) account = "Tester";
else account = "Player";
format(origin, 32, "%.16s", PlayerData[targetid][pOrigin]);
if (strlen(PlayerData[targetid][pOrigin]) > 16)
strcat(origin, "...");
/*---------------------------------------------------------------------------------- pTrusted */
SendClientMessage(playerid, COLOR_NICEYELLOW, " Your Stats (XXXXXX)");
format(string, sizeof(string), "| Sex: %s | Birthdate: %s | Origin: %s | PayCheck: %d", (PlayerData[targetid][pGender] == 2) ? ("Female") : ("Male"), PlayerData[targetid][pBirthdate], origin,PlayerData[playerid][pMinutes]);
SendClientMessage(playerid, COLOR_NICEBLUE, string);
format(string, sizeof(string), "| Hours: %d | Job: %s | Inventory: %d/%d | Ping: %d | Hunger: %d% | Thirst: %d%", PlayerData[targetid][pPlayingHours], Job_GetName(PlayerData[targetid][pJob]), count, MAX_INVENTORY, GetPlayerPing(targetid),PlayerData[playerid][pHunger], PlayerData[playerid][pThirst]);
SendClientMessage(playerid, COLOR_NICEBLUE, string);
format(string, sizeof(string), "| Money: %s | Bank: %s | Savings: %s | Packet Loss: %.1f%%", FormatNumber(PlayerData[targetid][pMoney]), FormatNumber(PlayerData[targetid][pBankMoney]), FormatNumber(PlayerData[targetid][pSavings]), NetStats_PacketLossPercent(targetid));
SendClientMessage(playerid, COLOR_NICEBLUE, string);
format(string, sizeof(string), "| Account: %s | Tester: %s | Admin: %s", account, (PlayerData[targetid][pTester]) ? ("Yes") : ("No"), (PlayerData[targetid][pAdmin]) ? ("Yes") : ("No"));
SendClientMessage(playerid, COLOR_NICEBLUE, string);
/*if (!PlayerData[playerid][pDisplayStats])
{
if (targetid != playerid)
{
for (new i = 40; i < 50; i ++) if (i != 47 && i != 48) {
PlayerTextDrawShow(playerid, PlayerData[playerid][pTextdraws][i]);
}
}
else for (new i = 40; i < 50; i ++) {
PlayerTextDrawShow(playerid, PlayerData[playerid][pTextdraws][i]);
}
SelectTextDraw(playerid, -1);
PlayerData[playerid][pDisplayStats] = true;
}
else
{
if (PlayerData[playerid][pDisplayStats] == 2) {
for (new i = 50; i < 58; i ++) PlayerTextDrawHide(playerid, PlayerData[playerid][pTextdraws][i]);
}
else for (new i = 40; i < 50; i ++) {
PlayerTextDrawHide(playerid, PlayerData[playerid][pTextdraws][i]);
}
CancelSelectTextDraw(playerid);
PlayerData[playerid][pDisplayStats] = false;*/
// }
return 1;
}
ShowStatsForPlayer(playerid, targetid)
{
new
account[24],
origin[32],
string[128],
count;
for (new i = 0; i < MAX_INVENTORY; i ++) if (InventoryData[playerid][i][invExists]) {
count++;
}
if (PlayerData[targetid][pAdmin] > 0) account = "Admin";
else if (PlayerData[targetid][pTester] > 0) account = "Tester";
else if (PlayerData[targetid][pTrusted] == true) account = "Trusted Player"; // i added this
else account = "Player";
format(origin, 32, "%.16s", PlayerData[targetid][pOrigin]);
if (strlen(PlayerData[targetid][pOrigin]) > 16)
strcat(origin, "...");
/*---------------------------------------------------------------------------------- pTrusted */
SendClientMessage(playerid, COLOR_NICEYELLOW, " Your Stats (XXXXXX)");
format(string, sizeof(string), "| Sex: %s | Birthdate: %s | Origin: %s | PayCheck: %d", (PlayerData[targetid][pGender] == 2) ? ("Female") : ("Male"), PlayerData[targetid][pBirthdate], origin,PlayerData[playerid][pMinutes]);
SendClientMessage(playerid, COLOR_NICEBLUE, string);
format(string, sizeof(string), "| Hours: %d | Job: %s | Inventory: %d/%d | Ping: %d | Hunger: %d% | Thirst: %d%", PlayerData[targetid][pPlayingHours], Job_GetName(PlayerData[targetid][pJob]), count, MAX_INVENTORY, GetPlayerPing(targetid),PlayerData[playerid][pHunger], PlayerData[playerid][pThirst]);
SendClientMessage(playerid, COLOR_NICEBLUE, string);
format(string, sizeof(string), "| Money: %s | Bank: %s | Savings: %s | Packet Loss: %.1f%%", FormatNumber(PlayerData[targetid][pMoney]), FormatNumber(PlayerData[targetid][pBankMoney]), FormatNumber(PlayerData[targetid][pSavings]), NetStats_PacketLossPercent(targetid));
SendClientMessage(playerid, COLOR_NICEBLUE, string);
format(string, sizeof(string), "| Account: %s | Tester: %s | Admin: %s", account, (PlayerData[targetid][pTester]) ? ("Yes") : ("No"), (PlayerData[targetid][pAdmin]) ? ("Yes") : ("No"));
SendClientMessage(playerid, COLOR_NICEBLUE, string);
/*if (!PlayerData[playerid][pDisplayStats])
{
if (targetid != playerid)
{
for (new i = 40; i < 50; i ++) if (i != 47 && i != 48) {
PlayerTextDrawShow(playerid, PlayerData[playerid][pTextdraws][i]);
}
}
else for (new i = 40; i < 50; i ++) {
PlayerTextDrawShow(playerid, PlayerData[playerid][pTextdraws][i]);
}
SelectTextDraw(playerid, -1);
PlayerData[playerid][pDisplayStats] = true;
}
else
{
if (PlayerData[playerid][pDisplayStats] == 2) {
for (new i = 50; i < 58; i ++) PlayerTextDrawHide(playerid, PlayerData[playerid][pTextdraws][i]);
}
else for (new i = 40; i < 50; i ++) {
PlayerTextDrawHide(playerid, PlayerData[playerid][pTextdraws][i]);
}
CancelSelectTextDraw(playerid);
PlayerData[playerid][pDisplayStats] = false;*/
// }
return 1;
}
PHP код:
|
format(string, sizeof(string), " Your Stats (Status: %s)", PlayerData[targetid][pTrusted]);
SendClientMessage(playerid, COLOR_NICEYELLOW, string);
//REST OF CODE
new string[25] = "Player Stats"; //Or you can use format or strcpy.
if(PlayerInfo[targetid][pTrusted])
strcat(string, " [TRUSTED]");
//CONTINUE /stats CODE HERE.