Stats Help
#1

- FIXED -
Reply
#2

Showe the lines with the comment or so.. Because nobody wants to waste his time...
Reply
#3

Код:
CMD:stats(playerid, params[])
{
	new str[956], yes[2][50];
	if(pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, COLOR_RED, "[Error]: You must be logged in to use this command!");
	GetPlayerIp(playerid, pInfo[playerid][Ip], 16);
	switch(pInfo[playerid][NoPM])
	{
	    case 0: yes[0] = "Disable";
	    case 1: yes[0] = "Enable";
	}
	switch(pInfo[playerid][PlayerTele])
	{
	    case 0: yes[1] = "Disable";
	    case 1: yes[1] = "Enable";
	}
	format(str, "{15D4ED}Player Name: %s\n", GetName(playerid)); // Error Started
	format(str, "Ip Address: %s\n", pInfo[playerid][Ip]);
	format(str, "Admin: %i\n", pInfo[playerid][Admin]);
	format(str, "VIP: %i\n", pInfo[playerid][VIP]);
	format(str, "Drugs: %i || Herione: %i || Cocaine: %i\n", pInfo[playerid][Drugs], pInfo[playerid][Heroine], pInfo[playerid][Cocaine]);
	format(str, "Money: $%i\n", GetPlayerMoney(playerid));
	format(str, "Score: %i\n", GetPlayerScore(playerid));
	format(str, "Cookies: %i\n", pInfo[playerid][Cookies]);
	format(str, "SkinID: %i\n", pInfo[playerid][SaveSkin]);
	format(str, "PM: %s\n", yes[0]);
	format(str, "Player Teleport: %s\n", yes[1]);
	format(str, "Bank Balance: $%i\n", pInfo[playerid][BankWealth]);
	format(str, "Kills: %i || Deaths: %i || Ratio: NaN\n", pInfo[playerid][Kills], pInfo[playerid][Deaths]); // End Of Error line
	ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_MSGBOX, ""white"Stats", str, "Close", "");
	SendAdminCMD(playerid, "stats");
	return 1;
this
Reply
#4

Код:
CMD:stats(playerid, params[])
{
	new str[956], yes[2][50];
	if(pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, COLOR_RED, "[Error]: You must be logged in to use this command!");
	GetPlayerIp(playerid, pInfo[playerid][Ip], 16);
	switch(pInfo[playerid][NoPM])
	{
	    case 0: yes[0] = "Disable";
	    case 1: yes[0] = "Enable";
	}
	switch(pInfo[playerid][PlayerTele])
	{
	    case 0: yes[1] = "Disable";
	    case 1: yes[1] = "Enable";
	}
	format(str,sizeof(str), "{15D4ED}Player Name: %s\nIp Address: %s\nAdmin: %i\nVIP: %i\nDrugs: %i || Herione: %i || Cocaine: %i\nMoney: $%i\nScore: %i\nCookies: %i\nSkinID: %i\nPM: %s\nPlayer Teleport: %s\nBank Balance: $%i\nKills: %i || Deaths: %i || Ratio: NaN\n", GetName(playerid),pInfo[playerid][Ip],pInfo[playerid][Admin],pInfo[playerid][VIP],pInfo[playerid][Drugs], pInfo[playerid][Heroine], pInfo[playerid][Cocaine],GetPlayerMoney(playerid),GetPlayerScore(playerid),pInfo[playerid][Cookies],pInfo[playerid][SaveSkin],yes[0],yes[1],pInfo[playerid][BankWealth],pInfo[playerid][Kills], pInfo[playerid][Deaths]); 

	ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_MSGBOX, ""white"Stats", str, "Close", "");
	SendAdminCMD(playerid, "stats");
	return 1;
Strcat if you get error with length.
Reply
#5

the problem is that the format syntax is wrong
the 2nd argument should be the size of the output string
so like current line is this--
format(str, "{15D4ED}Player Name: %s\n", GetName(playerid));
change it to following--
format(str, sizeof(str),"{15D4ED}Player Name: %s\n", GetName(playerid));

like this do with all format line
Reply
#6

I already with it, but I do not like it, I want to try using strcat, can you make it to me (using strcat)??
Reply
#7

