[SOLVED] ShowStats
#1

Hello again, just got a question about my ShowStats.

I got places where I want it to say "Yes or No" instead of just 1 or 0.

Hehe I've been trying to make it for my VIP Member script:

Код:
public ShowStats(playerid,targetid)
{
  if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
	{
	  new string[256];
 		new admin = PlayerInfo[playerid][pAdminLevel];
	  new VIP = PlayerInfo[playerid][pVIPMember];
	  new laerank = PlayerInfo[playerid][pLAERank];
	  new roleplay = PlayerInfo[playerid][pRoleplay];
	  new cash = GetPlayerMoney(targetid);
	  new bank = PlayerInfo[playerid][pBank];
	  new car = PlayerInfo[playerid][pCarLic];
	  new gun = PlayerInfo[playerid][pGunLic];
		new name[MAX_PLAYER_NAME];
		GetPlayerName(targetid, name, sizeof(name));
		new Float:px,Float:py,Float:pz;
		GetPlayerPos(targetid, px, py, pz);
		new coordsstring[256];
		format(coordsstring, sizeof(coordsstring),"Your Stats");
  	SendClientMessage(playerid, COLOR_YELLOW,coordsstring);
		format(coordsstring, sizeof(coordsstring), "OOC: | Admin Level: %d | VIP Member: %d | LAE Rank: %d | Roleplay Points: %d |", admin, VIP, laerank, roleplay);
		SendClientMessage(playerid, COLOR_GREY,coordsstring);
		format(coordsstring, sizeof(coordsstring), "IC: | Cash: $%d | Bank: $%d | Driving License: %d | Firearm License: %d |", cash, bank, car, gun);
		SendClientMessage(playerid, COLOR_GREY,coordsstring);
		if(PlayerInfo[playerid][pVIPMember] == 1) VIP = "Yes";
		else if(PlayerInfo[playerid][pVIPMember] == 0) VIP = "No";
	}
}
I get this error:

Код:
must be assigned to an array
On the if and else if.

Thanks
Reply
#2

Try this:

pawn Код:
public ShowStats(playerid,targetid)
{
  if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
    {
      new string[256],VIP2[10];
        new admin = PlayerInfo[playerid][pAdminLevel];
      new VIP = PlayerInfo[playerid][pVIPMember];
      new laerank = PlayerInfo[playerid][pLAERank];
      new roleplay = PlayerInfo[playerid][pRoleplay];
      new cash = GetPlayerMoney(targetid);
      new bank = PlayerInfo[playerid][pBank];
      new car = PlayerInfo[playerid][pCarLic];
      new gun = PlayerInfo[playerid][pGunLic];
        new name[MAX_PLAYER_NAME];
        GetPlayerName(targetid, name, sizeof(name));
        new Float:px,Float:py,Float:pz;
        GetPlayerPos(targetid, px, py, pz);
        new coordsstring[256];
        format(coordsstring, sizeof(coordsstring),"Your Stats");
    SendClientMessage(playerid, COLOR_YELLOW,coordsstring);
        format(coordsstring, sizeof(coordsstring), "OOC: | Admin Level: %d | VIP Member: %d | LAE Rank: %d | Roleplay Points: %d |", admin, VIP, laerank, roleplay);
        SendClientMessage(playerid, COLOR_GREY,coordsstring);
        format(coordsstring, sizeof(coordsstring), "IC: | Cash: $%d | Bank: $%d | Driving License: %d | Firearm License: %d |", cash, bank, car, gun);
        SendClientMessage(playerid, COLOR_GREY,coordsstring);
        if(PlayerInfo[playerid][pVIPMember] == 1) VIP2 = "Yes";
        else if(PlayerInfo[playerid][pVIPMember] == 0) VIP2 = "No";
    }
}
Should work.
Reply
#3

Quote:
Originally Posted by Jeffry
Try this:

