help due to this server server bug
#1

[05:34:27] [debug] Run time error 4: "Array index out of bounds"
[05:34:27] [debug] Attempted to read/write array element at index 500 in array of size 500
[05:34:27] [debug] AMX backtrace:
[05:34:27] [debug] #0 000e9a3c in public Load_Vehicles () from CnR1.amx
[05:34:27] [debug] #1 0011f43c in public FIXES_OnGameModeInit () from CnR1.amx
[05:34:27] [debug] #2 0000ea94 in public FC_OnGameModeInit () from CnR1.amx
[05:34:27] [debug] #3 native CallLocalFunction () from sampsvr-port_2509
[05:34:27] [debug] #4 0000d064 in public SSCANF_OnGameModeInit () from CnR1.amx
[05:34:27] [debug] #5 00004c08 in public zcmd_OnGameModeInit () from CnR1.amx
[05:34:27] [debug] #6 native CallLocalFunction () from sampsvr-port_2509
[05:34:27] [debug] #7 00004680 in public Itter_OnGameModeInit () from CnR1.amx
[05:34:27] [debug] #8 native CallLocalFunction () from sampsvr-port_2509
[05:34:27] [debug] #9 000021a0 in public ScriptInit_OnGameModeInit () from CnR1.amx
[05:34:27] [debug] #10 00001154 in public Streamer_OnGameModeInit () from CnR1.amx
[05:34:27] [debug] #11 native CallLocalFunction () from sampsvr-port_2509
[05:34:27] [debug] #12 00000a34 in public OnGameModeInit () from CnR1.amx
how to fix it
if u need code tell me i send u
Reply
#2

Guess you are having an array size of 500 and you are trying to write/read from a null char.

Maybe Load_Vehicles?
Reply
#3

how i fix it
Reply
#4

Well probably by posting a code from Load_Vehicles where you are probably passing an array value in a for loop.
Reply
#5

how to send code like php code
Reply
#6



You have been asked at least 10 times even in your previous threads to post that function.
Reply
#7

any problem with u ilearner go to hell with your suggestions
Reply
#8

#define MAX_SCRIPT_VEHICLES 600
#define MAX_PLAYER_VEHICLES 3

enum vehicle_store
{
vehicle_id,
vehicle_owner[48],
vehicle_bought,
vehicle_price,
vehicle_model,
vehicle_sid,
vehicle_locked,
Float: vX,
Float: vY,
Float: vZ,
Float: vZA,
Float: vA,
colour_1,
colour_2,
allow_spawn
}

new
xVehicles = 1,
DB:VEHICLEDB,
oVehicle[MAX_SCRIPT_VEHICLES][vehicle_store]
;

