30.03.2014, 15:13
Command :
What's wrong with this? When I type /v it will show a dialog. It's perfect. But, When I type /v (carname), It spawns the same car even if I type someother car ID's / names.
I don't know the name of the car, sorry.
and "CreatePlayerVehicle" function :
Hope someone will help me,
Thanks.
pawn Code:
CMD:v(playerid,params[])
{
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"[ERROR] You already have a vehicle!");
new vehicle;
vehicle = GetVehicleModelIDFromName(params);
if(isnull(params)) return ShowPlayerDefaultDialog(playerid);
if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid,COLOR_RED,"[ERROR] Invalid vehicle name!");
CreatePlayerVehicle(playerid,vehicle);
return 1;
}
I don't know the name of the car, sorry.
and "CreatePlayerVehicle" function :
pawn Code:
function CreatePlayerVehicle(playerid, modelid)
{
if(PlayerInfo[playerid][PlayerCar] != -1 && !IsVehicleOccupied(PlayerInfo[playerid][PlayerCar]))
{
DestroyVehicle(PlayerInfo[playerid][PlayerCar]);
PlayerInfo[playerid][PlayerCar] = -1;
}
new Float:x, Float:y, Float:z, Float:a;
GetPlayerFacingAngle(playerid, a);
GetPlayerPos(playerid, x, y, z);
PlayerInfo[playerid][PlayerCar] = CreateVehicle(modelid, x, y, z, a, random(255), random(255), -1);
LinkVehicleToInterior(PlayerInfo[playerid][PlayerCar], GetPlayerInterior(playerid));
PutPlayerInVehicle(playerid, PlayerInfo[playerid][PlayerCar], 0);
return PlayerInfo[playerid][PlayerCar];
}
Thanks.