pawn Код:
public ShowStats(playerid,targetid)
{
  if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
    {
      new string[256],VIP2[10];
        new admin = PlayerInfo[playerid][pAdminLevel];
      new VIP = PlayerInfo[playerid][pVIPMember];
      new laerank = PlayerInfo[playerid][pLAERank];
      new roleplay = PlayerInfo[playerid][pRoleplay];
      new cash = GetPlayerMoney(targetid);
      new bank = PlayerInfo[playerid][pBank];
      new car = PlayerInfo[playerid][pCarLic];
      new gun = PlayerInfo[playerid][pGunLic];
        new name[MAX_PLAYER_NAME];
        GetPlayerName(targetid, name, sizeof(name));
        new Float:px,Float:py,Float:pz;
        GetPlayerPos(targetid, px, py, pz);
        new coordsstring[256];
        format(coordsstring, sizeof(coordsstring),"Your Stats");
    SendClientMessage(playerid, COLOR_YELLOW,coordsstring);
        format(coordsstring, sizeof(coordsstring), "OOC: | Admin Level: %d | VIP Member: %d | LAE Rank: %d | Roleplay Points: %d |", admin, VIP, laerank, roleplay);
        SendClientMessage(playerid, COLOR_GREY,coordsstring);
        format(coordsstring, sizeof(coordsstring), "IC: | Cash: $%d | Bank: $%d | Driving License: %d | Firearm License: %d |", cash, bank, car, gun);
        SendClientMessage(playerid, COLOR_GREY,coordsstring);
        if(PlayerInfo[playerid][pVIPMember] == 1) VIP2 = "Yes";
        else if(PlayerInfo[playerid][pVIPMember] == 0) VIP2 = "No";
    }
}
Should work.
Sorry, is still just shows 0 or 1.
Reply
#4

pawn Код:
format(string, sizeof string, "VIP Member: %s", (PlayerInfo[playerid][pVIPMember])?("Yes"):("No"));
or

pawn Код:
new
        No_or_Yes[][] = { "No", "Yes" };
    format(string, sizeof string, "VIP Member: %s", No_or_Yes[PlayerInfo[playerid][pVIPMember]]);
Reply
#5

Quote:
Originally Posted by FreddeN
Sorry, is still just shows 0 or 1.
You need to put the if and else if over the message.

pawn Код:
public ShowStats(playerid,targetid)
{
  if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
    {
      new string[256],VIP2[10];
        new admin = PlayerInfo[playerid][pAdminLevel];
      new VIP = PlayerInfo[playerid][pVIPMember];
      new laerank = PlayerInfo[playerid][pLAERank];
      new roleplay = PlayerInfo[playerid][pRoleplay];
      new cash = GetPlayerMoney(targetid);
      new bank = PlayerInfo[playerid][pBank];
      new car = PlayerInfo[playerid][pCarLic];
      new gun = PlayerInfo[playerid][pGunLic];
        new name[MAX_PLAYER_NAME];
        GetPlayerName(targetid, name, sizeof(name));
        new Float:px,Float:py,Float:pz;
        GetPlayerPos(targetid, px, py, pz);
        if(PlayerInfo[playerid][pVIPMember] == 1) VIP2 = "Yes";
        else if(PlayerInfo[playerid][pVIPMember] == 0) VIP2 = "No";
        new coordsstring[256];
        format(coordsstring, sizeof(coordsstring),"Your Stats");
    SendClientMessage(playerid, COLOR_YELLOW,coordsstring);
        format(coordsstring, sizeof(coordsstring), "OOC: | Admin Level: %d | VIP Member: %d | LAE Rank: %d | Roleplay Points: %d |", admin, VIP2, laerank, roleplay);
        SendClientMessage(playerid, COLOR_GREY,coordsstring);
        format(coordsstring, sizeof(coordsstring), "IC: | Cash: $%d | Bank: $%d | Driving License: %d | Firearm License: %d |", cash, bank, car, gun);
        SendClientMessage(playerid, COLOR_GREY,coordsstring);
       
    }
}
Reply
#6