forward load_oVehicles();
public load_oVehicles()
{
xVehicles = 0;

new DBResult:qresult, count = 0, value[328];
//new engine, lights, alarm, doors, bonnet, boot, objective;

if(!db_query(DB: VEHICLEDB, "SELECT * FROM `vehicle_data`"))
{
print("VEHICLE SYSTEM :: No vehicles were found in \"Vehicles.db\" :: 0 Loaded");
}
else
{
db_query(DB: VEHICLEDB, "DELETE FROM `vehicle_data` WHERE `vehicle_owner` = 'SOLD'");

qresult = db_query(DB: VEHICLEDB, "SELECT * FROM `vehicle_data`");
count = db_num_rows(qresult);
for(new i = 0; i < count; i++)
{
if(count <= MAX_SCRIPT_VEHICLES)
{
// Fetch data
db_get_field_assoc(qresult, "vehicle_id", value, 5); // oVehicle ID
oVehicle[i][vehicle_id] = strval(value);

db_get_field_assoc(qresult, "vehicle_owner", value, 4; // oVehicle Owner
format(oVehicle[i][vehicle_owner], 48, value);

db_get_field_assoc(qresult, "vehicle_bought", value, 20); // oVehicle X Position
oVehicle[i][vehicle_bought] = strval(value);

db_get_field_assoc(qresult, "vehicle_price", value, 20); // oVehicle X Position
oVehicle[i][vehicle_price] = strval(value);

db_get_field_assoc(qresult, "vehicle_model", value, 20); // oVehicle type
oVehicle[i][vehicle_model] = strval(value);

db_get_field_assoc(qresult, "vehicle_locked", value, 20); // oVehicle locked
oVehicle[i][vehicle_locked] = strval(value);

db_get_field_assoc(qresult, "vX", value, 20); // oVehicle X Position
oVehicle[i][vX] = floatstr(value);

db_get_field_assoc(qresult, "vY", value, 20); // oVehicle Y Position
oVehicle[i][vY] = floatstr(value);

db_get_field_assoc(qresult, "vZ", value, 20); // oVehicle Z Position
oVehicle[i][vZ] = floatstr(value);

db_get_field_assoc(qresult, "vZA", value, 20); // oVehicle Z Position
oVehicle[i][vZA] = floatstr(value);

db_get_field_assoc(qresult, "vA", value, 20); // oVehicle A Position
oVehicle[i][vA] = floatstr(value);

db_get_field_assoc(qresult, "colour_1", value, 20); // oVehicle A Position
oVehicle[i][colour_1] = strval(value);

db_get_field_assoc(qresult, "colour_2", value, 20); // oVehicle A Position
oVehicle[i][colour_2] = strval(value);

//oVehicle[i][vehicle_sid] = CreateVehicle(oVehicle[i][vehicle_model], oVehicle[i][vX], oVehicle[i][vY], oVehicle[i][vZ], oVehicle[i][vZA], oVehicle[i][colour_1], oVehicle[i][colour_2], 120);
//SetVehicleZAngle(oVehicle[i][vehicle_id], oVehicle[i][vZA]);

//GetVehicleParamsEx(oVehicle[i][vehicle_sid], engine, lights, alarm, doors, bonnet, boot, objective);
//SetVehicleParamsEx(oVehicle[i][vehicle_sid], engine, 0, alarm, doors, 0, 0, objective);

xVehicles++;
db_next_row(qresult);
}
}

db_free_result(qresult);
}
}

stock enterVehicle(vehicleID, playerid)
{
new
vid
;

vid = GetPlayerVehicleID(playerid);

for(new i = 0; i < MAX_SCRIPT_VEHICLES; i++)
{
if(oVehicle[i][vehicle_sid] == vid && GetVehicleModel(vid) == oVehicle[i][vehicle_model])
{
if(oVehicle[i][vehicle_sid] == vehicleID)
{
if (playerData[playerid][playerVehicleLocating] == oVehicle[i][vehicle_sid])
{
RemovePlayerMapIcon(playerid, MAP_ICON_VEHICLE_LOCATE);
}

if (oVehicle[i][vehicle_bought] == 0)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleID, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleID, 0, lights, alarm, doors, bonnet, boot, objective);

new purchaseMsg[200];
format(purchaseMsg, sizeof(purchaseMsg), "{58D3F7}[VEHICLE] {FFFFFF}This vehicle costs {FFDC2E}$%s{FFFFFF}. Type /vbuy to purchase it.", FormatNumber(oVehicle[i][vehicle_price]));
SendClientMessage(playerid, COLOR_WHITE, purchaseMsg);
}
else
{
new purchaseMsg[200];

if(!strcmp(oVehicle[i][vehicle_owner], playerData[playerid][playerNamee], true))
{
format(purchaseMsg, sizeof(purchaseMsg), "{58D3F7}[VEHICLE] {FFFFFF}Welcome back to your vehicle. Type /v to configure it.", oVehicle[i][vehicle_owner]);

new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleID, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleID, 1, lights, alarm, doors, bonnet, boot, objective);
}
else
{
if (oVehicle[i][vehicle_locked] && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if (playerData[playerid][playerLevel] >= 3)
{
format(purchaseMsg, sizeof(purchaseMsg), "{58D3F7}[VEHICLE] {FFFFFF}This vehicle is locked. You can drive it because you're an administrator.");

new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleID, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleID, 1, lights, alarm, doors, bonnet, boot, objective);
}
else
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleID, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleID, 0, lights, alarm, doors, bonnet, boot, objective);
format(purchaseMsg, sizeof(purchaseMsg), "{58D3F7}[VEHICLE] {FFFFFF}This vehicle is locked.");

RemovePlayerFromVehicle(playerid);
}
}
else
{
format(purchaseMsg, sizeof(purchaseMsg), "{58D3F7}[VEHICLE] {FFFFFF}This vehicle is owned by {FFDC2E}%s{FFFFFF}.", oVehicle[i][vehicle_owner]);

new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleID, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleID, 1, lights, alarm, doors, bonnet, boot, objective);
}
}

