Createpvehicle -_-
#1

This error


As you can see, That ID "451" is a turismo vehicle but it says ERROR -_-

Heres my codes

pawn Код:
CMD:createpvehicle(playerid, params[])
{

   
    if(PlayerInfo[playerid][pAdmin] < 4)
    {
        SendClientMessage(playerid, COLOR_GREY, "You're not allowed to use this command.");
        return 1;
    }
    new playervehicleid = GetPlayerFreeVehicleId(playerid);
    if(AdminDuty[playerid] != 1 && PlayerInfo[playerid][pAdmin] < 6)
    {
        SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
        return 1;
    }
    new string[128], giveplayerid, modelid, color1, color2;
    if(sscanf(params, "uddd", giveplayerid, modelid, color1, color2)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /createpvehicle [playerid/partofname] [modelid] [color 1] [color 2]");

    if(AdminDuty[giveplayerid] == 1)
    {
        SendClientMessage(playerid,COLOR_WHITE, "You can't use that command on an on-duty admin.");
        return 1;
    }



    if(color1 < 0 || color1 > 255) { SendClientMessage(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 255!"); return 1; }
    if(color2 < 0 || color2 > 255) { SendClientMessage(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 255!"); return 1; }
    if(modelid < 400 || modelid > 611) { SendClientMessage(playerid, COLOR_GREY, "   Vehicle Number can't be below 400 or above 611!"); return 1; }

    new carsamount = GetPlayerVehicleCount(giveplayerid);
    // (TEMPORARY - ZHAO NOTE) TempDonator not added yet
    if(PlayerInfo[giveplayerid][pDonator] == 0 && carsamount >= 5) //PlayerInfo[giveplayerid][pTempDonator] > 0) && carsamount >= 5)
    {
        SendClientMessage(giveplayerid, COLOR_GREY, "That player can't have more cars, non-donator can only own 5 cars.");
        return 1;
    }
    if(PlayerInfo[giveplayerid][pDonator] == 1 && carsamount >= 7)
    {
        SendClientMessage(playerid, COLOR_GREY, "That player can't have more cars, Bronze Donator can only own 7 cars.");
        return 1;
    }
    if(PlayerInfo[giveplayerid][pDonator] == 2 && carsamount >= 8)
    {
        SendClientMessage(playerid, COLOR_GREY, "That player can't have more cars, Silver Donator can only own 8 cars.");
        return 1;
    }
    if(PlayerInfo[giveplayerid][pDonator] == 3 && carsamount >= 10)
    {
        SendClientMessage(playerid, COLOR_GREY, "That player can't have more cars, Gold Donator can only own 10 cars.");
        return 1;
    }
    /*if(PlayerInfo[giveplayerid][pDonator] >= 4 && carsamount >= 10)
    {
        SendClientMessage(giveplayerid, COLOR_GREY, "That player can't have more cars, Platinum+ VIP can only own 10 cars.");
        return 1;
    }*/


    if(playervehicleid == -1) return SendClientMessage(playerid, COLOR_GREY, "ERROR: That player can't have more cars.");
    if(PlayerInfo[giveplayerid][pDonator] == 0 && VehicleSpawned[giveplayerid] >= 1)
    {
        SendClientMessage(playerid, COLOR_GREY, "That player is non-donator and can only have 1 vehicle spawned. The player must store that vehicle in order to create a new one.");
        return 1;
    }
    if(PlayerInfo[giveplayerid][pDonator] == 1 && VehicleSpawned[giveplayerid] >= 2)
    {
        SendClientMessage(playerid, COLOR_GREY, "That player is Bronze Donator and can only have 2 vehicles spawned. The player must store that vehicle in order to create a new one.");
        return 1;
    }
    if(PlayerInfo[giveplayerid][pDonator] == 2 && VehicleSpawned[giveplayerid] >= 3)
    {
        SendClientMessage(playerid, COLOR_GREY, "That player is Silver Donator and can only have 3 vehicles spawned. The player must store a vehicle in order to create a new one.");
        return 1;
    }
    /*if(PlayerInfo[giveplayerid][pDonator] == 3 && VehicleSpawned[giveplayerid] >= 4)
    {
        SendClientMessage(playerid, COLOR_GREY, "That player is Gold Donator and can only have 4 vehicles spawned. The player must store a vehicle in order to create a new one.");
        return 1;
    }*/

    /*if(PlayerInfo[giveplayerid][pDonator] == 4 && VehicleSpawned[giveplayerid] >= 5)
    {
        SendClientMessage(giveplayerid, COLOR_GREY, "That player is Undefined Donator and can only have 5 vehicles spawned. The player must store a vehicle in order to create a new one.");
        return 1;
    }
    if(PlayerInfo[giveplayerid][pDonator] == 5 && VehicleSpawned[giveplayerid] >= 5)
    {
        SendClientMessage(giveplayerid, COLOR_GREY, "That player is a VIP Moderator and can only have 5 vehicles spawned. The player must store a vehicle in order to create a new one.");
        return 1;
    }*/

    if(PlayerInfo[giveplayerid][pDonator] < 0 || PlayerInfo[giveplayerid][pDonator] > 3)
    {
        SendClientMessage(playerid, COLOR_GREY, "ERROR: That player has an invalid Donator level.");
        return 1;
    }

    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(giveplayerid,X,Y,Z);
    new Float:Angle;
    GetPlayerFacingAngle(giveplayerid,Angle);
    new car = CreatePlayerVehicle(giveplayerid, playervehicleid, modelid, X, Y, Z, Angle, color1, color2, 0);
    if(car == INVALID_PLAYER_VEHICLE_ID)
    {
        return SendClientMessage(playerid, COLOR_GREY, "ERROR: Something went wrong and the car didn't get created.");
    }
    else
    {
        format(string, sizeof(string), " Vehicle successfully created with ID %d.", car);
        SendClientMessage(playerid, COLOR_GRAD1, string);

        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(car, engine, lights, alarm, doors, bonnet, boot, objective);
        SetVehicleParamsEx(car, 0,lights,alarm,doors,bonnet,boot,objective);
    }

    format(string, sizeof(string), "%s has created a %s for %s (Color 1: %d | Color 2: %d).", GetPlayerNameEx(playerid), GetVehicleName(car), GetPlayerNameEx(giveplayerid), color1, color2);
    Log("logs/playervehicle.log", string);
    return 1;
}
And my stock
pawn Код:
stock CreatePlayerVehicle(playerid, playervehicleid, modelid, Float: x, Float: y, Float: z, Float: angle, color1, color2, price)
{
    if(PlayerVehicleInfo[playerid][playervehicleid][pvId] == INVALID_PLAYER_VEHICLE_ID)
    {
        VehicleSpawned[playerid]++;
        PlayerCars++;
        PlayerVehicleInfo[playerid][playervehicleid][pvModelId] = modelid;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosX] = x;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosY] = y;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosZ] = z;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosAngle] = angle;
        PlayerVehicleInfo[playerid][playervehicleid][pvColor1] = color1;
        PlayerVehicleInfo[playerid][playervehicleid][pvColor2] = color2;
        PlayerVehicleInfo[playerid][playervehicleid][pvPark] = 1;
        PlayerVehicleInfo[playerid][playervehicleid][pvPrice] = price;
        PlayerVehicleInfo[playerid][playervehicleid][pvFuel] = 100.0;
        PlayerVehicleInfo[playerid][playervehicleid][pvImpounded] = 0;
        for(new m = 0; m < MAX_MODS; m++)
        {
            PlayerVehicleInfo[playerid][playervehicleid][pvMods][m] = 0;
        }
        new carcreated = AddStaticVehicleEx(modelid,x,y,z,angle,color1,color2,-1);
        PlayerVehicleInfo[playerid][playervehicleid][pvId] = carcreated;
        PlayerVehicleInfo[playerid][playervehicleid][pvSpawned] = 1;
        SetVehicleNumberPlate(carcreated, PlayerVehicleInfo[playerid][playervehicleid][pvNumberPlate]);
        return carcreated;
    }
    return INVALID_PLAYER_VEHICLE_ID;
}
Reply
#2

Which error?
Reply
#3

Quote:
Originally Posted by Affan
Посмотреть сообщение
Which error?
uhh, Saying like I created first the vehicle then after i created it says the ERROR thing

For example:

Код:
Successfully Vehicle Created with ID 451
ERROR Example:
Код:
Successfully Vehicle Created with ID 451
ERROR: Something went wrong vehicle didnt created!
Reply
#4

pawn Код:
CMD:createpvehicle(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "You're not allowed to use this command.");
    if(!AdminDuty[playerid] && PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
    new giveplayerid, modelid, color1, color2;
    if(sscanf(params, "udD(-1)D(-1)", giveplayerid, modelid, color1, color2)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /createpvehicle [playerid/partofname] [modelid] [color 1] [color 2]");
    if(!IsPlayerConnected(giveplayerid) || giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "Player not connected.");
    if(AdminDuty[giveplayerid]) return SendClientMessage(playerid, COLOR_WHITE, "You can't use that command on an on-duty admin.");
    if(!(-1 < color1 < 256)) return SendClientMessage(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 255!");
    if(!(-1 < color2 < 256)) return SendClientMessage(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 255!");
    if(!(399 < modelid < 612)) return SendClientMessage(playerid, COLOR_GREY, "   Vehicle Model can't be below 400 or above 611!");
    new carsamount = GetPlayerVehicleCount(giveplayerid);
    // (TEMPORARY - ZHAO NOTE) TempDonator not added yet
    switch(PlayerInfo[giveplayerid][pDonator])
    {
        case 0:
        {
            if(carsamount >= 5) return SendClientMessage(giveplayerid, COLOR_GREY, "That player can't have more cars, non-donator can only own 5 cars.");
            if(VehicleSpawned[giveplayerid] >= 1) return SendClientMessage(playerid, COLOR_GREY, "That player is non-donator and can only have 1 vehicle spawned. The player must store that vehicle in order to create a new one.");
        }
        case 1:
        {
            if(carsamount >= 7) return SendClientMessage(playerid, COLOR_GREY, "That player can't have more cars, Bronze Donator can only own 7 cars.");
            if(VehicleSpawned[giveplayerid] >= 2) return SendClientMessage(playerid, COLOR_GREY, "That player is Bronze Donator and can only have 2 vehicles spawned. The player must store that vehicle in order to create a new one.");
        }
        case 2:
        {
            if(carsamount >= 8) return SendClientMessage(playerid, COLOR_GREY, "That player can't have more cars, Silver Donator can only own 8 cars.");
            if(VehicleSpawned[giveplayerid] >= 3) return SendClientMessage(playerid, COLOR_GREY, "That player is Silver Donator and can only have 3 vehicles spawned. The player must store a vehicle in order to create a new one.");
        }
        case 3:
        {
            if(carsamount >= 10) return SendClientMessage(playerid, COLOR_GREY, "That player can't have more cars, Gold Donator can only own 10 cars.");
            //if(VehicleSpawned[giveplayerid] >= 4) return SendClientMessage(playerid, COLOR_GREY, "That player is Gold Donator and can only have 4 vehicles spawned. The player must store a vehicle in order to create a new one.");
        }
        /*case 4:
        {
            if(carsamount >= 10) return SendClientMessage(giveplayerid, COLOR_GREY, "That player can't have more cars, Platinum+ VIP can only own 10 cars.");
            if(VehicleSpawned[giveplayerid] >= 5) return SendClientMessage(giveplayerid, COLOR_GREY, "That player is Undefined Donator and can only have 5 vehicles spawned. The player must store a vehicle in order to create a new one.");
        }
        case 5:
        {
            //...
        }*/

        default: return SendClientMessage(playerid, COLOR_GREY, "ERROR: That player has an invalid Donator level.");
    }
    new playervehicleid = GetPlayerFreeVehicleId(playerid);
    if(playervehicleid == -1) return SendClientMessage(playerid, COLOR_GREY, "ERROR: That player can't have more cars.");
    new Float:X, Float:Y, Float:Z, Float:Angle;
    GetPlayerPos(giveplayerid, X, Y, Z);
    GetPlayerFacingAngle(giveplayerid, Angle);
    new car = CreatePlayerVehicle(giveplayerid, playervehicleid, modelid, X, Y, Z, Angle, color1, color2, 0);
    if(car == INVALID_PLAYER_VEHICLE_ID) return SendClientMessage(playerid, COLOR_GREY, "ERROR: Something went wrong and the car didn't get created.");
    new fstr[128], engine, lights, alarm, doors, bonnet, boot, objective;
    format(fstr, sizeof(fstr), " Vehicle successfully created with ID %d.", car);
    SendClientMessage(playerid, COLOR_GRAD1, fstr);
    GetVehicleParamsEx(car, engine, lights, alarm, doors, bonnet, boot, objective);
    SetVehicleParamsEx(car, 0, lights, alarm, doors, bonnet, boot, objective);
    format(fstr, sizeof(fstr), "%s has created a %s for %s (Color 1: %d | Color 2: %d).", GetPlayerNameEx(playerid), GetVehicleName(car), GetPlayerNameEx(giveplayerid), color1, color2);
    Log("logs/playervehicle.log", fstr);
    return 1;
}

stock CreatePlayerVehicle(playerid, playervehicleid, modelid, Float: x, Float: y, Float: z, Float: angle, color1, color2, price)
{
    if(PlayerVehicleInfo[playerid][playervehicleid][pvId] == INVALID_PLAYER_VEHICLE_ID)
    {
        VehicleSpawned[playerid]++;
        PlayerCars++;
        PlayerVehicleInfo[playerid][playervehicleid][pvModelId] = modelid;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosX] = x;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosY] = y;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosZ] = z;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosAngle] = angle;
        PlayerVehicleInfo[playerid][playervehicleid][pvColor1] = color1;
        PlayerVehicleInfo[playerid][playervehicleid][pvColor2] = color2;
        PlayerVehicleInfo[playerid][playervehicleid][pvPark] = 1;
        PlayerVehicleInfo[playerid][playervehicleid][pvPrice] = price;
        PlayerVehicleInfo[playerid][playervehicleid][pvFuel] = 100.0;
        PlayerVehicleInfo[playerid][playervehicleid][pvImpounded] = 0;
        for(new m = 0; m < MAX_MODS; m++) PlayerVehicleInfo[playerid][playervehicleid][pvMods][m] = 0;
        new carcreated = CreateVehicle(modelid, x, y, z, angle, color1, color2, -1);
        PlayerVehicleInfo[playerid][playervehicleid][pvId] = carcreated;
        PlayerVehicleInfo[playerid][playervehicleid][pvSpawned] = 1;
        SetVehicleNumberPlate(carcreated, PlayerVehicleInfo[playerid][playervehicleid][pvNumberPlate]);
        return carcreated;
    }
    return INVALID_PLAYER_VEHICLE_ID;
}
Reply
#5

