sscanf optional values
#1

Hello there.
I'm wondering how can I switch 2 type of values with sscanf. What I mean?
Example, a player have to type the ID of a vehicle OR the plate of the vehicle.
So.. how can I make it?
PHP код:
CMD:rplate(playeridparams[])
{
    if(!
GetPlayerVehicleID(playerid)) return SCM(playeridRED"You must be in a vehicle.");
    
    new 
        
target,
        
plate[12+EOS] = EOS;
    if(
sscanf(params"I(65535)S()[12]"targetplate)) 
        return 
SCM(playeridLBLUE"/rplate [blabla]");
    if(
target == INVALID_VEHICLE_ID && strval(plate) < 2)
        return 
SCM(playeridRED"Error"); 
If I type nothing after /rplate, I've "Error" message. If I type an ID, this working too but if I type a plate I've "/rplate" message. I think because I is optionnal but I can't pass it.
So, I hope you understand what I mean.
Thanks you'!
Reply


Messages In This Thread
sscanf optional values - by Dayrion - 05.10.2016, 07:57
Re: sscanf optional values - by Threshold - 05.10.2016, 09:43
Re: sscanf optional values - by RoboN1X - 05.10.2016, 09:50
Re: sscanf optional values - by Rdx - 05.10.2016, 10:26
Re: sscanf optional values - by Dayrion - 05.10.2016, 13:35

Forum Jump:


Users browsing this thread: 1 Guest(s)