Sscanf problem.
#1

Hellooooo. I have a sscanf problem. I want to make command that spawns a vehicle. But I want to make command with a choice. You can type Vehicle ID or it's name. I know it's possible, because I have done it already (I don't know how...). I have made this command:
pawn Код:
dcmd_gpv(params[])
{
    new CarName[32], id, OptionalID, Color1, Color2;
  new Float: PlayerCoords[4];
    if(sscanf(params, "udid", id, OptionalID, Color1, Color2)) return print("Usage: /gpv [playerid/PartOfName] [CarID/CarName] [Color 1] [Color 2]"), 1;
    if(!sscanf(params, "usid", id, CarName, Color1, Color2)) goto by_name;
    if(!IsPlayerConnected(id)) return print("Player is not connected!"), 1;
    if(OptionalID < 400 || OptionalID > 611) return print("Wrong Car ID! IDs start at 400 and end at 611!"), 1;
    if(Color1 < 0 || Color1 > 126) return print("Wrong ColorID! Color IDs start at 0 and end at 126!"), 1;
    if(Color2 < 0 || Color2 > 126) return print("Wrong ColorID! Color IDs start at 0 and end at 126!"), 1;
    do{
    GetPlayerPos(id, PlayerCoords[0], PlayerCoords[1], PlayerCoords[2]);
    GetPlayerFacingAngle(id, PlayerCoords[3]);
    CreateVehicle(OptionalID, PlayerCoords[0], PlayerCoords[1], PlayerCoords[2]+1, PlayerCoords[3], Color1, Color2, 99*999);
    SendClientMessage(id, lightblue, "Remote admin has given you a vehicle!");
    printf("Player %s (ID: %i) was given a vehicle!", GetPlayerNick(id), id);
    return 1;
    }
    while(FALSE);
    by_name:
    if(!IsPlayerConnected(id)) return print("Player is not connected!"), 1;
    if(Color1 < 0 || Color1 > 126) return print("Wrong ColorID! Color IDs start at 0 and end at 126!"), 1;
    if(Color2 < 0 || Color2 > 126) return print("Wrong ColorID! Color IDs start at 0 and end at 126!"), 1;
    if(!ReturnCarID(CarName)) return print("Unknown vehicle name!"), 1;
    OptionalID = ReturnCarID(CarName);
    GetPlayerPos(id, PlayerCoords[0], PlayerCoords[1], PlayerCoords[2]);
    GetPlayerFacingAngle(id, PlayerCoords[3]);
    CreateVehicle(OptionalID, PlayerCoords[0]+3.0, PlayerCoords[1], PlayerCoords[2], PlayerCoords[3], Color1, Color2, 99*999);
    SendClientMessage(id, lightblue, "Remote admin has given you a vehicle!");
    printf("Player %s (ID: %i) was given a vehicle! (%s)", GetPlayerNick(id), id, CarName);
    return 1;
}
but it always go to the 'by_name', even if I type ID instead of Name... Anybody can help me?
Reply


Messages In This Thread
Sscanf problem. - by pulposlaw - 03.06.2009, 12:32
Re: Sscanf problem. - by Weirdosport - 03.06.2009, 14:31
Re: Sscanf problem. - by pulposlaw - 03.06.2009, 14:39
Re: Sscanf problem. - by Weirdosport - 03.06.2009, 14:44
Re: Sscanf problem. - by pulposlaw - 03.06.2009, 14:56

Forum Jump:


Users browsing this thread: 1 Guest(s)