SA-MP Forums Archive
how to find case's value - 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: how to find case's value (/showthread.php?tid=659230)



sscanf warning: Format specifier does not match parameter count. - Zeus666 - 27.09.2018

PHP код:
CMD:setfreq(playerid,params[])
{
    if(
PlayerHasItem(playerid,"Statie Radio"))
    {
        new 
slotvaloare ,string[128];
        if(
sscanf(params"i"slotvalue)) return SendClientMessage(playerid,-1,""COL_RED"Cmds: /setfreq [Slot] [Freq]");
        switch(
slot)
        {
        case 
1pInfo[playerid][pRadioFreq1] = value;
        case 
2pInfo[playerid][pRadioFreq2] = value;
        case 
3pInfo[playerid][pRadioFreq3] = value;
        }
        
format(string,sizeof(string),""COL_RED"Cmds: You have changed slot number %i frequency at %i.",slotvalue);
        
SendClientMessage(playerid,-1,string);
    }
    else {
        
SendClientMessage(playerid,-1,""COL_RED"ERROR: Where's your radio?");
    } 
Known errors:


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 slotvalue,string[128];
        if(
sscanf(params"i"slotvalue)) return SendClientMessage(playerid,-1,""COL_RED"Cmds: /setfreq [Slot] [Freq]");
        switch(
slot)
        {
        case 
1pInfo[playerid][pRadioFreq1] = value;
        case 
2pInfo[playerid][pRadioFreq2] = value;
        case 
3pInfo[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 %S1
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