SendClientMessage(playerid, COLOR_WHITE, purchaseMsg);
}

break;
}
else
{
continue;
}
}
}
}

stock SpawnVehicle(vehicleID, oldID, place, playerid)
{
new
vehicleQuery[200],
engine, lights, alarm, doors, bonnet, boot, objective
;

format(vehicleQuery, sizeof(vehicleQuery), "SELECT * FROM `vehicle_data` WHERE `vehicle_id` = '%i' LIMIT 1", vehicleID);

new DBResult:qresult, count = 0, value[328];
qresult = db_query(DB: VEHICLEDB, vehicleQuery);
count = db_num_rows(qresult);

if (count == 0)
{
print("Invalid spawn ID");
}
else
{
db_get_field_assoc(qresult, "vehicle_id", value, 5); // oVehicle ID
oVehicle[oldID][vehicle_id] = strval(value);

db_get_field_assoc(qresult, "vehicle_owner", value, 4; // oVehicle Owner
format(oVehicle[oldID][vehicle_owner], 48, value);

db_get_field_assoc(qresult, "vehicle_bought", value, 20); // oVehicle X Position
oVehicle[oldID][vehicle_bought] = strval(value);

db_get_field_assoc(qresult, "vehicle_price", value, 20); // oVehicle X Position
oVehicle[oldID][vehicle_price] = strval(value);

db_get_field_assoc(qresult, "vehicle_model", value, 20); // oVehicle type
oVehicle[oldID][vehicle_model] = strval(value);

db_get_field_assoc(qresult, "vehicle_locked", value, 20); // oVehicle locked
oVehicle[oldID][vehicle_locked] = strval(value);

db_get_field_assoc(qresult, "vX", value, 20); // oVehicle X Position
oVehicle[oldID][vX] = floatstr(value);

db_get_field_assoc(qresult, "vY", value, 20); // oVehicle Y Position
oVehicle[oldID][vY] = floatstr(value);

db_get_field_assoc(qresult, "vZ", value, 20); // oVehicle Z Position
oVehicle[oldID][vZ] = floatstr(value);

db_get_field_assoc(qresult, "vZA", value, 20); // oVehicle Z Position
oVehicle[oldID][vZA] = floatstr(value);

db_get_field_assoc(qresult, "vA", value, 20); // oVehicle A Position
oVehicle[oldID][vA] = floatstr(value);

db_get_field_assoc(qresult, "colour_1", value, 20); // oVehicle A Position
oVehicle[oldID][colour_1] = strval(value);

db_get_field_assoc(qresult, "colour_2", value, 20); // oVehicle A Position
oVehicle[oldID][colour_2] = strval(value);

oVehicle[oldID][vehicle_sid] = CreateVehicle(oVehicle[oldID][vehicle_model], oVehicle[oldID][vX], oVehicle[oldID][vY], oVehicle[oldID][vZ], oVehicle[oldID][vZA], oVehicle[oldID][colour_1], oVehicle[oldID][colour_2], 120);
SetVehicleZAngle(oVehicle[oldID][vehicle_id], oVehicle[oldID][vZA]);

GetVehicleParamsEx(oVehicle[oldID][vehicle_sid], engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(oVehicle[oldID][vehicle_sid], engine, 0, alarm, doors, 0, 0, objective);

if (place)
{
PutPlayerInVehicle(playerid, oVehicle[oldID][vehicle_sid], 0);
}
}
}

/**********************
| Vehicle Commands
**********************/

COMMAND:createvehicle(playerid, params[])
{
if(playerData[playerid][playerLoggedIn])
{
if(playerData[playerid][playerLevel] >= 6)
{
new
vehicleID,
newPrice,
query[400],
idQuery[300],
value[48],
Float,
Float:y,
Float:z,
Float:a
;

GetPlayerPos(playerid, x, y, z);

if(sscanf(params, "ii", vehicleID, newPrice))
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}Usage: \"createvehicle <vehicle id> <vehicle price>\"");
}
else
{
format(query, sizeof(query), "INSERT INTO `vehicle_data` (vehicle_bought, vehicle_price, vehicle_owner, vehicle_model, vX, vY, vZ, vZA, vA) VALUES ('0', '%i', 'CNRSF', '%i', '%f', '%f', '%f', '0', '%f')", newPrice, vehicleID, x, y, z, a);
db_query(DB: VEHICLEDB, query);

format(idQuery, sizeof(idQuery), "SELECT * FROM `vehicle_data` WHERE `vehicle_bought` = '0' ORDER BY `vehicle_id` DESC LIMIT 1", playerData[playerid][playerNamee]);

new DBResult:idresult;
idresult = db_query(DB: VEHICLEDB, idQuery);

db_get_field_assoc(idresult, "vehicle_id", value, 20); // oVehicle X Position
new dbid = strval(value);

new i = xVehicles;
oVehicle[i][vehicle_id] = dbid;
format(oVehicle[i][vehicle_owner], 48, "CNRSF");
oVehicle[i][vehicle_bought] = 0;
oVehicle[i][vehicle_price] = newPrice;
oVehicle[i][vehicle_model] = vehicleID;
oVehicle[i][vX] = x;
oVehicle[i][vY] = y;
oVehicle[i][vZ] = z;
oVehicle[i][vA] = a;

oVehicle[i][vehicle_sid] = CreateVehicle(oVehicle[i][vehicle_model], oVehicle[i][vX], oVehicle[i][vY], oVehicle[i][vZ], oVehicle[i][vA], 0, 1, 120);
SetVehicleZAngle(oVehicle[i][vehicle_id], oVehicle[i][vA]);

new debugmsg[100];
format(debugmsg, sizeof(debugmsg), "Array ID assigned: %i", i);
SendClientMessage(playerid, COLOR_WHITE, debugmsg);

xVehicles++;
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You do not have permission to use that command.");
}
}

return 1;
}

