SA-MP Forums Archive
/stats error - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /stats error (/showthread.php?tid=541285)



/stats error - boy - 11.10.2014

This error:
Код HTML:
C:\Users\Zachary.Zach-HP.000\Desktop\Folders\SA-MP\Los Santos Realism\gamemodes\LS-R.pwn(113) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
These codes:
Код HTML:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/buycar", cmdtext, true, 10) == 0)
    ShowPlayerDialog(playerid, 13, DIALOG_STYLE_LIST, "Car Dealership", "Huntley\nAdmiral\nBurrito\nStratum\nSadler\nUranus", "Buy", "Close");
    return 1;
    }
    
    if (strcmp(cmd, "/stats", true) == 0) // THIS IS LINE 113
	format(string, sizeof(string), "Money: [$%d]", PlayerInfo[playerid][pMoney])
	SendClientMessage(playerid, COLOR_GREEN, string);
    }
Anyone know what the problem is? Sorry if the codes aren't neatly written. I've been changing them up to see if I could fix it but nothing has fixed it yet. I will give rep to whoever successfully helps me.


Re: /stats error - SickAttack - 11.10.2014

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/buycar", true) == 0)
    {
        ShowPlayerDialog(playerid, 13, DIALOG_STYLE_LIST, "Car Dealership", "Huntley\nAdmiral\nBurrito\nStratum\nSadler\nUranus", "Buy", "Close");
        return 1;
    }
    if(strcmp(cmdtext, "/stats", true) == 0)
    {
        new string[144];
        format(string, sizeof(string), "Money: [$%d]", PlayerInfo[playerid][pMoney])
        SendClientMessage(playerid, COLOR_GREEN, string);
        return 1;
    }
    return 1;
}
You should use a command processor, strcmp commands are slow because it has to do a lot of checking. Command processors call the function directly.


Re: /stats error - boy - 11.10.2014

Okay. But now I'm getting this error
Код HTML:
C:\Users\Zachary.Zach-HP.000\Desktop\Folders\SA-MP\Los Santos Realism\gamemodes\LS-R.pwn(117) : error 001: expected token: ";", but found "-identifier-"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/buycar", true) == 0)
    {
        ShowPlayerDialog(playerid, 13, DIALOG_STYLE_LIST, "Car Dealership", "Huntley\nAdmiral\nBurrito\nStratum\nSadler\nUranus", "Buy", "Close");
        return 1;
    }
    if(strcmp(cmdtext, "/stats", true) == 0)
    {
        new string[144];
        format(string, sizeof(string), "Money: [$%d]", PlayerInfo[playerid][pMoney])
        SendClientMessage(playerid, COLOR_GREEN, string); // LINE 117
        return 1;
    }
    return 1;
}
I will keep that in mind once I get better at scripting.


Re: /stats error - The__ - 11.10.2014

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/buycar", true) == 0)
    {
        ShowPlayerDialog(playerid, 13, DIALOG_STYLE_LIST, "Car Dealership", "Huntley\nAdmiral\nBurrito\nStratum\nSadler\nUranus", "Buy", "Close");
        return 1;
    }
    if(strcmp(cmdtext, "/stats", true) == 0)
    {
        new string[144];
        format(string, sizeof(string), "Money: [$%d]", PlayerInfo[playerid][pMoney]);
        SendClientMessage(playerid, COLOR_GREEN, string); // LINE 117
        return 1;
    }
    return 1;
}



Re: /stats error - austin070 - 11.10.2014

Add a semicolon to the end of the line above.

pawn Код:
format(string, sizeof(string), "Money: [$%d]", PlayerInfo[playerid][pMoney]);



Re: /stats error - boy - 11.10.2014

Okay thanks guys.


Re: /stats error - Threshold - 11.10.2014

Just for a bit more efficiency..

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/buycar", true)) return ShowPlayerDialog(playerid, 13, DIALOG_STYLE_LIST, "Car Dealership", "Huntley\nAdmiral\nBurrito\nStratum\nSadler\nUranus", "Buy", "Close");
    if(!strcmp(cmdtext, "/stats", true))
    {
        new string[24];
        format(string, sizeof(string), "Money: [$%d]", PlayerInfo[playerid][pMoney]);
        SendClientMessage(playerid, COLOR_GREEN, string);
        return 1;
    }
    return 0;
}