sscanf warning: Format specifier does not match parameter count. -
Zeus666 - 27.09.2018
PHP код:
CMD:setfreq(playerid,params[])
{
if(PlayerHasItem(playerid,"Statie Radio"))
{
new slot, valoare ,string[128];
if(sscanf(params, "i", slot, value)) return SendClientMessage(playerid,-1,""COL_RED"Cmds: /setfreq [Slot] [Freq]");
switch(slot)
{
case 1: pInfo[playerid][pRadioFreq1] = value;
case 2: pInfo[playerid][pRadioFreq2] = value;
case 3: pInfo[playerid][pRadioFreq3] = value;
}
format(string,sizeof(string),""COL_RED"Cmds: You have changed slot number %i frequency at %i.",slot, value);
SendClientMessage(playerid,-1,string);
}
else {
SendClientMessage(playerid,-1,""COL_RED"ERROR: Where's your radio?");
}
Known errors:
- At server log it shows "sscanf warning: Format specifier does not match parameter count."
- When I type /setfreq, any of pRadioFreq won't change. It remains at 0
Re: how to find case's value -
GospodinX - 27.09.2018
Show us full code.. switch( ? ) .
Re: how to find case's value -
Zeus666 - 27.09.2018
PHP код:
new slot, value,string[128];
if(sscanf(params, "i", slot, value)) return SendClientMessage(playerid,-1,""COL_RED"Cmds: /setfreq [Slot] [Freq]");
switch(slot)
{
case 1: pInfo[playerid][pRadioFreq1] = value;
case 2: pInfo[playerid][pRadioFreq2] = value;
case 3: pInfo[playerid][pRadioFreq3] = value;
}
format(string,sizeof(string),""COL_RED"Cmds: You have changed slot number %i at frequency %i.",?????????, valoare);
SendClientMessage(playerid,-1,string);
}
Re: how to find case's value -
NaS - 27.09.2018
Why don't you use a multi dimensional array for the radio freq and do:
Код:
pInfo[playerid][pRadioFreq][slot] = value;
Then assign the slots -1 by default (which means invalid).
To find a slot simply loop through it, the first slot that is -1 will be the new slot you can use.
This will also allow you to change the amount of slots at any time dynamically, if you ever need more.
Re: how to find case's value -
GospodinX - 27.09.2018
?? = "slot" !?
Код:
new slot, value,string[128];
if(sscanf(params, "i", slot, value)) return SendClientMessage(playerid,-1,""COL_RED"Cmds: /setfreq [Slot] [Freq]");
switch(slot)
{
case 1: pInfo[playerid][pRadioFreq1] = value;
case 2: pInfo[playerid][pRadioFreq2] = value;
case 3: pInfo[playerid][pRadioFreq3] = value;
}
format(string,sizeof(string),""COL_RED"Cmds: You have changed slot number %i at frequency %i.",slot, value);
SendClientMessage(playerid,-1,string);
}
Re: how to find case's value -
Zeus666 - 27.09.2018
Well, I made
PHP код:
/r1 (slot1)
/r2 (Slot2)
/r3 (slot3)
PHP код:
And if you type /r1 it shows: [CH %i | S: 1]
At /r2 it shows S2
At /r3 it shows S3.
But command /setfreq it won't set the value of the "pRadioFreqX" (i have replaced ?? ?? ? with slot)
It sets 0 every pradiofreq
"sscanf warning: Format specifier does not match parameter count."
Re: how to find case's value -
GospodinX - 27.09.2018
You have an mistake here in sscanf ( params, "i" ) need to be ( params, "ii" )
replace
Код:
if(sscanf(params, "ii", slot, value)) return SendClientMessage(playerid,-1,""COL_RED"Cmds: /setfreq [Slot] [Freq]");
Re: how to find case's value -
Zeus666 - 27.09.2018
Thanks