COMMAND:reloadvehicles(playerid, params[])
{
if(playerData[playerid][playerLoggedIn])
{
if(playerData[playerid][playerLevel] >= 5)
{
for(new i = 0; i < MAX_SCRIPT_VEHICLES; i++)
{
oVehicle[i][vehicle_id] = -1;
format(oVehicle[i][vehicle_owner], 1, "");
oVehicle[i][vehicle_bought] = -1;
oVehicle[i][vehicle_price] = -1;
oVehicle[i][vehicle_model] = -1;
oVehicle[i][vX] = -1;
oVehicle[i][vY] = -1;
oVehicle[i][vZ] = -1;
oVehicle[i][vA] = -1;

DestroyVehicle(oVehicle[i][vehicle_sid]);
oVehicle[i][vehicle_sid] = -1;
}

load_oVehicles();
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You do not have permission to use that command.");
}
}

return 1;
}

COMMAND:respawnov(playerid, params[])
{
if(playerData[playerid][playerLoggedIn])
{
if(playerData[playerid][playerLevel] >= 5)
{
new
vehicleID,
vehicleQuery[200]
;

if(sscanf(params, "i", vehicleID))
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}Usage: \"houseinfo <house id>\"");
}
else
{
format(vehicleQuery, sizeof(vehicleQuery), "SELECT * FROM `vehicle_data` WHERE `vehicle_id` = '%i' LIMIT 1", vehicleID);

new DBResult:qresult, count = 0;
qresult = db_query(DB: VEHICLEDB, vehicleQuery);
count = db_num_rows(qresult);

if (count == 0)
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}That vehicle ID doesn't exist.");
}
else
{
new dbID, value[48];
db_get_field_assoc(qresult, "vehicle_id", value, 4;
dbID = strval(value);

for(new i = 0; i < MAX_SCRIPT_VEHICLES; i++)
{
if(oVehicle[i][vehicle_id] == dbID)
{
DestroyVehicle(oVehicle[i][vehicle_sid]);
SpawnVehicle(dbID, i, 0, playerid);

break;
}
}
}
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You do not have permission to use that command.");
}
}

