05.03.2017, 12:08
I saw the error in serverlog , but really don't know why its happens
Park cmd:
House_AddVehicle :
House_ReplaceVehicle :
Vehicle_Delete:
Dialog_GetCarSelectHouse :
What can cause this?
PHP код:
14:44:35] [debug] Run time error 4: "Array index out of bounds"
[14:44:35] [debug] Attempted to read/write array element at index 65535 in array of size 2000
[14:44:35] [debug] AMX backtrace:
[14:44:35] [debug] #0 00031bb4 in House_AddVehicle (HouseID=3, cModel=0, cPaint=256, cComponents[]=@00405cbc "", Float:cx=283.04770, Float:cy=-1168.74146, Float:cz=80.46407, Float:crot=290.78180, Col1=16, Col2=16) at E:\V1-1.1.1\pawno\include\PPC_Housing.inc:237
[14:44:35] [debug] #1 00033030 in House_ReplaceVehicle (HouseID=3, CarSlot=3) at E:\V1-1.1.1\pawno\include\PPC_Housing.inc:317
[14:44:35] [debug] #2 00083d9c in public cmd_park (playerid=0, params[]=@003def40 "") at E:\V1-1.1.1\pawno\include\PPC_PlayerCommands.inc:651
[14:44:35] [debug] #3 native CallLocalFunction () from samp03svr
[14:44:35] [debug] #4 00008690 in public OnPlayerCommandText (playerid=0, cmdtext[]=@003def28 "/park") at E:\V1-1.1.1\pawno\include\izcmd.inc:120
[14:44:43] [debug] Run time error 4: "Array index out of bounds"
[14:44:43] [debug] Attempted to read/write array element at index 65535 in array of size 2000
[14:44:43] [debug] AMX backtrace:
[14:44:43] [debug] #0 0006dda8 in Dialog_GetCarSelectHouse (playerid=0, response=1, listitem=0) at E:\V1-1.1.1\pawno\include\PPC_Dialogs.inc:1645
[14:44:43] [debug] #1 000c4cfc in public OnDialogResponse (playerid=0, dialogid=48, response=1, listitem=0, inputtext[]=@003def28 "Totul cu stil <3 !!!") at E:\V1-1.1.1\gamemodes\Lejiune.pwn:1133
PHP код:
CMD:park(playerid, params[])
{
// Send the command to all admins so they can see it
SendAdminText(playerid, "/park", params);
// Check if the player is inside a vehicle (he must be the driver)
if (GetPlayerVehicleSeat(playerid) == 0)
{
new vid, HouseID;
// Get the vehicle-id
vid = GetPlayerVehicleID(playerid);
// Get the HouseID to which this vehicle belongs
HouseID = AVehicleData[vid][BelongsToHouse];
// Check if the vehicle is owned (owner-check is not really required, as another player would get kicked out very fast)
// AND it must belong to a house that the player owns
if ((AVehicleData[vid][Owned] == 1) && (HouseID != 0))
{
// Check if the vehicle is in range of the house-entrance (you cannot park a vehicle further away from your house than 150m)
if (IsPlayerInRangeOfPoint(playerid, ParkRange, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]))
{
new Float:x, Float:y, Float:z, Float:rot,query[164];
// Get the player's position and angle
GetVehiclePos(vid, x, y, z);
GetVehicleZAngle(vid, rot);
// Save those values for the vehicle
AVehicleData[vid][SpawnX] = x;
AVehicleData[vid][SpawnY] = y;
AVehicleData[vid][SpawnZ] = z;
AVehicleData[vid][SpawnRot] = rot;
mysql_format(g_SQL, query, sizeof(query), "UPDATE `vehicles` SET `CarX` = %f, `CarY` = %f, `CarZ` = %f,`CarA` = %f WHERE `ID` = %i",AVehicleData[vid][SpawnX],AVehicleData[vid][SpawnY],AVehicleData[vid][SpawnZ],AVehicleData[vid][SpawnRot],AVehicleData[vid][IDD]);
mysql_tquery(g_SQL, query, "","");
// Find the vehicle in the player's houses
for (new i; i < MAX_HOUSESPERPLAYER; i++)
{
// Get the HouseID of the current house
HouseID = APlayerData[playerid][Houses][i];
// Loop through all carslots of this house to find the vehicle-id
for (new CarSlot; CarSlot < 10; CarSlot++)
{
// Check if this carslot holds the same vehicle-id
if (AHouseData[HouseID][VehicleIDs][CarSlot] == vid)
{
new engine,lights,alarm,doors,bonnet,boot,objective;
House_ReplaceVehicle(HouseID, CarSlot); // Re-create the vehicle at the same spot the player wants to park his vehicle
PutPlayerInVehicle(playerid, AHouseData[HouseID][VehicleIDs][CarSlot], 0);
// Turn on the engine
GetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(AHouseData[HouseID][VehicleIDs][CarSlot], 1, lights, alarm, doors, bonnet, boot, objective);
break; // Stop the for-loop
}
}
}
// Let the player know he parked his vehicle
SendClientMessage(playerid, 0x00FF00FF, "Ti-ai parcat masina");
}
else
{
new Msg[128];
format(Msg, sizeof(Msg), "{FF0000}Nu trebuie sa te aflii la mai mult de %im de casa pentru a parca masina.", ParkRange);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
}
}
else
SendClientMessage(playerid, 0xFF0000FF, "Nu deti masina");
}
else
SendClientMessage(playerid, 0xFF0000FF, "Trebuie sa conduci masina");
// Let the server know that this was a valid command
return 1;
}
PHP код:
House_AddVehicle(HouseID, cModel, cPaint, cComponents[], Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2)
{
// Setup local variables
new vid, CarSlot;
// Get a free carslot from the house
CarSlot = House_GetFreeCarSlot(HouseID);
// Check if there is a free carslot
if (CarSlot != -1)
{
// Create a new vehicle and get the vehicle-id
vid = CreateVehicle(cModel, cx, cy, cz, crot, Col1, Col2, 600);
// Store the vehicle-id in the house's free carslot
AHouseData[HouseID][VehicleIDs][CarSlot] = vid;
// Save the model of the vehicle
AVehicleData[vid][Model] = cModel;
// Save the paintjob of the vehicle and apply it
AVehicleData[vid][PaintJob] = cPaint;
if (cPaint != 0)
ChangeVehiclePaintjob(vid, cPaint - 1);
// Also update the car-color
ChangeVehicleColor(vid, Col1, Col2);
// Save the colors of the vehicle
AVehicleData[vid][Color1] = Col1;
AVehicleData[vid][Color2] = Col2;
// Save the components of the vehicle and apply them
for (new i; i < 14; i++)
{
AVehicleData[vid][Components][i] = cComponents[i];
// Check if the componentslot has a valid component-id
if (AVehicleData[vid][Components][i] != 0)
AddVehicleComponent(vid, AVehicleData[vid][Components][i]); // Add the component to the vehicle
}
// Save the spawn-data of the vehicle
AVehicleData[vid][SpawnX] = cx;
AVehicleData[vid][SpawnY] = cy;
AVehicleData[vid][SpawnZ] = cz;
AVehicleData[vid][SpawnRot] = crot;
// Also set the fuel to maximum
AVehicleData[vid][Fuel] = MaxFuel;
// Also set the owner
AVehicleData[vid][Owned] = 1;
format(AVehicleData[vid][Owner], 24, AHouseData[HouseID][Owner]);
// Save the HouseID for the vehicle
AVehicleData[vid][BelongsToHouse] = HouseID;
AVehicleData[vid][Pid] = AHouseData[HouseID][Pid];
// Add a 3DText label to the vehicle, displaying the name of the owner
new query[500];
mysql_format(g_SQL, query, sizeof(query), "INSERT INTO `vehicles` (`ModelID`,`Fuel`,`Color1`,`Color2`,`CarX`,`CarY`,`CarZ`, `CarA`,`Owned`, `Owner`, `BelongsToHouse`,`pid`) VALUES (%i,%i,%i,%i,%f,%f,%f,%f,%i,'%e',%i,%i)",AVehicleData[vid][Model],AVehicleData[vid][Fuel],AVehicleData[vid][Color1],AVehicleData[vid][Color2],AVehicleData[vid][SpawnX],AVehicleData[vid][SpawnY],AVehicleData[vid][SpawnZ],AVehicleData[vid][SpawnRot],AVehicleData[vid][Owned],AVehicleData[vid][Owner],HouseID,AHouseData[HouseID][Pid]);
mysql_tquery(g_SQL, query, "OnVehicleInsertID","i",vid);
print(query);
}
else // No free carslot was found, return 0
return 0;
// Exit the function and return the vehicle-id
return vid;
}
PHP код:
House_ReplaceVehicle(HouseID, CarSlot)
{
// Setup local variables
new vid, cModel, cPaint, cComponents[14], Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2, Float:Health, cFuel;
new panels, doors, lights, tires;
// Get the data from the already existing vehicle that was parked before
vid = AHouseData[HouseID][VehicleIDs][CarSlot];
cModel = AVehicleData[vid][Model];
cPaint = AVehicleData[vid][PaintJob];
cFuel = AVehicleData[vid][Fuel];
for (new i; i < 14; i++)
cComponents[i] = AVehicleData[vid][Components][i];
Col1 = AVehicleData[vid][Color1];
Col2 = AVehicleData[vid][Color2];
cx = AVehicleData[vid][SpawnX];
cy = AVehicleData[vid][SpawnY];
cz = AVehicleData[vid][SpawnZ];
crot = AVehicleData[vid][SpawnRot];
GetVehicleHealth(vid, Health);
GetVehicleDamageStatus(vid, panels, doors, lights, tires);
// Delete the vehicle and clear the data
Vehicle_Delete(vid);
// Create a new vehicle in the same carslot
vid = House_AddVehicle(HouseID, cModel, cPaint, cComponents, Float:cx, Float:cy, Float:cz, Float:crot, Col1, Col2);
// Update the fuel of the vehicle to the previous setting
AVehicleData[vid][Fuel] = cFuel;
// Update the health to what it was before and update the bodywork
SetVehicleHealth(vid, Health);
UpdateVehicleDamageStatus(vid, panels, doors, lights, tires);
return vid;
}
PHP код:
Vehicle_Delete(vid)
{
// Setup local variables
new HouseID, CarSlot;
// Get the HouseID and CarSlot where the vehicle is linked to
HouseID = AVehicleData[vid][BelongsToHouse];
// Check if this was a valid HouseID
if (HouseID != 0)
{
// Loop through all carslots of this house to find the vehicle-id
for (new i; i < 10; i++)
{
// Check if this carslot holds the same vehicle-id
if (AHouseData[HouseID][VehicleIDs][i] == vid)
{
CarSlot = i; // The carslot has been found where the vehicle is stored, remember it
break; // Stop the for-loop
}
}
// Remove the vehicle from the house
AHouseData[HouseID][VehicleIDs][CarSlot] = 0;
}
// Delete the vehicle
DestroyVehicle(vid);
// Clear the data
AVehicleData[vid][Owned] = 0;
AVehicleData[vid][Owner] = 0;
AVehicleData[vid][Model] = 0;
AVehicleData[vid][PaintJob] = 0;
for (new i; i < 14; i++)
AVehicleData[vid][Components][i] = 0;
AVehicleData[vid][Color1] = 0;
AVehicleData[vid][Color2] = 0;
AVehicleData[vid][SpawnX] = 0.0;
AVehicleData[vid][SpawnY] = 0.0;
AVehicleData[vid][SpawnZ] = 0.0;
AVehicleData[vid][SpawnRot] = 0.0;
AVehicleData[vid][BelongsToHouse] = 0;
new query[264];
mysql_format(g_SQL, query, sizeof(query), "DELETE FROM `vehicles` WHERE `ID` = %i LIMIT 1", AVehicleData[vid][IDD]);
mysql_tquery(g_SQL, query, "","");
}
PHP код:
Dialog_GetCarSelectHouse(playerid, response, listitem)
{
// Just close the dialog if the player clicked "Cancel"
if(!response) return 1;
// Get the houseid based on the chosen listitem
new HouseID = APlayerData[playerid][Houses][listitem];
// Check if it was a valid house
if (HouseID != 0)
{
// Setup local variables
new BuyableCarIndex, VehicleList[500], bool:HouseHasCars = false, CarSlot;
// Store the HouseID, otherwise the next dialog won't be able to get a car from the chosen house
APlayerData[playerid][DialogGetCarHouseID] = HouseID;
// Check if the house has any cars assigned to it
for (CarSlot = 0; CarSlot < 10; CarSlot++)
if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
HouseHasCars = true;
// Check if the house has any cars assigned to it
if (HouseHasCars == true)
{
// Add all vehicles to the list
for (CarSlot = 0; CarSlot < 10; CarSlot++)
{
// Check if the carslot has a vehicle in it
if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
{
// Get the index where the first vehicle is found in the ABuyableVehicles array
BuyableCarIndex = VehicleBuyable_GetIndex(GetVehicleModel(AHouseData[HouseID][VehicleIDs][CarSlot]));
// Add the name of the vehicle to the list
if (AVehicleData[AHouseData[HouseID][VehicleIDs][CarSlot]][Clamped] == 1)
format(VehicleList, 500, "%s{00FF00}%s (clamped)\n", VehicleList, ABuyableVehicles[BuyableCarIndex][CarName]);
else
format(VehicleList, 500, "%s{00FF00}%s\n", VehicleList, ABuyableVehicles[BuyableCarIndex][CarName]);
}
else
format(VehicleList, 500, TXT_EmptyCarSlot, VehicleList);
}
// Ask which vehicle the player wants to teleport to his location
ShowPlayerDialog(playerid, DialogGetCarSelectCar, DIALOG_STYLE_LIST, TXT_SelectVehicleToGet, VehicleList, TXT_DialogButtonSelect, TXT_DialogButtonCancel);
}
else
SendClientMessage(playerid, 0xFFFFFFFF, TXT_NoHouseVehicles);
}
else
SendClientMessage(playerid, 0xFFFFFFFF, TXT_NoHouseInSlot);
return 1;
}