Quote:
Originally Posted by Threshold
Посмотреть сообщение
pawn Код:
CMD:createpvehicle(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "You're not allowed to use this command.");
    if(!AdminDuty[playerid] && PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
    new giveplayerid, modelid, color1, color2;
    if(sscanf(params, "udD(-1)D(-1)", giveplayerid, modelid, color1, color2)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /createpvehicle [playerid/partofname] [modelid] [color 1] [color 2]");
    if(!IsPlayerConnected(giveplayerid) || giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "Player not connected.");
    if(AdminDuty[giveplayerid]) return SendClientMessage(playerid, COLOR_WHITE, "You can't use that command on an on-duty admin.");
    if(!(-1 < color1 < 256)) return SendClientMessage(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 255!");
    if(!(-1 < color2 < 256)) return SendClientMessage(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 255!");
    if(!(399 < modelid < 612)) return SendClientMessage(playerid, COLOR_GREY, "   Vehicle Model can't be below 400 or above 611!");
    new carsamount = GetPlayerVehicleCount(giveplayerid);
    // (TEMPORARY - ZHAO NOTE) TempDonator not added yet
    switch(PlayerInfo[giveplayerid][pDonator])
    {
        case 0:
        {
            if(carsamount >= 5) return SendClientMessage(giveplayerid, COLOR_GREY, "That player can't have more cars, non-donator can only own 5 cars.");
            if(VehicleSpawned[giveplayerid] >= 1) return SendClientMessage(playerid, COLOR_GREY, "That player is non-donator and can only have 1 vehicle spawned. The player must store that vehicle in order to create a new one.");
        }
        case 1:
        {
            if(carsamount >= 7) return SendClientMessage(playerid, COLOR_GREY, "That player can't have more cars, Bronze Donator can only own 7 cars.");
            if(VehicleSpawned[giveplayerid] >= 2) return SendClientMessage(playerid, COLOR_GREY, "That player is Bronze Donator and can only have 2 vehicles spawned. The player must store that vehicle in order to create a new one.");
        }
        case 2:
        {
            if(carsamount >= 8) return SendClientMessage(playerid, COLOR_GREY, "That player can't have more cars, Silver Donator can only own 8 cars.");
            if(VehicleSpawned[giveplayerid] >= 3) return SendClientMessage(playerid, COLOR_GREY, "That player is Silver Donator and can only have 3 vehicles spawned. The player must store a vehicle in order to create a new one.");
        }
        case 3:
        {
            if(carsamount >= 10) return SendClientMessage(playerid, COLOR_GREY, "That player can't have more cars, Gold Donator can only own 10 cars.");
            //if(VehicleSpawned[giveplayerid] >= 4) return SendClientMessage(playerid, COLOR_GREY, "That player is Gold Donator and can only have 4 vehicles spawned. The player must store a vehicle in order to create a new one.");
        }
        /*case 4:
        {
            if(carsamount >= 10) return SendClientMessage(giveplayerid, COLOR_GREY, "That player can't have more cars, Platinum+ VIP can only own 10 cars.");
            if(VehicleSpawned[giveplayerid] >= 5) return SendClientMessage(giveplayerid, COLOR_GREY, "That player is Undefined Donator and can only have 5 vehicles spawned. The player must store a vehicle in order to create a new one.");
        }
        case 5:
        {
            //...
        }*/

        default: return SendClientMessage(playerid, COLOR_GREY, "ERROR: That player has an invalid Donator level.");
    }
    new playervehicleid = GetPlayerFreeVehicleId(playerid);
    if(playervehicleid == -1) return SendClientMessage(playerid, COLOR_GREY, "ERROR: That player can't have more cars.");
    new Float:X, Float:Y, Float:Z, Float:Angle;
    GetPlayerPos(giveplayerid, X, Y, Z);
    GetPlayerFacingAngle(giveplayerid, Angle);
    new car = CreatePlayerVehicle(giveplayerid, playervehicleid, modelid, X, Y, Z, Angle, color1, color2, 0);
    if(car == INVALID_PLAYER_VEHICLE_ID) return SendClientMessage(playerid, COLOR_GREY, "ERROR: Something went wrong and the car didn't get created.");
    new fstr[128], engine, lights, alarm, doors, bonnet, boot, objective;
    format(fstr, sizeof(fstr), " Vehicle successfully created with ID %d.", car);
    SendClientMessage(playerid, COLOR_GRAD1, fstr);
    GetVehicleParamsEx(car, engine, lights, alarm, doors, bonnet, boot, objective);
    SetVehicleParamsEx(car, 0, lights, alarm, doors, bonnet, boot, objective);
    format(fstr, sizeof(fstr), "%s has created a %s for %s (Color 1: %d | Color 2: %d).", GetPlayerNameEx(playerid), GetVehicleName(car), GetPlayerNameEx(giveplayerid), color1, color2);
    Log("logs/playervehicle.log", fstr);
    return 1;
}

stock CreatePlayerVehicle(playerid, playervehicleid, modelid, Float: x, Float: y, Float: z, Float: angle, color1, color2, price)
{
    if(PlayerVehicleInfo[playerid][playervehicleid][pvId] == INVALID_PLAYER_VEHICLE_ID)
    {
        VehicleSpawned[playerid]++;
        PlayerCars++;
        PlayerVehicleInfo[playerid][playervehicleid][pvModelId] = modelid;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosX] = x;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosY] = y;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosZ] = z;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosAngle] = angle;
        PlayerVehicleInfo[playerid][playervehicleid][pvColor1] = color1;
        PlayerVehicleInfo[playerid][playervehicleid][pvColor2] = color2;
        PlayerVehicleInfo[playerid][playervehicleid][pvPark] = 1;
        PlayerVehicleInfo[playerid][playervehicleid][pvPrice] = price;
        PlayerVehicleInfo[playerid][playervehicleid][pvFuel] = 100.0;
        PlayerVehicleInfo[playerid][playervehicleid][pvImpounded] = 0;
        for(new m = 0; m < MAX_MODS; m++) PlayerVehicleInfo[playerid][playervehicleid][pvMods][m] = 0;
        new carcreated = CreateVehicle(modelid, x, y, z, angle, color1, color2, -1);
        PlayerVehicleInfo[playerid][playervehicleid][pvId] = carcreated;
        PlayerVehicleInfo[playerid][playervehicleid][pvSpawned] = 1;
        SetVehicleNumberPlate(carcreated, PlayerVehicleInfo[playerid][playervehicleid][pvNumberPlate]);
        return carcreated;
    }
    return INVALID_PLAYER_VEHICLE_ID;
}
Thanks