return 1;
}

COMMAND:destroyvehicle(playerid, params[])
{
if(playerData[playerid][playerLoggedIn])
{
if(playerData[playerid][playerLevel] >= 5)
{
new
vehicleID,
vehicleQuery[200],
deleteQuery[200]
;

if(sscanf(params, "i", vehicleID))
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}Usage: \"destroyvehicle <vehicle id>\"");
}
else
{
format(vehicleQuery, sizeof(vehicleQuery), "SELECT * FROM `vehicle_data` WHERE `vehicle_id` = '%i' LIMIT 1", vehicleID);

new DBResult:qresult, count = 0;
qresult = db_query(DB: VEHICLEDB, vehicleQuery);
count = db_num_rows(qresult);

if (count == 0)
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}That vehicle ID doesn't exist.");
}
else
{
new dbID, value[48];
db_get_field_assoc(qresult, "vehicle_id", value, 4;
dbID = strval(value);

for(new i = 0; i < MAX_SCRIPT_VEHICLES; i++)
{
if(oVehicle[i][vehicle_id] == dbID)
{
oVehicle[i][vehicle_id] = -1;
format(oVehicle[i][vehicle_owner], 1, "");
oVehicle[i][vehicle_bought] = -1;
oVehicle[i][vehicle_price] = -1;
oVehicle[i][vehicle_model] = -1;
oVehicle[i][vX] = -1;
oVehicle[i][vY] = -1;
oVehicle[i][vZ] = -1;
oVehicle[i][vA] = -1;

DestroyVehicle(oVehicle[i][vehicle_sid]);

format(deleteQuery, sizeof(deleteQuery), "DELETE FROM `vehicle_data` WHERE `vehicle_id` = '%i'", dbID);
db_query(DB: VEHICLEDB, deleteQuery);

break;
}
}
}
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You do not have permission to use that command.");
}
}

return 1;
}

COMMAND:gotovehicle(playerid, params[])
{
if(playerData[playerid][playerLoggedIn])
{
if(playerData[playerid][playerLevel] >= 5)
{
new
vehicleID,
vehicleQuery[200]
;

if(sscanf(params, "i", vehicleID))
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}Usage: \"gotovehicle <vehicle id>\"");
}
else
{
format(vehicleQuery, sizeof(vehicleQuery), "SELECT * FROM `vehicle_data` WHERE `vehicle_id` = '%i' LIMIT 1", vehicleID);

new DBResult:qresult, count = 0;
qresult = db_query(DB: VEHICLEDB, vehicleQuery);
count = db_num_rows(qresult);

if (count == 0)
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}That vehicle ID doesn't exist.");
}
else
{
new dbID, value[48];
db_get_field_assoc(qresult, "vehicle_id", value, 4;
dbID = strval(value);

for(new i = 0; i < MAX_SCRIPT_VEHICLES; i++)
{
if(oVehicle[i][vehicle_id] == dbID)
{
new
Float,
Float:y,
Float:z
;

GetVehiclePos(oVehicle[i][vehicle_sid], x, y, z);

SetPlayerPos(playerid, x, y, z);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);

break;
}
}
}
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You do not have permission to use that command.");
}
}

return 1;
}

