how to skip a part of a command for sscanf? -
Apenmeeuw - 11.03.2013
hey all,
i made this command "/v" with parameters "park, respawn, color, get", but now i have a problem at the color.
when i want to set the color of the car, it's like this:
/v color color1 color2.
so i did this:
pawn Код:
CMD:v(playerid, params[])
{
if(strcmp(params,"color",true) == 0)
{
if(GetPlayerVehicleID(playerid) != PlayerVeh) return SendClientMessage(playerid, COLOR_RED, "This ain't your current car, use / v get to change your current car.");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You aren't in any vehicle.");
if(IsValidVehicleID(GetPlayerVehicleID(playerid)))
{
new col1, col2;
if(sscanf(params, "dd", col1, col2)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: {FF0000}/v color [color1] [color2]");
ChangeVehicleColor(GetPlayerVehicleID(playerid), col1, col2);
SendClientMessage(playerid, COLOR_GREEN, "You have successfully changed your Vehicle colors");
SaveVehComponents(playerid, PlayerVeh, CurrentSlot(playerid));
}
}
return 1;
}
but when i do for example "/v color 1 1" it says: correct usage: /v color/respawn/get/park.
so i have to skip a certain part of the command for sscanf... but how can i do this?
greets
Re: how to skip a part of a command for sscanf? -
Denying - 11.03.2013
May we see your other /v command?
I assume that you have one as it says "correct usage: /v color/respawn/get/park"
Re: how to skip a part of a command for sscanf? -
IstuntmanI - 11.03.2013
Try changing
pawn Код:
new col1, col2;
if(sscanf(params, "dd", col1, col2)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: {FF0000}/v color [color1] [color2]");
with
pawn Код:
new col1, col2, uString[ 32 ];
if(sscanf(params, "s[32]dd", uString, col1, col2)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: {FF0000}/v color [color1] [color2]");
"s[32]" because in "params" first is "color", then color1 and color2.
Re: how to skip a part of a command for sscanf? -
Apenmeeuw - 11.03.2013
pawn Код:
CMD:v(playerid, params[])
{
if(Player[playerid][IsInGarage] == 1) return SendClientMessage(playerid, COLOR_RED,"You can't use this command when you're in your garage");
if(strcmp(params,"park",true) == 0)
{
if(GetPlayerVehicleID(playerid) != PlayerVeh) return SendClientMessage(playerid, COLOR_RED, "This ain't your current car, use / v get to change your current car.");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You aren't in any vehicle.");
new Float:x, Float:y, Float:z, Float:angle;
new vid = GetPlayerVehicleID(playerid);
GetVehiclePos(vid, x, y, z);
GetVehicleZAngle(vid, angle);
SaveFloatToCarSlot(playerid, CurrentSlot(playerid), "XSpawn", x );
SaveFloatToCarSlot(playerid, CurrentSlot(playerid), "YSpawn", y );
SaveFloatToCarSlot(playerid, CurrentSlot(playerid), "ZSpawn", z );
SaveFloatToCarSlot(playerid, CurrentSlot(playerid), "ASpawn", angle );
SaveVehComponents(playerid, PlayerVeh, CurrentSlot(playerid));
foreach(Player, i)
{
if(IsPlayerInVehicle(playerid, vid))
{
RemovePlayerFromVehicle(i);
}
}
SetVehiclePosZAngle( vid, x, y, z, angle );
PutPlayerInVehicle(playerid, vid, 0);
SendClientMessage(playerid, COLOR_WHITE, "Car Succesfully Parked.");
}
else if(strcmp(params,"color",true) == 0)
{
if(GetPlayerVehicleID(playerid) != PlayerVeh) return SendClientMessage(playerid, COLOR_RED, "This ain't your current car, use / v get to change your current car.");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You aren't in any vehicle.");
if(IsValidVehicleID(GetPlayerVehicleID(playerid)))
{
new col1, col2;
if(sscanf(params, "dd", col1, col2)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: {FF0000}/v color [color1] [color2]");
ChangeVehicleColor(GetPlayerVehicleID(playerid), col1, col2);
SendClientMessage(playerid, COLOR_GREEN, "You have successfully changed your Vehicle colors");
SaveVehComponents(playerid, PlayerVeh, CurrentSlot(playerid));
}
}
else if(strcmp(params,"get",true) == 0)
{
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_BLUE, "you need to be onfoot to teleport vehicles");
new string1[50], string2[50], string3[50], string4[50], string[128];
if(PlayerCars[playerid][0] != -1)
{
format(string1, sizeof(string1), "%s", GetVehicleNameByModel(PlayerCars[playerid][0]));
}
else if(PlayerCars[playerid][0] == -1 )
{
format(string1, sizeof(string1), "Empty Slot");
}
if( PlayerCars[playerid][1] != -1 )
{
format(string2, sizeof(string2), "%s", GetVehicleNameByModel(PlayerCars[playerid][1]));
}
else if( PlayerCars[playerid][1] == -1 )
{
format(string2, sizeof(string2), "Empty Slot");
}
if( PlayerCars[playerid][2] != -1 )
{
format(string3, sizeof(string3), "%s", GetVehicleNameByModel(PlayerCars[playerid][2]));
}
else if( PlayerCars[playerid][2] == -1 )
{
format(string3, sizeof(string3), "Empty Slot");
}
if( PlayerCars[playerid][3] != -1 )
{
format(string4, sizeof(string4), "%s", GetVehicleNameByModel(PlayerCars[playerid][3]));
}
else if( PlayerCars[playerid][3] == -1 )
{
format(string4, sizeof(string4), "Empty Slot");
}
format(string, sizeof(string), "%s\n%s\n%s\n%s", string1, string2, string3, string4);
ShowPlayerDialog(playerid, DIALOG_GETCARS, DIALOG_STYLE_LIST, "Vehicle Respawning", string, "Respawn", "Cancel");
}
else if(strcmp(params,"respawn",true) == 0)
{
new string1[50], string2[50], string3[50], string4[50], string[128];
if(PlayerCars[playerid][0] != -1)
{
format(string1, sizeof(string1), "%s", GetVehicleNameByModel(PlayerCars[playerid][0]));
}
else if(PlayerCars[playerid][0] == -1 )
{
format(string1, sizeof(string1), "Empty Slot");
}
if( PlayerCars[playerid][1] != -1 )
{
format(string2, sizeof(string2), "%s", GetVehicleNameByModel(PlayerCars[playerid][1]));
}
else if( PlayerCars[playerid][1] == -1 )
{
format(string2, sizeof(string2), "Empty Slot");
}
if( PlayerCars[playerid][2] != -1 )
{
format(string3, sizeof(string3), "%s", GetVehicleNameByModel(PlayerCars[playerid][2]));
}
else if( PlayerCars[playerid][2] == -1 )
{
format(string3, sizeof(string3), "Empty Slot");
}
if( PlayerCars[playerid][3] != -1 )
{
format(string4, sizeof(string4), "%s", GetVehicleNameByModel(PlayerCars[playerid][3]));
}
else if( PlayerCars[playerid][3] == -1 )
{
format(string4, sizeof(string4), "Empty Slot");
}
format(string, sizeof(string), "%s\n%s\n%s\n%s", string1, string2, string3, string4);
ShowPlayerDialog(playerid, DIALOG_RESPAWNCARS, DIALOG_STYLE_LIST, "Vehicle Respawning", string, "Respawn", "Cancel");
}
else return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: /v [PARK/GET/RESPAWN/COLOR]");
return 1;
}
and i will try that costel

thanks
EDIT: costel that didnt work
Re: how to skip a part of a command for sscanf? -
Apenmeeuw - 12.03.2013
bump...
Re: how to skip a part of a command for sscanf? -
Denying - 12.03.2013
You can't use the same command twice, I mean.. if you want something like when a player types /v and it shows him "USAGE: /v park | get | blabla" you have to do an actual command when a player types only /v it will send him that message and the rest of the commands as "/v park" and "/v get" etc..
Re: how to skip a part of a command for sscanf? -
Apenmeeuw - 12.03.2013
i see... so i have to make 4 seperated commands for this?
Re: how to skip a part of a command for sscanf? -
Denying - 12.03.2013
That's correct. If you have four options for /v
Re: how to skip a part of a command for sscanf? -
Apenmeeuw - 12.03.2013
alright, then how can i fix this?
pawn Код:
CMD:vget(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_BLUE, "you need to be onfoot to teleport vehicles");
new string1[50], string2[50], string3[50], string4[50], string[128];
if(PlayerCars[playerid][0] != -1)
{
format(string1, sizeof(string1), "%s", GetVehicleNameByModel(PlayerCars[playerid][0]));
}
else if(PlayerCars[playerid][0] == -1 )
{
format(string1, sizeof(string1), "Empty Slot");
}
if( PlayerCars[playerid][1] != -1 )
{
format(string2, sizeof(string2), "%s", GetVehicleNameByModel(PlayerCars[playerid][1]));
}
else if( PlayerCars[playerid][1] == -1 )
{
format(string2, sizeof(string2), "Empty Slot");
}
if( PlayerCars[playerid][2] != -1 )
{
format(string3, sizeof(string3), "%s", GetVehicleNameByModel(PlayerCars[playerid][2]));
}
else if( PlayerCars[playerid][2] == -1 )
{
format(string3, sizeof(string3), "Empty Slot");
}
if( PlayerCars[playerid][3] != -1 )
{
format(string4, sizeof(string4), "%s", GetVehicleNameByModel(PlayerCars[playerid][3]));
}
else if( PlayerCars[playerid][3] == -1 )
{
format(string4, sizeof(string4), "Empty Slot");
}
format(string, sizeof(string), "%s\n%s\n%s\n%s", string1, string2, string3, string4);
ShowPlayerDialog(playerid, DIALOG_GETCARS, DIALOG_STYLE_LIST, "Vehicle Teleporting", string, "Respawn", "Cancel");
return 1;
}
pawn Код:
CMD:col(playerid, params[])
{
if(GetPlayerVehicleID(playerid) != PlayerVeh) return SendClientMessage(playerid, COLOR_RED, "This ain't your current car, use /v get to change your current car.");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You aren't in any vehicle.");
if(IsValidVehicleID(GetPlayerVehicleID(playerid)))
{
new col1, col2, uString[32];
if(sscanf(params, "s[32]dd", uString, col1, col2)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: {FF0000}/v color [color1] [color2]");
ChangeVehicleColor(GetPlayerVehicleID(playerid), col1, col2);
SendClientMessage(playerid, COLOR_GREEN, "You have successfully changed your Vehicle colors");
SaveVehComponents(playerid, PlayerVeh, CurrentSlot(playerid));
}
return 1;
}
when i do /v color it says: usage: /v color col1 col2.
when i do /v color 1 1 it says: /v [respawn/lock/color/etc]
Re: how to skip a part of a command for sscanf? -
Apenmeeuw - 14.03.2013
bump...