03.06.2009, 14:56
You helped me and I helped you. We both learned something.
@up.
I've already made a command that works as it's supposed to.
It's also possible to make with IsNumeric. But first of all, IsNumeric should have modified return values.
@up.
I've already made a command that works as it's supposed to.
pawn Код:
dcmd_gpv(params[])
{
new CarName[32], id, OptionalID, Color1, Color2;
new Float: PlayerCoords[4];
if(sscanf(params, "uddd", id, OptionalID, Color1, Color2)) //if it "aint" that
{
if(!sscanf(params, "usid", id, CarName, Color1, Color2)) //but it is that - go to the appropriate script part
{
goto by_name;
}
else //if it "aint" that either - tell them they fail
{
return print("Usage: /gpv [playerid/PartOfName] [CarID/CarName] [Color 1] [Color 2]"), 1;
}
}
else
{
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! (%s)", GetPlayerNick(id), id, VehicleNames[OptionalID-400]);
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;
}
return 1;
}