Vehicle Storage
#1

Hi,
i am trying to fix my vstorage script.
The problem is that its somtimes duplicate the vehicles and doing a lot of problems...
script:
pawn Код:
CMD:vstorage(playerid, params[])
{
    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");
    }
    ShowPlayerDialog(playerid, VEHICLESTORAGE, DIALOG_STYLE_LIST, "Vehicle storage", vstring, "(De)spawn", "Cancel");
    return 1;
}*
pawn Код:
if(dialogid == VEHICLESTORAGE && response) {
        if(PlayerVehicleInfo[playerid][listitem][pvSpawned]) {

            new
                iVehicleID = PlayerVehicleInfo[playerid][listitem][pvId];

            if((!IsVehicleOccupied(iVehicleID) || IsPlayerInVehicle(playerid, iVehicleID)) && !IsVehicleInTow(iVehicleID)) {

                new
                    Float: vehiclehealth;

                GetVehicleHealth(iVehicleID, vehiclehealth);

                if(vehiclehealth < 800) {
                    SendClientMessageEx(playerid, COLOR_WHITE, "This vehicle is too damaged to be stored.");
                }
                else {
                    --PlayerCars;
                    VehicleSpawned[playerid]--;
                    PlayerVehicleInfo[playerid][listitem][pvSpawned] = 0;
                    PlayerVehicleInfo[playerid][listitem][pvFuel] = VehicleFuel[iVehicleID];
                    VehicleFuel[iVehicleID] = 100.0;
                    DestroyVehicle(iVehicleID);
                    PlayerVehicleInfo[playerid][listitem][pvId] = INVALID_PLAYER_VEHICLE_ID;

                    new vstring[128];
                    format(vstring, sizeof(vstring), "You have stored your %s. The vehicle has been despawned.", VehicleName[PlayerVehicleInfo[playerid][listitem][pvModelId] - 400]);
                    SendClientMessageEx(playerid, COLOR_WHITE, vstring);
                }
            }
            else SendClientMessageEx(playerid, COLOR_WHITE, "This vehicle is currently occupied - it cannot be despawned right now.");
        }
        else if(PlayerVehicleInfo[playerid][listitem][pvImpounded]) {
            SendClientMessageEx(playerid, COLOR_WHITE, "You can not spawn an impounded vehicle. If you wish to reclaim it, do so at the DMV in Dillimore.");
        }
        else if(PlayerVehicleInfo[playerid][listitem][pvDisabled]) {
            SendClientMessageEx(playerid, COLOR_WHITE, "You can not spawn a disabled vehicle. It is disabled due to your VIP level (vehicle restrictions).");
        }
        else if((PlayerInfo[playerid][pRVehRestricted] > gettime() || PlayerVehicleInfo[playerid][listitem][pvRestricted] > gettime()) && IsWeaponisedVehicle(PlayerVehicleInfo[playerid][listitem][pvModelId]))
        {
            SendClientMessageEx(playerid, COLOR_GREY, "You are not authorized to spawn this restricted vehicle.");
        }
        else if(!PlayerVehicleInfo[playerid][listitem][pvSpawned]) {
            if(PlayerInfo[playerid][pDonateRank] == 0 && VehicleSpawned[playerid] >= 2) {
                SendClientMessageEx(playerid, COLOR_GREY, "As non-VIP you can only have 2 vehicles spawned. You must store a vehicle in order to spawn another one.");
            }
            else if(PlayerInfo[playerid][pDonateRank] == 1 && VehicleSpawned[playerid] >= 2) {
                SendClientMessageEx(playerid, COLOR_GREY, "As Bronze VIP you can only have 2 vehicles spawned. You must store a vehicle in order to spawn another one.");
            }
            else if(PlayerInfo[playerid][pDonateRank] == 2 && VehicleSpawned[playerid] >= 2) {
                SendClientMessageEx(playerid, COLOR_GREY, "As Silver VIP you can only have 2 vehicles spawned. You must store a vehicle in order to spawn another one.");
            }
            else if(PlayerInfo[playerid][pDonateRank] == 3 && VehicleSpawned[playerid] >= 3) {
                SendClientMessageEx(playerid, COLOR_GREY, "As Gold VIP you can only have 3 vehicles spawned. You must store a vehicle in order to spawn another one.");
            }
            else if(PlayerInfo[playerid][pDonateRank] == 4 && VehicleSpawned[playerid] >= 5) {
                SendClientMessageEx(playerid, COLOR_GREY, "As Platinum VIP you can only have 5 vehicles spawned. You must store a vehicle in order to spawn another one.");
            }
            else if(PlayerInfo[playerid][pDonateRank] == 5 && VehicleSpawned[playerid] >= 5) {
                SendClientMessageEx(playerid, COLOR_GREY, "As VIP Moderator you can only have 5 vehicles spawned. You must store a vehicle in order to spawn another one.");
            }
            else if(!(0 <= PlayerInfo[playerid][pDonateRank] <= 5)) {
                SendClientMessageEx(playerid, COLOR_GREY, "You have an invalid VIP level.");
            }
            else if((PlayerVehicleInfo[playerid][listitem][pvModelId]) < 400) {
                SendClientMessageEx(playerid, COLOR_GREY, "The vehicle slot is empty.");
            }
            else {

                new
                    iVeh = CreateVehicle(PlayerVehicleInfo[playerid][listitem][pvModelId], PlayerVehicleInfo[playerid][listitem][pvPosX], PlayerVehicleInfo[playerid][listitem][pvPosY], PlayerVehicleInfo[playerid][listitem][pvPosZ], PlayerVehicleInfo[playerid][listitem][pvPosAngle],PlayerVehicleInfo[playerid][listitem][pvColor1], PlayerVehicleInfo[playerid][listitem][pvColor2], -1);

                ++PlayerCars;
                VehicleSpawned[playerid]++;
                PlayerVehicleInfo[playerid][listitem][pvSpawned] = 1;
                PlayerVehicleInfo[playerid][listitem][pvId] = iVeh;
                VehicleFuel[iVeh] = PlayerVehicleInfo[playerid][listitem][pvFuel];
                if(PlayerVehicleInfo[playerid][listitem][pvLocked] == 1) LockPlayerVehicle(playerid, iVeh, PlayerVehicleInfo[playerid][listitem][pvLock]);
                LoadPlayerVehicleMods(playerid, listitem);

                new vstring[64];
                format(vstring, sizeof(vstring), "You have taken your %s out of storage.", VehicleName[PlayerVehicleInfo[playerid][listitem][pvModelId] - 400]);
                SendClientMessageEx(playerid, COLOR_WHITE, vstring);

                new szPrefix[32], tmpFVehModelId, Float:tmpFVehPos[4];

                format(szPrefix, sizeof(szPrefix), "tmpVeh%dModelId", listitem);
                tmpFVehModelId = GetPVarInt(playerid, szPrefix);
                DeletePVar(playerid, szPrefix);
                format(szPrefix, sizeof(szPrefix), "tmpVeh%dPosX", listitem);
                tmpFVehPos[0] = GetPVarFloat(playerid, szPrefix);
                DeletePVar(playerid, szPrefix);
                format(szPrefix, sizeof(szPrefix), "tmpVeh%dPosY", listitem);
                tmpFVehPos[1] = GetPVarFloat(playerid, szPrefix);
                DeletePVar(playerid, szPrefix);
                format(szPrefix, sizeof(szPrefix), "tmpVeh%dPosZ", listitem);
                tmpFVehPos[2] = GetPVarFloat(playerid, szPrefix);
                DeletePVar(playerid, szPrefix);
                format(szPrefix, sizeof(szPrefix), "tmpVeh%dAngle", listitem);
                tmpFVehPos[3] = GetPVarFloat(playerid, szPrefix);
                DeletePVar(playerid, szPrefix);

                if(tmpFVehPos[0] != 0.0 && tmpFVehModelId == PlayerVehicleInfo[playerid][listitem][pvModelId])
                {
                    SetVehiclePos(iVeh, tmpFVehPos[0], tmpFVehPos[1], tmpFVehPos[2]);
                    SetVehicleZAngle(iVeh, tmpFVehPos[3]);

                    SendClientMessageEx(playerid, COLOR_WHITE, "Your vehicle has been restored to it's last known location from your previous timeout.");
                }
            }
        }
        else SendClientMessageEx(playerid, COLOR_WHITE, "You can not spawn a non-existent vehicle.");
    }
Reply
#2

Help?
Reply
#3

NGRP script, no thank you!
Reply
#4

Quote:
Originally Posted by MattSlater
Посмотреть сообщение
NGRP script, no thank you!
Its not NG RP Script!
any other help?
Reply
#5

Hello someone?
Reply
#6

Hi??
Reply
#7

Please help?
Reply
#8

Please?
Reply
#9

someone?
Reply
#10

How many times are you gonna bump in 1 day?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)