Try it; it may be bugged though, not tested...
pawn Код:
CMD:stats(playerid, params[])
{
    new str[956], yes[2][50];
    if(pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, COLOR_RED, "[Error]: You must be logged in to use this command!");
    GetPlayerIp(playerid, pInfo[playerid][Ip], 16);
    switch(pInfo[playerid][NoPM])
    {
        case 0: yes[0] = "Disable";
        case 1: yes[0] = "Enable";
    }
    switch(pInfo[playerid][PlayerTele])
    {
        case 0: yes[1] = "Disable";
        case 1: yes[1] = "Enable";
    }
    strcat(str, "{15D4ED}Player Name: %s\n", GetName(playerid));
    strcat(str, "Ip Address: %s\n", pInfo[playerid][Ip]);
    strcat(str, "Admin: %i\n", pInfo[playerid][Admin]);
    strcat(str, "VIP: %i\n", pInfo[playerid][VIP]);
    strcat(str, "Drugs: %i || Herione: %i || Cocaine: %i\n", pInfo[playerid][Drugs], pInfo[playerid][Heroine], pInfo[playerid][Cocaine]);
    strcat(str, "Money: $%i\n", GetPlayerMoney(playerid));
    strcat(str, "Score: %i\n", GetPlayerScore(playerid));
    strcat(str, "Cookies: %i\n", pInfo[playerid][Cookies]);
    strcat(str, "SkinID: %i\n", pInfo[playerid][SaveSkin]);
    strcat(str, "PM: %s\n", yes[0]);
    strcat(str, "Player Teleport: %s\n", yes[1]);
    strcat(str, "Bank Balance: $%i\n", pInfo[playerid][BankWealth]);
    strcat(str, "Kills: %i || Deaths: %i || Ratio: NaN\n", pInfo[playerid][Kills], pInfo[playerid][Deaths]);
    ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_MSGBOX, ""white"Stats", str, "Close", "");
    SendAdminCMD(playerid, "stats");
    return 1;
Reply
#8

Quote:
Originally Posted by BenJackster
Посмотреть сообщение
Try it; it may be bugged though, not tested...
pawn Код:
CMD:stats(playerid, params[])
{
    new str[956], yes[2][50];
    if(pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, COLOR_RED, "[Error]: You must be logged in to use this command!");
    GetPlayerIp(playerid, pInfo[playerid][Ip], 16);
    switch(pInfo[playerid][NoPM])
    {
        case 0: yes[0] = "Disable";
        case 1: yes[0] = "Enable";
    }
    switch(pInfo[playerid][PlayerTele])
    {
        case 0: yes[1] = "Disable";
        case 1: yes[1] = "Enable";
    }
    strcat(str, "{15D4ED}Player Name: %s\n", GetName(playerid));
    strcat(str, "Ip Address: %s\n", pInfo[playerid][Ip]);
    strcat(str, "Admin: %i\n", pInfo[playerid][Admin]);
    strcat(str, "VIP: %i\n", pInfo[playerid][VIP]);
    strcat(str, "Drugs: %i || Herione: %i || Cocaine: %i\n", pInfo[playerid][Drugs], pInfo[playerid][Heroine], pInfo[playerid][Cocaine]);
    strcat(str, "Money: $%i\n", GetPlayerMoney(playerid));
    strcat(str, "Score: %i\n", GetPlayerScore(playerid));
    strcat(str, "Cookies: %i\n", pInfo[playerid][Cookies]);
    strcat(str, "SkinID: %i\n", pInfo[playerid][SaveSkin]);
    strcat(str, "PM: %s\n", yes[0]);
    strcat(str, "Player Teleport: %s\n", yes[1]);
    strcat(str, "Bank Balance: $%i\n", pInfo[playerid][BankWealth]);
    strcat(str, "Kills: %i || Deaths: %i || Ratio: NaN\n", pInfo[playerid][Kills], pInfo[playerid][Deaths]);
    ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_MSGBOX, ""white"Stats", str, "Close", "");
    SendAdminCMD(playerid, "stats");
    return 1;
I got error
Код:
D:\xSF\gamemodes\IxF.pwn(19607) : error 035: argument type mismatch (argument 3)
D:\xSF\gamemodes\IxF.pwn(19611) : warning 202: number of arguments does not match definition
D:\xSF\gamemodes\IxF.pwn(19611) : warning 202: number of arguments does not match definition
D:\xSF\gamemodes\IxF.pwn(19616) : error 035: argument type mismatch (argument 3)
D:\xSF\gamemodes\IxF.pwn(19617) : error 035: argument type mismatch (argument 3)
D:\xSF\gamemodes\IxF.pwn(19619) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
Код:
    strcat(str, "{15D4ED}Player Name: %s\n", GetName(playerid)); // ERROR
    strcat(str, "Ip Address: %s\n", pInfo[playerid][Ip]);
    strcat(str, "Admin: %i\n", pInfo[playerid][Admin]);
    strcat(str, "VIP: %i\n", pInfo[playerid][VIP]);
    strcat(str, "Drugs: %i || Herione: %i || Cocaine: %i\n", pInfo[playerid][Drugs], pInfo[playerid][Heroine], pInfo[playerid][Cocaine]); // Error
    strcat(str, "Money: $%i\n", GetPlayerMoney(playerid));
    strcat(str, "Score: %i\n", GetPlayerScore(playerid));
    strcat(str, "Cookies: %i\n", pInfo[playerid][Cookies]);
    strcat(str, "SkinID: %i\n", pInfo[playerid][SaveSkin]);
    strcat(str, "PM: %s\n", yes[0]);
    strcat(str, "Player Teleport: %s\n", yes[1]); // Error
    strcat(str, "Bank Balance: $%i\n", pInfo[playerid][BankWealth]);
    strcat(str, "Kills: %i || Deaths: %i || Ratio: NaN\n", pInfo[playerid][Kills], pInfo[playerid][Deaths]); //Error
    ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_MSGBOX, ""white"Stats", str, "Close", "");
    SendAdminCMD(playerid, "stats");