COMMAND:vbuy(playerid, params[])
{
if(playerData[playerid][playerLoggedIn])
{
new
pQuery[200],
newName[48],
query[400],
maxVehicles,
bool:found
;

if(!IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You must be the driver of a vehicle to use this command.");
}
else
{
format(pQuery, sizeof(pQuery), "SELECT * FROM `vehicle_data` WHERE `vehicle_owner` = '%s'", playerData[playerid][playerNamee]);

new DBResultresult, pcount = 0;
presult = db_query(DB: VEHICLEDB, pQuery);
pcount = db_num_rows(presult);

new vid = GetPlayerVehicleID(playerid);

if (playerData[playerid][playerVIPLevel] >= 1)
{
maxVehicles = STANDARD_VIP_MAX_VEHICLES;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You have too many vehicles. Sell a vehicle first.");
}
if (playerData[playerid][playerVIPLevel] >= 2)
{
maxVehicles = SILVER_VIP_MAX_VEHICLES;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You have too many vehicles. Sell a vehicle first.");
}
if (playerData[playerid][playerVIPLevel] >= 3)
{
maxVehicles = GOLD_VIP_MAX_VEHICLES;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You have too many vehicles. Sell a vehicle first.");
}
if(playerData[playerid][playerVIPLevel] == 0)
{
maxVehicles = PLAYER_MAX_VEHICLES;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You have too many vehicles. Sell a vehicle first.");
}
if (pcount != maxVehicles)
{
for(new i = 0; i < MAX_SCRIPT_VEHICLES; i++)
{
if(oVehicle[i][vehicle_sid] == vid)
{
found = true;
if (oVehicle[i][vehicle_bought] != 1)
{
if (playerData[playerid][playerMoney] >= oVehicle[i][vehicle_price])
{
format(newName, sizeof(newName), "%s", playerData[playerid][playerNamee]);
format(query, sizeof(query), "UPDATE `vehicle_data` SET `vehicle_bought` = '1', `vehicle_owner` = '%s' WHERE `vehicle_id` = '%i'", playerData[playerid][playerNamee], oVehicle[i][vehicle_id]);
db_query(DB: VEHICLEDB, query);

oVehicle[i][vehicle_owner] = newName;
oVehicle[i][vehicle_bought] = 1;

new price = oVehicle[i][vehicle_price];
playerSetMoney(playerid, playerData[playerid][playerMoney] - price);

new purchaseMsg[200];
format(purchaseMsg, sizeof(purchaseMsg), "{58D3F7}[VEHICLE] {FFFFFF}You purchased this vehicle for {FFDC2E}$%s{FFFFFF}. Type /v to configure it.", FormatNumber(oVehicle[i][vehicle_price]));
SendClientMessage(playerid, COLOR_WHITE, purchaseMsg);

new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vid, 1, lights, alarm, doors, bonnet, boot, objective);
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You don't have enough cash to purchase this vehicle.");
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}This vehicle is already owned by another player.");
}

break;
}
}

if (!found)
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You are not inside a buyable vehicle.");
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You have too many vehicles. Please sell a vehicle first!");
}
}
}

return 1;
}

COMMAND:v(playerid, params[])
{
if(playerData[playerid][playerLoggedIn])
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new
bool:found,
vid
;

vid = GetPlayerVehicleID(playerid);

for(new i = 0; i < MAX_SCRIPT_VEHICLES; i++)
{
if(oVehicle[i][vehicle_sid] == vid)
{
found = true;
if(!strcmp(oVehicle[i][vehicle_owner], playerData[playerid][playerNamee], true) || playerData[playerid][playerLevel] >= 6)
{
playerData[playerid][vehicleMenu] = i;
ShowPlayerDialog(playerid, DIALOG_VEHICLEMENU, DIALOG_STYLE_LIST, "Vehicle Menu", "Lock/Unlock Vehicle \nSell Vehicle \nChange Colour \nToggle Lights \nToggle Boot \nToggle Hood", "Select", "Cancel");
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You are not the owner of this vehicle.");

new whois[200];
format(whois, 200, "%s", oVehicle[i][vehicle_owner]);
print(whois);
}

break;
}
}

if(!found)
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You are not inside an owned vehicle.");
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You must be the driver of a vehicle to use this command.");
}
}