Quote:
Originally Posted by Jeffry
Quote:
Originally Posted by FreddeN
Sorry, is still just shows 0 or 1.
You need to put the if and else if over the message.

pawn Код:
public ShowStats(playerid,targetid)
{
  if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
    {
      new string[256],VIP2[10];
        new admin = PlayerInfo[playerid][pAdminLevel];
      new VIP = PlayerInfo[playerid][pVIPMember];
      new laerank = PlayerInfo[playerid][pLAERank];
      new roleplay = PlayerInfo[playerid][pRoleplay];
      new cash = GetPlayerMoney(targetid);
      new bank = PlayerInfo[playerid][pBank];
      new car = PlayerInfo[playerid][pCarLic];
      new gun = PlayerInfo[playerid][pGunLic];
        new name[MAX_PLAYER_NAME];
        GetPlayerName(targetid, name, sizeof(name));
        new Float:px,Float:py,Float:pz;
        GetPlayerPos(targetid, px, py, pz);
        if(PlayerInfo[playerid][pVIPMember] == 1) VIP2 = "Yes";
        else if(PlayerInfo[playerid][pVIPMember] == 0) VIP2 = "No";
        new coordsstring[256];
        format(coordsstring, sizeof(coordsstring),"Your Stats");
    SendClientMessage(playerid, COLOR_YELLOW,coordsstring);
        format(coordsstring, sizeof(coordsstring), "OOC: | Admin Level: %d | VIP Member: %d | LAE Rank: %d | Roleplay Points: %d |", admin, VIP2, laerank, roleplay);
        SendClientMessage(playerid, COLOR_GREY,coordsstring);
        format(coordsstring, sizeof(coordsstring), "IC: | Cash: $%d | Bank: $%d | Driving License: %d | Firearm License: %d |", cash, bank, car, gun);
        SendClientMessage(playerid, COLOR_GREY,coordsstring);
       
    }
}
This just changed the %d to the number 78 and it stays there...
Reply
#7

I solved it by deleting the:

Код:
new vip = PlayerInfo[playerid][pVIPMember];
And changind the VIP2 to VIP, also changed the format "%d" to %s".

SOLVED
Reply
#8

Quote:
Originally Posted by FreddeN
And changind the VIP2 to VIP, also changed the format "%d" to %s".
Oh, yeah, these little thingys. I just oversaw them on this small box here.

But nice its fixed.
Reply
#9

pawn Код:
public ShowStats(playerid,targetid)
{
  if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
    {
      new string[256],VIP2[5];
        new admin = PlayerInfo[playerid][pAdminLevel];
      new VIP = PlayerInfo[playerid][pVIPMember];
      new laerank = PlayerInfo[playerid][pLAERank];
      new roleplay = PlayerInfo[playerid][pRoleplay];
      new cash = GetPlayerMoney(targetid);
      new bank = PlayerInfo[playerid][pBank];
      new car = PlayerInfo[playerid][pCarLic];
      new gun = PlayerInfo[playerid][pGunLic];
        new name[MAX_PLAYER_NAME];
        GetPlayerName(targetid, name, sizeof(name));
        new Float:px,Float:py,Float:pz;
        GetPlayerPos(targetid, px, py, pz);
        if(PlayerInfo[playerid][pVIPMember]) VIP2 = "Yes";
        else if(PlayerInfo[playerid][pVIPMember]) VIP2 = "No";
        new coordsstring[256];
    SendClientMessage(playerid, COLOR_YELLOW,"Your Stats");
        format(coordsstring, sizeof(coordsstring), "OOC: | Admin Level: %d | VIP Member: %s | LAE Rank: %d | Roleplay Points: %d |", admin, VIP2, laerank, roleplay);
        SendClientMessage(playerid, COLOR_GREY,coordsstring);
        format(coordsstring, sizeof(coordsstring), "IC: | Cash: $%d | Bank: $%d | Driving License: %d | Firearm License: %d |", cash, bank, car, gun);
        SendClientMessage(playerid, COLOR_GREY,coordsstring);
       
    }
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)