Whats the problem at my previous codes?
Reply
#6

FUCK!! YOUR CODES DOESNT WORKS
Reply
#7

it only works when creating the vehicle onto myself but When im creating to player, After creating 1 vehicle then if i create again it says that error thing!

Someone help me please ?
Reply
#8

pawn Код:
CMD:createpvehicle(playerid, params[])
{

    if (PlayerInfo[playerid][pAdmin] < 4)
    {
        SendClientMessageEx(playerid, COLOR_GREY, " You are not allowed to use this command.");
        return 1;
    }

    new string[128], giveplayerid, modelid, color1, color2;
    if(sscanf(params, "uddd", giveplayerid, modelid, color1, color2)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /createpvehicle [playerid] [modelid] [color 1] [color 2]");

    if(color1 < 0 || color1 > 126) { SendClientMessageEx(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 126 !"); return 1; }
    if(color2 < 0 || color2 > 126) { SendClientMessageEx(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 126 !"); return 1; }
    if(modelid < 400 || modelid > 611) { SendClientMessageEx(playerid, COLOR_GREY, "   Vehicle Number can't be below 400 or above 611 !"); return 1; }
    new playervehicleid = GetPlayerFreeVehicleId(giveplayerid); new carsamount = GetPlayerVehicleCount(giveplayerid);
    if(playervehicleid == -1) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: That player can't have more cars.");
    if(PlayerInfo[giveplayerid][pDonateRank] == 0 && carsamount >= 7) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You can't have more cars.");
    if(PlayerInfo[giveplayerid][pDonateRank] == 1 && carsamount >= 8) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You can't have more cars.");
    if(PlayerInfo[giveplayerid][pDonateRank] == 2 && carsamount >= 9) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You can't have more cars.");
    if(PlayerInfo[giveplayerid][pDonateRank] == 3 && carsamount >= 10) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You can't have more cars.");
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(giveplayerid,X,Y,Z);
    new Float:Angle;
    GetPlayerFacingAngle(giveplayerid,Angle);
    new car = CreatePlayerVehicle(giveplayerid, playervehicleid, modelid, X, Y, Z, Angle, color1, color2, 0);
    if(car == INVALID_PLAYER_VEHICLE_ID)
    {
        SendClientMessageEx(playerid, COLOR_GREY, "ERROR: Something went wrong and the car didn't get created.");
    }
    else
    {
        format(string, sizeof(string), " Vehicle successfully created with ID %d.", car);
        SendClientMessageEx(playerid, COLOR_GRAD1, string);
    }

    format(string, sizeof(string), "%s has created a %s for %s (Color 1: %d | Color 2: %d).", GetPlayerNameEx(playerid), GetVehicleName(car), GetPlayerNameEx(giveplayerid), color1, color2);
    Log("logs/playervehicle.log", string);
    return 1;
}
pawn Код:
stock CreatePlayerVehicle(playerid, playervehicleid, modelid, Float: x, Float: y, Float: z, Float: angle, color1, color2, price)
{
    if(PlayerVehicleInfo[playerid][playervehicleid][pvId] == INVALID_PLAYER_VEHICLE_ID)
    {
        PlayerCars++;
        PlayerVehicleInfo[playerid][playervehicleid][pvModelId] = modelid;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosX] = x;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosY] = y;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosZ] = z;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosAngle] = angle;
        PlayerVehicleInfo[playerid][playervehicleid][pvColor1] = color1;
        PlayerVehicleInfo[playerid][playervehicleid][pvColor2] = color2;
        PlayerVehicleInfo[playerid][playervehicleid][pvPark] = 1;
        PlayerVehicleInfo[playerid][playervehicleid][pvPrice] = price;
        PlayerVehicleInfo[playerid][playervehicleid][pvFuel] = 100.0;
        PlayerVehicleInfo[playerid][playervehicleid][pvImpounded] = 0;
        for(new m = 0; m < MAX_MODS; m++)
        {
            PlayerVehicleInfo[playerid][playervehicleid][pvMods][m] = 0;
        }
        new carcreated = CreateVehicle(modelid,x,y,z,angle,color1,color2,-1);
        PlayerVehicleInfo[playerid][playervehicleid][pvId] = carcreated;
        //SetVehicleNumberPlate(carcreated, PlayerVehicleInfo[playerid][playervehicleid][pvNumberPlate]);
        return carcreated;
    }
    return INVALID_PLAYER_VEHICLE_ID;
}
Reply
#9

Quote:
Originally Posted by Max5
Посмотреть сообщение
pawn Код:
CMD:createpvehicle(playerid, params[])
{

    if (PlayerInfo[playerid][pAdmin] < 4)
    {
        SendClientMessageEx(playerid, COLOR_GREY, " You are not allowed to use this command.");
        return 1;
    }

    new string[128], giveplayerid, modelid, color1, color2;
    if(sscanf(params, "uddd", giveplayerid, modelid, color1, color2)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /createpvehicle [playerid] [modelid] [color 1] [color 2]");

    if(color1 < 0 || color1 > 126) { SendClientMessageEx(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 126 !"); return 1; }
    if(color2 < 0 || color2 > 126) { SendClientMessageEx(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 126 !"); return 1; }
    if(modelid < 400 || modelid > 611) { SendClientMessageEx(playerid, COLOR_GREY, "   Vehicle Number can't be below 400 or above 611 !"); return 1; }
    new playervehicleid = GetPlayerFreeVehicleId(giveplayerid); new carsamount = GetPlayerVehicleCount(giveplayerid);
    if(playervehicleid == -1) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: That player can't have more cars.");
    if(PlayerInfo[giveplayerid][pDonateRank] == 0 && carsamount >= 7) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You can't have more cars.");
    if(PlayerInfo[giveplayerid][pDonateRank] == 1 && carsamount >= 8) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You can't have more cars.");
    if(PlayerInfo[giveplayerid][pDonateRank] == 2 && carsamount >= 9) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You can't have more cars.");
    if(PlayerInfo[giveplayerid][pDonateRank] == 3 && carsamount >= 10) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You can't have more cars.");
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(giveplayerid,X,Y,Z);
    new Float:Angle;
    GetPlayerFacingAngle(giveplayerid,Angle);
    new car = CreatePlayerVehicle(giveplayerid, playervehicleid, modelid, X, Y, Z, Angle, color1, color2, 0);
    if(car == INVALID_PLAYER_VEHICLE_ID)
    {
        SendClientMessageEx(playerid, COLOR_GREY, "ERROR: Something went wrong and the car didn't get created.");
    }
    else
    {
        format(string, sizeof(string), " Vehicle successfully created with ID %d.", car);
        SendClientMessageEx(playerid, COLOR_GRAD1, string);
    }

    format(string, sizeof(string), "%s has created a %s for %s (Color 1: %d | Color 2: %d).", GetPlayerNameEx(playerid), GetVehicleName(car), GetPlayerNameEx(giveplayerid), color1, color2);
    Log("logs/playervehicle.log", string);
    return 1;
}
pawn Код:
stock CreatePlayerVehicle(playerid, playervehicleid, modelid, Float: x, Float: y, Float: z, Float: angle, color1, color2, price)
{
    if(PlayerVehicleInfo[playerid][playervehicleid][pvId] == INVALID_PLAYER_VEHICLE_ID)
    {
        PlayerCars++;
        PlayerVehicleInfo[playerid][playervehicleid][pvModelId] = modelid;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosX] = x;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosY] = y;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosZ] = z;
        PlayerVehicleInfo[playerid][playervehicleid][pvPosAngle] = angle;
        PlayerVehicleInfo[playerid][playervehicleid][pvColor1] = color1;
        PlayerVehicleInfo[playerid][playervehicleid][pvColor2] = color2;
        PlayerVehicleInfo[playerid][playervehicleid][pvPark] = 1;
        PlayerVehicleInfo[playerid][playervehicleid][pvPrice] = price;
        PlayerVehicleInfo[playerid][playervehicleid][pvFuel] = 100.0;
        PlayerVehicleInfo[playerid][playervehicleid][pvImpounded] = 0;
        for(new m = 0; m < MAX_MODS; m++)
        {
            PlayerVehicleInfo[playerid][playervehicleid][pvMods][m] = 0;
        }
        new carcreated = CreateVehicle(modelid,x,y,z,angle,color1,color2,-1);
        PlayerVehicleInfo[playerid][playervehicleid][pvId] = carcreated;
        //SetVehicleNumberPlate(carcreated, PlayerVehicleInfo[playerid][playervehicleid][pvNumberPlate]);
        return carcreated;
    }
    return INVALID_PLAYER_VEHICLE_ID;
}
Thanks you, Problem Solved
Reply
#10

ANOTHER shit problem -_-

I added his code

pawn Код:
CMD:createpvehicle(playerid, params[])
{

    if (PlayerInfo[playerid][pAdmin] < 4)
    {
        SendClientMessageEx(playerid, COLOR_GREY, " You are not allowed to use this command.");
        return 1;
    }

    new string[128], giveplayerid, modelid, color1, color2;
    if(sscanf(params, "uddd", giveplayerid, modelid, color1, color2)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /createpvehicle [playerid] [modelid] [color 1] [color 2]");

    if(color1 < 0 || color1 > 126) { SendClientMessageEx(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 126 !"); return 1; }
    if(color2 < 0 || color2 > 126) { SendClientMessageEx(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 126 !"); return 1; }
    if(modelid < 400 || modelid > 611) { SendClientMessageEx(playerid, COLOR_GREY, "   Vehicle Number can't be below 400 or above 611 !"); return 1; }
    new playervehicleid = GetPlayerFreeVehicleId(giveplayerid); new carsamount = GetPlayerVehicleCount(giveplayerid);
    if(playervehicleid == -1) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: That player can't have more cars.");
    if(PlayerInfo[giveplayerid][pDonator] == 0 && carsamount >= 7) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: That player cant have more cars.");
    if(PlayerInfo[giveplayerid][pDonator] == 1 && carsamount >= 8) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: That player cant have more cars.");
    if(PlayerInfo[giveplayerid][pDonator] == 2 && carsamount >= 9) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: That player cant have more cars.");
    if(PlayerInfo[giveplayerid][pDonator] == 3 && carsamount >= 10) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: That player cant have more cars.");
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(giveplayerid,X,Y,Z);
    new Float:Angle;
    GetPlayerFacingAngle(giveplayerid,Angle);
    new car = CreatePlayerVehicle(giveplayerid, playervehicleid, modelid, X, Y, Z, Angle, color1, color2, 0);
    if(car == INVALID_PLAYER_VEHICLE_ID)
    {
        SendClientMessageEx(playerid, COLOR_GREY, "ERROR: Something went wrong and the car didn't get created.");
    }
    else
    {
        format(string, sizeof(string), " Vehicle successfully created with ID %d.", car);
        SendClientMessageEx(playerid, COLOR_GRAD1, string);
    }

    format(string, sizeof(string), "%s has created a %s for %s (Color 1: %d | Color 2: %d).", GetPlayerNameEx(playerid), GetVehicleName(car), GetPlayerNameEx(giveplayerid), color1, color2);
    Log("logs/playervehicle.log", string);
    return 1;
}
Then now it doesnt save on the /vstorage thing -_- i created but i didnt see on /vstorage the vehicle i created!

pawn Код:
CMD:vstorage(playerid, params[])
{
    if(AdminDuty[playerid] == 1)
    {
        SendClientMessage(playerid,COLOR_WHITE, "You can't use this command while on-duty as admin.");
        return 1;
    }
    new vstring[1024];
    for(new i, iModelID; i < MAX_PLAYERVEHICLES; i++) {
        if((iModelID = PlayerVehicleInfo[playerid][i][pvModelId] - 400) >= 0) {
            if(PlayerVehicleInfo[playerid][i][pvImpounded]) {
                format(vstring, sizeof(vstring), "%s\n%s (impounded)", vstring, VehicleName[iModelID]);
            }
            else if(PlayerVehicleInfo[playerid][i][pvDisabled]) {
                format(vstring, sizeof(vstring), "%s\n%s (disabled)", vstring, VehicleName[iModelID]);
            }
            else if(!PlayerVehicleInfo[playerid][i][pvSpawned]) {
                format(vstring, sizeof(vstring), "%s\n%s (stored)", vstring, VehicleName[iModelID]);
            }
            else format(vstring, sizeof(vstring), "%s\n%s (spawned)", vstring, VehicleName[iModelID]);
        }
        else strcat(vstring, "\nEmpty");
    }
    ShowPlayerDialogEx(playerid, VEHICLESTORAGE, DIALOG_STYLE_LIST, "Vehicle storage", vstring, "(De)spawn", "Cancel");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)