return 1;
}

COMMAND:vehicleinfo(playerid, params[])
{
if(playerData[playerid][playerLoggedIn])
{
if(playerData[playerid][playerLevel] >= 3)
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new
bool:found,
vid
;

vid = GetPlayerVehicleID(playerid);

for(new i = 0; i < MAX_SCRIPT_VEHICLES; i++)
{
if(oVehicle[i][vehicle_sid] == vid && GetVehicleModel(vid) == oVehicle[i][vehicle_model])
{
found = true;

new vlist[600];
format(vlist, sizeof(vlist), "%s\nVehicle DB Key: %i", vlist, oVehicle[i][vehicle_id]);
format(vlist, sizeof(vlist), "%s\nVehicle Array Key: %i", vlist, i);
format(vlist, sizeof(vlist), "%s\nVehicle VID: %i", vlist, oVehicle[i][vehicle_sid]);
format(vlist, sizeof(vlist), "%s\nVehicle Owner: %s", vlist, oVehicle[i][vehicle_owner]);
format(vlist, sizeof(vlist), "%s\nVehicle Price: $%s", vlist, FormatNumber(oVehicle[i][vehicle_price]));

ShowPlayerDialog(playerid, 969, DIALOG_STYLE_LIST, "Vehicle Information", vlist, "OK", "Close");

break;
}
}

if(!found)
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You are not inside an owned vehicle.");
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You must be the driver of a vehicle to use this command.");
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You do not have the correct permissions to use this command.");
}
}

return 1;
}

COMMANDlayervehicles(playerid, params[])
{
if(playerData[playerid][playerLoggedIn])
{
if(playerData[playerid][playerLevel] >= 5)
{
new
playerwho,
dialogtitle[60],
dialogList[256],
DBResult:locatingResult,
locatingQuery[128],
resultCount,
bool:firstOne
;

if(sscanf(params, "u", playerwho))
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}Usage: \"playervehicles <playerid>\"");
}
else
{
format(locatingQuery, sizeof(locatingQuery), "SELECT * FROM `vehicle_data` WHERE `vehicle_owner` = '%s'", playerData[playerwho][playerNamee]);
locatingResult = db_query(DB: VEHICLEDB, locatingQuery);
resultCount = db_num_rows(locatingResult);

if(resultCount > 0)
{
do
{
new vehicleModel, vehicleID, temporaryString[54];

db_get_field_assoc(locatingResult, "vehicle_model", temporaryString, 3);
vehicleModel = strval(temporaryString);

db_get_field_assoc(locatingResult, "vehicle_id", temporaryString, 3);
vehicleID = strval(temporaryString);

if(firstOne == true)
{
format(dialogList, sizeof(dialogList), "%s (ID: %i)", dialogList, vehicleNames[vehicleModel - 400], vehicleID);
firstOne = false;
}
else
{
format(dialogList, sizeof(dialogList), "%s\n%s (ID: %i)", dialogList, vehicleNames[vehicleModel - 400], vehicleID);
}

} while(db_next_row(locatingResult));

format(dialogtitle, sizeof(dialogtitle), "%s's Vehicles", playerData[playerwho][playerNamee]);
ShowPlayerDialog(playerid, DIALOG_OPTIONSLIST, DIALOG_STYLE_LIST, dialogtitle, dialogList, "Select", "Cancel");
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}That player does not own any vehicles.");
}

db_free_result(locatingResult);
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You do not have permission to use that command.");
}
}

return 1;
}

