SA-MP Forums Archive
DCMD - Unknown command? - 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: DCMD - Unknown command? (/showthread.php?tid=492821)



DCMD - Unknown command? - SA_martin_SK - 05.02.2014

Hello. This command is working but it sending me also Unknown command message. Other commands work perfectly. So what's wrong? And when ShowPlayerDialog is outside the loop, why variable eqpt has no value after loop so it won't show dialog.

Код:
dcmd_class(playerid,params[])
{
    #pragma unused params
    new eqpt[128],eqp[32];
    for(new i;i<=5;i++)
    {
	format(eqp,sizeof(eqp),"%s\n",ClassName[i][playerid]);
	strcat(eqpt,eqp);
	ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Class selection",eqpt,"Select","");
    }
    return 1;
}



Re: DCMD - Unknown command? - Konstantinos - 05.02.2014

Run time error: Array index out of bounds because ClassName has size of 5 and the valid indexes are 0-4 but you used "<=" instead of "<" in the loop. Also ShowPlayerDialog should be outside of the loop otherwise you call it many times for no reason.

pawn Код:
dcmd_class(playerid, params[])
{
    #pragma unused params
   
    new
        eqpt[128];
   
    for (new i; i != sizeof (ClassName); ++i)
    {
        strcat(eqpt, ClassName[i][playerid]);
        strcat(eqpt, "\n");
    }
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Class selection", eqpt, "Select", "");
    return 1;
}



Re: DCMD - Unknown command? - SA_martin_SK - 05.02.2014

Thank you, it works now REP+