Whats Wrong With This? - 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: Whats Wrong With This? (
/showthread.php?tid=347308)
Whats Wrong With This? -
Littlehelper - 01.06.2012
Hello,
I have a little problem here with the code /reports.
Here's my code.
pawn Код:
// New's
new reportcount = 0;
new reports[5][50];
new reportstring[100];
new reportstring1[100];
new reportstring2[100];
new reportstring3[100];
new reportstring4[100];
// Command
CMD:reports(playerid, params[])
{
if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid, -1, ""COL_RED"[ERROR]:"COL_WHITE": You Are Not Authorized To Use This Command!");
if(!strlen(reports[0])) return SendClientMessage(playerid, -1, ""COL_RED"[ERROR]:"COL_WHITE": There Have Been 0 Player Reports So Far!");
for(new s; s < 5; s++)
{
if(strlen(reports[s]) != 0)
{
format(reportstring, sizeof(reportstring), "REPORT: %s", reports[s][0]);
SendClientMessage(playerid, -1, reportstring);
format(reportstring1, sizeof(reportstring1), "REPORT: %s", reports[s][1]);
SendClientMessage(playerid, -1, reportstring1);
format(reportstring2, sizeof(reportstring2), "REPORT: %s", reports[s][2]);
SendClientMessage(playerid, -1, reportstring2);
format(reportstring3, sizeof(reportstring3), "REPORT: %s", reports[s][3]);
SendClientMessage(playerid, -1, reportstring3);
format(reportstring4, sizeof(reportstring4), "REPORT: %s", reports[s][4]);
SendClientMessage(playerid, -1, reportstring4);
}
}
return 1;
}
Whenever someone does /reports it spams something like ' aceeed: Littlehelper '
Help will be appreciated.
Thanks.
Re: Whats Wrong With This? -
IstuntmanI - 01.06.2012
Try changing your code with
pawn Код:
// New's
new reportcount = 0;
new reports[5][50];
new reportstring[128];
// Command
CMD:reports(playerid, params[])
{
if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid, -1, ""COL_RED"[ERROR]:"COL_WHITE": You Are Not Authorized To Use This Command!");
if(!strlen(reports[0])) return SendClientMessage(playerid, -1, ""COL_RED"[ERROR]:"COL_WHITE": There Have Been 0 Player Reports So Far!");
for(new s; s < 5; s++)
if(strlen(reports[s]) != 0)
format(reportstring, sizeof(reportstring), "REPORT: %s", reports[s]);
return 1;
}
Re: Whats Wrong With This? -
Babul - 01.06.2012
using reports[s][0] will pick the string at the starting point [0]. to print the whole string, just remove the 2-dimensional [0]. the [s] is already done by the loop, you dont need to access all reports if just one string is existing:
pawn Код:
for(new s; s < 5; s++)
{
if(strlen(reports[s]) != 0)
{
format(reportstring, sizeof(reportstring), "REPORT: %s", reports[s]);
SendClientMessage(playerid, -1, reportstring);
}
}
oh, you can get rid of the other reportstring1, 2 etc...
edit: ah, its already postet above, iam 1 minute late lol
Re: Whats Wrong With This? -
Littlehelper - 04.06.2012
I get it,
thanks.