COMMAND:myvehicles(playerid, params[])
{
if(playerData[playerid][playerLoggedIn])
{
new
dialogList[256],
DBResult:locatingResult,
locatingQuery[128],
resultCount,
bool:firstOne
;

format(locatingQuery, sizeof(locatingQuery), "SELECT * FROM `vehicle_data` WHERE `vehicle_owner` = '%s'", playerData[playerid][playerNamee]);
locatingResult = db_query(DB: VEHICLEDB, locatingQuery);
resultCount = db_num_rows(locatingResult);

if(resultCount > 0)
{
do
{
new vehicleModel, vehicleID, temporaryString[54];

db_get_field_assoc(locatingResult, "vehicle_model", temporaryString, 3);
vehicleModel = strval(temporaryString);

db_get_field_assoc(locatingResult, "vehicle_id", temporaryString, 3);
vehicleID = strval(temporaryString);

if(firstOne == true)
{
format(dialogList, sizeof(dialogList), "%s (ID: %i)", dialogList, vehicleNames[vehicleModel - 400], vehicleID);
firstOne = false;
}
else
{
format(dialogList, sizeof(dialogList), "%s\n%s (ID: %i)", dialogList, vehicleNames[vehicleModel - 400], vehicleID);
}

} while(db_next_row(locatingResult));

ShowPlayerDialog(playerid, DIALOG_OPTIONSLIST, DIALOG_STYLE_LIST, "My Vehicles", dialogList, "Select", "Cancel");
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You do not own any vehicles.");
}

db_free_result(locatingResult);
}

return 1;
}

COMMANDpawncar(playerid, params[])
{
if(playerData[playerid][playerLoggedIn])
{
new
dialogList[256],
DBResult:locatingResult,
locatingQuery[128],
resultCount,
bool:firstOne
;

format(locatingQuery, sizeof(locatingQuery), "SELECT * FROM `vehicle_data` WHERE `vehicle_owner` = '%s'", playerData[playerid][playerNamee]);
locatingResult = db_query(DB: VEHICLEDB, locatingQuery);
resultCount = db_num_rows(locatingResult);

if(resultCount > 0)
{
do
{
TextDrawShowForPlayer(playerid, vSpawns[0]);
TextDrawShowForPlayer(playerid, vSpawns[1]);

new vehicleModel, temporaryString[54];

db_get_field_assoc(locatingResult, "vehicle_model", temporaryString, 3);
vehicleModel = strval(temporaryString);

if(firstOne == true)
{
format(dialogList, sizeof(dialogList), "%s {D87C3E}$100", dialogList, vehicleNames[vehicleModel - 400]);
firstOne = false;
}
else
{
format(dialogList, sizeof(dialogList), "%s\n%s {D87C3E}$100", dialogList, vehicleNames[vehicleModel - 400]);
}

} while(db_next_row(locatingResult));

ShowPlayerDialog(playerid, DIALOG_VEHICLESPAWN, DIALOG_STYLE_LIST, " ", dialogList, "Spawn", "Cancel");
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "{B7B7B7}[SERVER] {FFFFFF}You do not own any vehicles.");
}

db_free_result(locatingResult);
}

return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
for(new i = 0; i < MAX_SCRIPT_VEHICLES; i++)
{
if (oVehicle[i][vehicle_id] != -1)
{
if(oVehicle[i][vehicle_sid] == vehicleid)
{
oVehicle[i][allow_spawn] = 0;
DestroyVehicle(oVehicle[i][vehicle_sid]);
}

break;
}
}

vWarped[vehicleid][Spawned] = false;
vWarped[vehicleid][wasOccupied] = false;
}
Reply
#9

Except the fact you posted 5+ irrelevant commands along with the function, you've been told the solution: http://forum.sa-mp.com/showpost.php?...2&postcount=31
I see you changed the part that the sql ID was used as index which is good but the other thing is still the same.

Instead of keep checking with an if statement, just change

pawn Код:
count = db_num_rows(qresult);
to:
pawn Код:
count = clamp(db_num_rows(qresult), .max = sizeof oVehicle);
so if there are more rows than the size of the array, it will load only as many as it can. You may want to compare it and print in the console to let you know (to increase the size of the array) but nevermind for now. By the way, the logs are old as the current size is 600 but says 500.

Last, remove this completely:
pawn Код:
if (count <= MAX_SCRIPT_VEHICLES)
Just be careful with the brackets.
Reply
#10

bro listen i know a little bit about mysql i make server before 1 or 2 weak idk what is this i just upload the given file to server can u fix it and then send me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)