Reply
#9

Actually the code that Ben gave is wrong
this is correct one use this--
pawn Код:
CMD:stats(playerid, params[])
{
    new str[200], yes[2][50],sho[956];
    if(pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, COLOR_RED, "[Error]: You must be logged in to use this command!");
    GetPlayerIp(playerid, pInfo[playerid][Ip], 16);
    switch(pInfo[playerid][NoPM])
    {
        case 0: yes[0] = "Disable";
        case 1: yes[0] = "Enable";
    }
    switch(pInfo[playerid][PlayerTele])
    {
        case 0: yes[1] = "Disable";
        case 1: yes[1] = "Enable";
    }


    format(str,sizeof(str), "{15D4ED}Player Name: %s\n", GetName(playerid));
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "Ip Address: %s\n", pInfo[playerid][Ip]);
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "Admin: %i\n", pInfo[playerid][Admin]);
         strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "VIP: %i\n", pInfo[playerid][VIP]);
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "Drugs: %i || Herione: %i || Cocaine: %i\n", pInfo[playerid][Drugs], pInfo[playerid][Heroine], pInfo[playerid][Cocaine]);
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "Money: $%i\n", GetPlayerMoney(playerid));
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "Score: %i\n", GetPlayerScore(playerid));
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str),"Cookies: %i\n", pInfo[playerid][Cookies]);
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "SkinID: %i\n", pInfo[playerid][SaveSkin]);
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "PM: %s\n", yes[0]);
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "Player Teleport: %s\n", yes[1]);
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "Bank Balance: $%i\n", pInfo[playerid][BankWealth]);
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "Kills: %i || Deaths: %i || Ratio: NaN\n", pInfo[playerid][Kills], pInfo[playerid][Deaths]);
        strcat(sho,str,sizeof(sho));

    ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_MSGBOX, ""white"Stats", sho, "Close", "");
    SendAdminCMD(playerid, "stats");
    return 1;
}
Reply
#10

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
Actually the code that Ben gave is wrong
this is correct one use this--
pawn Код:
CMD:stats(playerid, params[])
{
    new str[200], yes[2][50],sho[956];
    if(pInfo[playerid][Logged] == 0) return SendClientMessage(playerid, COLOR_RED, "[Error]: You must be logged in to use this command!");
    GetPlayerIp(playerid, pInfo[playerid][Ip], 16);
    switch(pInfo[playerid][NoPM])
    {
        case 0: yes[0] = "Disable";
        case 1: yes[0] = "Enable";
    }
    switch(pInfo[playerid][PlayerTele])
    {
        case 0: yes[1] = "Disable";
        case 1: yes[1] = "Enable";
    }


    format(str,sizeof(str), "{15D4ED}Player Name: %s\n", GetName(playerid));
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "Ip Address: %s\n", pInfo[playerid][Ip]);
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "Admin: %i\n", pInfo[playerid][Admin]);
         strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "VIP: %i\n", pInfo[playerid][VIP]);
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "Drugs: %i || Herione: %i || Cocaine: %i\n", pInfo[playerid][Drugs], pInfo[playerid][Heroine], pInfo[playerid][Cocaine]);
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "Money: $%i\n", GetPlayerMoney(playerid));
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "Score: %i\n", GetPlayerScore(playerid));
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str),"Cookies: %i\n", pInfo[playerid][Cookies]);
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "SkinID: %i\n", pInfo[playerid][SaveSkin]);
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "PM: %s\n", yes[0]);
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "Player Teleport: %s\n", yes[1]);
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "Bank Balance: $%i\n", pInfo[playerid][BankWealth]);
        strcat(sho,str,sizeof(sho));
    format(str,sizeof(str), "Kills: %i || Deaths: %i || Ratio: NaN\n", pInfo[playerid][Kills], pInfo[playerid][Deaths]);
        strcat(sho,str,sizeof(sho));

    ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_MSGBOX, ""white"Stats", sho, "Close", "");
    SendAdminCMD(playerid, "stats");
    return 1;
}
Yep - since I'm not that used to strcat.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)