problems with sscanf -
Marricio - 29.01.2012
Hello everyone,
I am trying to make a trunk / boot system it's based that you can store certain items in the vehicle's rear boot/trunk (how americans or english people would say it).
However I have problems with this:
pawn Code:
CMD:vehtrunk( playerid, params[] )
{
new option[64];
if( sscanf( params, "s[64]", option ) )
{
SendClientMessage( playerid, COLOR_GREEN, "SYNTAX: /vehtrunk [info/open/close/putgun/takegun/putcocaine/takecocaine/putheroin]");
SendClientMessage( playerid, COLOR_GREEN, "[takeheroin/putecstasy/takeecstasy/putcrack/takecrack/putweed/takeweed/putcrystalmeth]");
SendClientMessage( playerid, COLOR_GREEN, "[takecrystalmeth/putsteroids/takesteroids/putgascan/takegascan/putmaterials/takematerials]");
return 1;
}
if ( !isnull( option ) )
{
new closest = GetClosestVehicleInRange( playerid, 3.0 );
new szString[128];
else if ( !strcmp( option, "putgun", true ) )
{
new slot;
if( sscanf( params, "d", slot ) )
return SendClientMessage( playerid, COLOR_BEIGE, "SYNTAX: /vehtrunk putgun [1-4 slot]");
printf(" Slot: %d", slot );
}
}
return 1;
}
My problem is that when I do /vehtrunk putgun and only that, I get the message "SYNTAX: /vehtrunk putgun [1-4 slot]", however, if I do for example /vehtrunk putgun 3, nothing happens, and the message is not printed to the console.
p.s: I removed irrevelant bits of code.
Why?
Re: problems with sscanf -
MP2 - 29.01.2012
I'd personally have /trunk put gun (gun)
Re: problems with sscanf -
Marricio - 29.01.2012
I think it's the same thing.. even with that way you tell me I would have problems.. I need some orientation to use sscanf properly in this situation.
Re: problems with sscanf -
Marricio - 30.01.2012
bump
Re: problems with sscanf -
milanosie - 30.01.2012
pawn Code:
CMD:vehtrunk( playerid, params[] )
{
new option[64];
if(!sscanf( params, "s[64]", option ))
{
SendClientMessage( playerid, COLOR_GREEN, "SYNTAX: /vehtrunk [info/open/close/putgun/takegun/putcocaine/takecocaine/putheroin]");
SendClientMessage( playerid, COLOR_GREEN, "[takeheroin/putecstasy/takeecstasy/putcrack/takecrack/putweed/takeweed/putcrystalmeth]");
SendClientMessage( playerid, COLOR_GREEN, "[takecrystalmeth/putsteroids/takesteroids/putgascan/takegascan/putmaterials/takematerials]");
return 1;
}
if ( !isnull( option ) )
{
new closest = GetClosestVehicleInRange( playerid, 3.0 );
new szString[128];
else if ( !strcmp( option, "putgun", true ) )
{
new slot;
if( sscanf( params, "d", slot ) )
return SendClientMessage( playerid, COLOR_BEIGE, "SYNTAX: /vehtrunk putgun [1-4 slot]");
printf(" Slot: %d", slot );
}
}
return 1;
}
Re: problems with sscanf -
Konstantinos - 30.01.2012
pawn Code:
CMD:vehtrunk( playerid, params[ ] )
{
if( !isnull( params ) )
{
SendClientMessage( playerid, COLOR_GREEN, "SYNTAX: /vehtrunk [info/open/close/putgun/takegun/putcocaine/takecocaine/putheroin]" );
SendClientMessage( playerid, COLOR_GREEN, "[takeheroin/putecstasy/takeecstasy/putcrack/takecrack/putweed/takeweed/putcrystalmeth]" );
SendClientMessage( playerid, COLOR_GREEN, "[takecrystalmeth/putsteroids/takesteroids/putgascan/takegascan/putmaterials/takematerials]" );
return 1;
}
if( strcmp( params, "info", true ) == 0)
{
// Code about Info
}
else if( strcmp( params, "open", true ) == 0)
{
// Code about Open
}
else if( strcmp( params, "close", true ) == 0)
{
// Code about Close
}
else if( strcmp( params, "putgun", true ) == 0)
{
// Code about Putgun
}
// Continue up to the last...
else if( strcmp( params, "takematerials", true ) == 0)
{
// Code about Takematerials
}
else
{
SendClientMessage( playerid, COLOR_GREEN, "SYNTAX: /vehtrunk [info/open/close/putgun/takegun/putcocaine/takecocaine/putheroin]" );
SendClientMessage( playerid, COLOR_GREEN, "[takeheroin/putecstasy/takeecstasy/putcrack/takecrack/putweed/takeweed/putcrystalmeth]" );
SendClientMessage( playerid, COLOR_GREEN, "[takecrystalmeth/putsteroids/takesteroids/putgascan/takegascan/putmaterials/takematerials]" );
return 1;
}
return 1;
}
Re: problems with sscanf -
admantis - 30.01.2012
----
Re: problems with sscanf -
Marricio - 30.01.2012
These commands are not really helping, as in, for example, when I need to do "putmaterials" and insert an ammount of items to place in the trunk, I will need to use sscanf again to extract that the same way.
I now know why is it caused; now how do I fix it?