VStorage Bug
#1

Hey,
I have a problem with the Vehicle Storage in my server, When I register to my server the vehicle storage is full with cars that I didn't buy, How can I remove it?

Codes:

PHP код:
CMD:vstorage(playeridparams[])
{
    if(
PlayerTied[playerid] != || PlayerCuffed[playerid] != || PlayerInfo[playerid][pJailTime] > || GetPVarInt(playerid"Injured")) return SendClientMessageEx(playeridCOLOR_GRAD2"You cannot do this at this time.");
    if(
PlayerInfo[playerid][pFreezeCar] == || PlayerInfo[playerid][pAdmin] >= 2)
    {
        new 
vstring[4096], icount GetPlayerVehicleSlots(playerid);
        for(new 
iiModelIDicounti++) {
            if((
iModelID PlayerVehicleInfo[playerid][i][pvModelId] - 400) >= 0) {
                if(
PlayerVehicleInfo[playerid][i][pvImpounded]) {
                    
format(vstringsizeof(vstring), "%s\n%s (impounded)"vstringVehicleName[iModelID]);
                }
                else if(
PlayerVehicleInfo[playerid][i][pvDisabled]) {
                    
format(vstringsizeof(vstring), "%s\n%s (disabled)"vstringVehicleName[iModelID]);
                }
                else if(!
PlayerVehicleInfo[playerid][i][pvSpawned]) {
                    
format(vstringsizeof(vstring), "%s\n%s (stored)"vstringVehicleName[iModelID]);
                }
                else 
format(vstringsizeof(vstring), "%s\n%s (spawned)"vstringVehicleName[iModelID]);
            }
            else 
strcat(vstring"\nEmpty");
        }
        
format(vstringsizeof(vstring), "%s\n{40FFFF}Additional Vehicle Slot {FFD700}(Credits: %s){A9C4E4}"vstringnumber_format(ShopItems[23][sItemPrice]));
        
ShowPlayerDialog(playeridVEHICLESTORAGEDIALOG_STYLE_LIST"Vehicle storage"vstring"(De)spawn""Cancel");
    }
    else { return 
SendClientMessageEx(playeridCOLOR_GRAD2"Your vehicle assets have been frozen by the Judiciary.  Consult your local courthouse to have this cleared"); }
    return 
1;

PHP код:
    if(dialogid == VEHICLESTORAGE && response) {
        
//if(!(400 <= PlayerVehicleInfo[playerid][listitem][pvModelId] <= 611))
        //printf("DEBUG: listitem: %d, Vehicle Slots: %d", listitem, GetPlayerVehicleSlots(playerid));
        
if(listitem == GetPlayerVehicleSlots(playerid)) {
            new 
szstring[128];
            
SetPVarInt(playerid"MiscShop"7);
            
format(szstringsizeof(szstring), "Additional Vehicle Slot\nYour Credits: %s\nCost: {FFD700}%s{A9C4E4}\nCredits Left: %s"number_format(PlayerInfo[playerid][pCredits]), number_format(ShopItems[23][sItemPrice]), number_format(PlayerInfo[playerid][pCredits]-ShopItems[23][sItemPrice]));
            return 
ShowPlayerDialog(playeridDIALOG_MISCSHOP2DIALOG_STYLE_MSGBOX"Purchase a additional vehicle slot"szstring"Purchase""Cancel");
        }
        if(
PlayerVehicleInfo[playerid][listitem][pvSpawned]) {
            new
                
iVehicleID PlayerVehicleInfo[playerid][listitem][pvId];
            if((!
IsVehicleOccupied(iVehicleID) || IsPlayerInVehicle(playeridiVehicleID)) && !IsVehicleInTow(iVehicleID)) {
                new
                    
Floatvehiclehealth;
                
GetVehicleHealth(iVehicleIDvehiclehealth);
                if(
vehiclehealth 800) {
                    
SendClientMessageEx(playeridCOLOR_WHITE"This vehicle is too damaged to be stored.");
                }
                   else if (
GetPVarInt(playerid"Refueling") == PlayerVehicleInfo[playerid][listitem][pvId])
                    
SendClientMessageEx(playeridCOLOR_WHITE"You can not store a vehicle while it is being refueled.");
                else {
                    --
PlayerCars;
                    
VehicleSpawned[playerid]--;
                    
PlayerVehicleInfo[playerid][listitem][pvSpawned] = 0;
                    
PlayerVehicleInfo[playerid][listitem][pvFuel] = VehicleFuel[iVehicleID];
                    
DestroyVehicle(iVehicleID);
                    
PlayerVehicleInfo[playerid][listitem][pvId] = INVALID_PLAYER_VEHICLE_ID;
                    
g_mysql_SaveVehicle(playeridlistitem);
                    new 
vstring[128];
                    
format(vstringsizeof(vstring), "You have stored your %s. The vehicle has been despawned."VehicleName[PlayerVehicleInfo[playerid][listitem][pvModelId] - 400]);
                    
SendClientMessageEx(playeridCOLOR_WHITEvstring);
                    
CheckPlayerVehiclesForDesync(playerid);
                }
            }
            else 
SendClientMessageEx(playeridCOLOR_WHITE"This vehicle is currently occupied - it cannot be despawned right now.");
        }
        else if(
PlayerVehicleInfo[playerid][listitem][pvImpounded]) {
            
SendClientMessageEx(playeridCOLOR_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(playeridCOLOR_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()) && IsRestrictedVehicle(PlayerVehicleInfo[playerid][listitem][pvModelId]))
        {
            
SendClientMessageEx(playeridCOLOR_GREY"You are not authorized to spawn this restricted vehicle.");
        }
        else if(!
PlayerVehicleInfo[playerid][listitem][pvSpawned]) {
            if(
PlayerInfo[playerid][pDonateRank] == && VehicleSpawned[playerid] >= 2) {
                
SendClientMessageEx(playeridCOLOR_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] == && VehicleSpawned[playerid] >= 2) {
                
SendClientMessageEx(playeridCOLOR_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] == && VehicleSpawned[playerid] >= 2) {
                
SendClientMessageEx(playeridCOLOR_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] == && VehicleSpawned[playerid] >= 3) {
                
SendClientMessageEx(playeridCOLOR_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] == && VehicleSpawned[playerid] >= 5) {
                
SendClientMessageEx(playeridCOLOR_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] == && VehicleSpawned[playerid] >= 5) {
                
SendClientMessageEx(playeridCOLOR_GREY"As Diamond 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)) {
                
SendClientMessageEx(playeridCOLOR_GREY"You have an invalid VIP level.");
            }
            else if((
PlayerVehicleInfo[playerid][listitem][pvModelId]) < 400) {
                
SendClientMessageEx(playeridCOLOR_GREY"The vehicle slot is empty.");
            }
            else { 
Reply
#2

first reset for all vehicles storge then load just for buyed vehicles...
Reply
#3

Quote:
Originally Posted by Dusan01
Посмотреть сообщение
first reset for all vehicles storge then load just for buyed vehicles...
How can I do it?

My problem is when I register my vstorage is full, I didn't buy any cars, When I register its full with randomly cars.
Reply
#4

Put this Before player stats is loaded(OnPlayerConnect)
Код:
for (new i = 0; i < MAX_VEHICLES; i++) {
	PlayerVehicleInfo[playerid][i][pvImpounded] = 0; //replace 0 with default value when is storage empty
	PlayerVehicleInfo[playerid][i][pvDisabled] = 0; //replace 0 with default value when is storage empty
	PlayerVehicleInfo[playerid][i][pvSpawned] = 0; //replace 0 with default value when is storage empty
}
Reply
#5

Quote:
Originally Posted by Dusan01
Посмотреть сообщение
Put this Before player stats is loaded(OnPlayerConnect)
Код:
for (new i = 0; i < MAX_VEHICLES; i++) {
	PlayerVehicleInfo[playerid][i][pvImpounded] = 0; //replace 0 with default value when is storage empty
	PlayerVehicleInfo[playerid][i][pvDisabled] = 0; //replace 0 with default value when is storage empty
	PlayerVehicleInfo[playerid][i][pvSpawned] = 0; //replace 0 with default value when is storage empty
}
Reply
#6

When I compiled the script it doesn't show any error.
I using CrashDetect so maybe it detect a crash problem.
Reply
#7

give me enumator of: PlayerVehicleInfo
Reply
#8

Quote:
Originally Posted by Dusan01
Посмотреть сообщение
Put this Before player stats is loaded(OnPlayerConnect)
Код:
for (new i = 0; i < MAX_VEHICLES; i++) {
	PlayerVehicleInfo[playerid][i][pvImpounded] = 0; //replace 0 with default value when is storage empty
	PlayerVehicleInfo[playerid][i][pvDisabled] = 0; //replace 0 with default value when is storage empty
	PlayerVehicleInfo[playerid][i][pvSpawned] = 0; //replace 0 with default value when is storage empty
}
Quote:
Originally Posted by Dusan01
Посмотреть сообщение
give me enumator of: PlayerVehicleInfo
Look, Instead of your command, I found this

PHP код:
    for(new 0MAX_PLAYERVEHICLES; ++i) {
        
PlayerVehicleInfo[playerid][i][pvModelId] = 0;
        
PlayerVehicleInfo[playerid][i][pvId] = INVALID_PLAYER_VEHICLE_ID;
        
PlayerVehicleInfo[playerid][i][pvSpawned] = 0;
        
PlayerVehicleInfo[playerid][i][pvSlotId] = 0;
    } 
Does it help you?
Reply
#9

yea, that should be in OnPlayerConnect to reset players storage...
Reply
#10

Quote:
Originally Posted by Dusan01
Посмотреть сообщение
yea, that should be in OnPlayerConnect to reset players storage...
Well, I have it already, but it doesnt helping me.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)