Vehicle spawner.
#1

Command :
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;
}
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 :
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];
}
Hope someone will help me,
Thanks.
Reply


Messages In This Thread
Vehicle spawner. - by biker122 - 30.03.2014, 15:13
Re: Vehicle spawner. - by RenovanZ - 30.03.2014, 15:19
Re: Vehicle spawner. - by biker122 - 30.03.2014, 15:21
Re: Vehicle spawner. - by RenovanZ - 30.03.2014, 15:25
Re: Vehicle spawner. - by biker122 - 30.03.2014, 15:28
Re: Vehicle spawner. - by RenovanZ - 30.03.2014, 15:32
Re: Vehicle spawner. - by biker122 - 30.03.2014, 15:40

Forum Jump:


Users browsing this thread: 1 Guest(s)