More efficient way of listitem. -
jasperschellekens - 06.01.2018
Hello, I was wondering if there is any easyer/better way to do the following:
PHP код:
if(listitem == 0)
{
format(file, sizeof(file), "Data/Reports/r0.ini");
}
if(listitem == 1)
{
format(file, sizeof(file), "Data/Reports/r1.ini");
}
if(listitem == 2)
{
format(file, sizeof(file), "Data/Reports/r2.ini");
}
I did try:
PHP код:
format(file, sizeof(file), "Data/Reports/r%d.ini", listitem);
But sadly that doesn't work. Any other way to this?
Re: More efficient way of listitem. -
rfr - 06.01.2018
https://sampwiki.blast.hk/wiki/Control_Structures
Use case for a more efficient way.
Re: More efficient way of listitem. -
Jaxson - 06.01.2018
I don't see why would this not work:
pawn Код:
format(file, sizeof(file), "Data/Reports/r%d.ini", listitem);
This is the most efficient way to do that.
Re: More efficient way of listitem. -
jasperschellekens - 06.01.2018
Quote:
Originally Posted by Jaxson
I don't see why would this not work:
pawn Код:
format(file, sizeof(file), "Data/Reports/r%d.ini", listitem);
This is the most efficient way to do that.
|
Indeed, thats what i tought but it doesn't work. It shows ID0 always...
Re: More efficient way of listitem. -
Kane - 06.01.2018
Debug it, print out the results.
Re: More efficient way of listitem. -
jasperschellekens - 06.01.2018
Quote:
Originally Posted by Arthur Kane
Debug it, print out the results.
|
I'm sorry i don't understand. how do i do that?
Re: More efficient way of listitem. -
Kane - 06.01.2018
Quote:
Originally Posted by jasperschellekens
I'm sorry i don't understand. how do i do that?
|
https://sampwiki.blast.hk/wiki/Printf
Re: More efficient way of listitem. -
jasperschellekens - 06.01.2018
Quote:
Originally Posted by Arthur Kane
|
I do not understand how that printing something on the server log will tell me why listitem does not work.
Could anybody give me an example on using this with switch case?
Re: More efficient way of listitem. -
adri1 - 06.01.2018
Quote:
Originally Posted by jasperschellekens
I do not understand how that printing something on the server log will tell me why listitem does not work.
Could anybody give me an example on using this with switch case?
|
https://sampwiki.blast.hk/wiki/Debugging
Re: More efficient way of listitem. -
jasperschellekens - 06.01.2018
I did something wrong after all, now it is working fine. thanks for the help.
I have one more question.
How to check if an array is equal to playername?
This does not work:
PHP код:
if(ReportInfo[repid][ReportOpenedBy] == GetPlayerName(playerid);)
This also does not work:
PHP код:
TempReportNameCheck[playerid] = GetPlayerName(playerid);
if(ReportInfo[repid][ReportOpenedBy] == TempReportNameCheck[playerid])