SSCANF2 warnings
#1

pawn Код:
if(sscanf(params, "s[64]I(-1)I(Color1)", aVehicle, Color1, Color2)) return SendClientMessage(playerid,COLOR_ERROR, "USAGE: /veh (Vehicle Name/ID) (color) (color)");
this is the code/error line in my command
these error i get in my log
Код:
[18:39:15] sscanf warning: Unclosed default value.
[18:39:15] sscanf warning: Format specifier does not match parameter count.
edit : please don't post ****** wiki for these errors i already read it all but nothing wrong
Reply
#2

When you do Optional Parameters you leave them blank, it'll automatically return -1 when there isn't any values.

Try This.
pawn Код:
if(sscanf(params, "s[64]I()I()", aVehicle, Color1, Color2)) return SendClientMessage(playerid,COLOR_ERROR, "USAGE: /veh (Vehicle Name/ID) (color) (color)");
Reply
#3

https://github.com/Y-Less/sscanf/wik..._default_value see we can add defult value
Reply
#4

BUMP
Reply
#5

I guess the "Color1" in the parentheses is the issue. Use a constant value like the previous one.
Reply
#6

use it like this

pawn Код:
if (sscanf(params, "s[64]ii" , aVehicle, Color1, Color2)) // The player will type color id in numbers, so numeric texts are integers.
Reply
#7

pawn Код:
CMD:veh(playerid, params[])
{
    if(pInfo[playerid][Adminlevel] < 1) return SCM(playerid, COLOR_ERROR, ""ERROR_MESSAGE"");
    if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid, COLOR_ERROR, "You can not use this command from an vehicle");
    new aVehicle[64], Color1, Color2,string[100];
    if(sscanf(params, "s[64]I(-1)I(Color1)", aVehicle, Color1, Color2)) return SendClientMessage(playerid,COLOR_ERROR, "USAGE: /veh (Vehicle Name/ID) (color) (color)");
    new veh = GetVehicleModelIDFromName(aVehicle);
    if(veh < 400 || veh > 611) return SendClientMessage(playerid,COLOR_ERROR, "Invalid Vehicle Name.");
    new Float:Pos[4];
    GetPlayerPos(playerid, Pos[0],Pos[1],Pos[2]); GetPlayerFacingAngle(playerid, Pos[3]);
    pVeh = cVeh = CreateStaticVehicle(VEHICLE_TYPE_CIVILIAN,veh, Pos[0], Pos[1], Pos[2]+10, Pos[3]+90, Color1, Color2);
    LinkVehicleToInterior(pVeh, GetPlayerInterior(playerid));
    SetVehicleVirtualWorld(pVeh, GetPlayerVirtualWorld(playerid));
    format(string,sizeof(string),"You have spawned %s - id %d with color %d - %d type normal.",VehicleNames[veh - 400],veh,Color1,Color2);
    SCM(playerid,COLOR_SKYBLUE,string);
    GameTextForPlayer(playerid, "~y~Enjoy your new ~r~ride", 2000, 1);
    return 1;
}
Reply
#8

Quote:
Originally Posted by ******
Посмотреть сообщение
Posting more code doesn't help - we already told you the issue. Yes, the errors coming from sscanf are a little cryptic, but that doesn't change the solution.
but that was an guess and i didn't meant to post whole code i wanted to show that it is Integer
Reply
#9

Quote:
Originally Posted by AroseKhanNaizi
Посмотреть сообщение
but that was an guess and i didn't meant to post whole code i wanted to show that it is Integer
You can't make a reference to another variable in the format specifier like you were trying to do, just set the default to -1 and check the value of Color2, if it's -1, then set Color2 to Color1.
Reply
#10

Try to read sscanf documentation. You'll understand everything. The integers, users, strings and all.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)