hi i am using AVS car system and when i try to buy it says: Buy or Cancel , when i press Cancel i get kicked it say Server Closed Connection can some1 help me ?
Код HTML:
ShowDialog(playerid, dialogid)
{
switch(dialogid)
{
case DIALOG_VEHICLE:
{
new vehicleid = GetPVarInt(playerid, "DialogValue1");
new caption[32], info[256];
format(caption, sizeof(caption), "Vehicle ID %d", vehicleid);
strcat(info, "Engine\nLights\nHood\nTrunk", sizeof(info));
strcat(info, "\nFill Tank", sizeof(info));
if(GetPlayerVehicleAccess(playerid, vehicleid) >= 2)
{
new value = VehicleValue[vehicleid]/2;
format(info, sizeof(info), "%s\nSell Vehicle ($%d)\nPark Vehicle\nEdit License Plate", info, value);
}
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, caption, info, "Select", "");
}
case DIALOG_VEHICLE_BUY:
{
new vehicleid = GetPVarInt(playerid, "DialogValue1");
new caption[32], info[256];
format(caption, sizeof(caption), "Vehicle ID %d", vehicleid);
format(info, sizeof(info), "This vehicle is for sale ($%d)\n-", VehicleValue[vehicleid]);
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, caption, info, "BUY", "CANCEL");
}
case DIALOG_VEHICLE_SELL:
{
new targetid = GetPVarInt(playerid, "DialogValue1");
new id = GetPVarInt(playerid, "DialogValue2");
new price = GetPVarInt(playerid, "DialogValue3");
new info[256];
format(info, sizeof(info), "%s (%d) wants to sell you a %s for $%d.", PlayerName(targetid), targetid,
VehicleNames[VehicleModel[id]-400], price);
strcat(info, "\n\nWould you like to buy?", sizeof(info));
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, "Buy Vehicle", info, "Yes", "No");
}
case DIALOG_TRUNK:
{
new vehicleid = GetPVarInt(playerid, "DialogValue1");
new name[32], info[256];
for(new i=0; i < sizeof(VehicleTrunk[]); i++)
{
if(VehicleTrunk[vehicleid][i][1] > 0)
{
GetWeaponName(VehicleTrunk[vehicleid][i][0], name, sizeof(name));
format(info, sizeof(info), "%s%d. %s (%d)\n", info, i+1, name, VehicleTrunk[vehicleid][i][1]);
}
else
{
format(info, sizeof(info), "%s%d. Empty\n", info, i+1);
}
}
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, "Trunk", info, "Select", "Cancel");
}
case DIALOG_TRUNK_ACTION:
{
new info[128];
strcat(info, "Put Into Trunk\nTake From Trunk", sizeof(info));
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, "Trunk", info, "Select", "Cancel");
}
case DIALOG_VEHICLE_PLATE:
{
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, "Edit License Plate", "Enter new license plate:", "Change", "Back");
}
case DIALOG_FUEL:
{
new info[128];
strcat(info, "Refuel Vehicle ($" #FUEL_PRICE ")\nBuy Gas Can ($" #GAS_CAN_PRICE ")", sizeof(info));
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, "Fuel Station", info, "OK", "Cancel");
}
case DIALOG_EDITVEHICLE:
{
new vehicleid = GetPVarInt(playerid, "DialogValue1");
new caption[32], info[256];
format(caption, sizeof(caption), "Edit Vehicle ID %d", vehicleid);
format(info, sizeof(info), "1. Value: [$%d]\n2. Model: [%d (%s)]\n3. Colors: [%d] [%d]\n4. License Plate: [%s]",
VehicleValue[vehicleid], VehicleModel[vehicleid], VehicleNames[VehicleModel[vehicleid]-400],
VehicleColor[vehicleid][0], VehicleColor[vehicleid][1], VehicleNumberPlate[vehicleid]);
strcat(info, "\n5. Delete Vehicle\n6. Park Vehicle\n7. Go To Vehicle", sizeof(info));
strcat(info, "\n\nEnter: [nr] [value1] [value2]", sizeof(info));
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, caption, info, "OK", "Cancel");
}
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_ERROR)
{
ShowDialog(playerid, DialogReturn[playerid]);
return 1;
}
DialogReturn[playerid] = dialogid;
if(dialogid == DIALOG_VEHICLE)
{
if(response)
{
switch(listitem)
{
case 0:
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(engine == 0 && Fuel[vehicleid] <= 0)
{
ShowErrorDialog(playerid, "This vehicle is out of fuel!");
return 1;
}
if(engine == 1) { engine = 0; lights = 0; }
else { engine = 1; lights = 1; }
SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
}
case 1:
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(lights == 1) lights = 0; else lights = 1;
SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
}
case 2:
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(bonnet == 1) bonnet = 0; else bonnet = 1;
SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
}
case 3:
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(boot == 1) boot = 0; else boot = 1;
SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
}
case 4:
{
if(!GetPVarInt(playerid, "GasCan"))
{
ShowErrorDialog(playerid, "You don't have a gas can!");
return 1;
}
new vehicleid = GetPlayerVehicleID(playerid);
if(Fuel[vehicleid] < 80.0) Fuel[vehicleid] += 20.0;
else Fuel[vehicleid] = 100.0;
SetPVarInt(playerid, "GasCan", 0);
SendClientMessage(playerid, COLOR_WHITE, "You have filled the fuel tank with 20 fuel");
}
case 5:
{
new id = GetPVarInt(playerid, "DialogValue1");
if(GetPlayerVehicleAccess(playerid, id) < 2)
{
ShowErrorDialog(playerid, "You are not the owner of this vehicle!");
return 1;
}
new msg[128];
VehicleCreated[id] = 0;
new money = VehicleValue[id]/2;
GivePlayerMoney(playerid, money);
format(msg, sizeof(msg), "You have sold your vehicle for $%d", money);
SendClientMessage(playerid, COLOR_WHITE, msg);
RemovePlayerFromVehicle(playerid);
DestroyVehicle(VehicleID[id]);
SaveVehicle(id);
}
case 6:
{
new vehicleid = GetPVarInt(playerid, "DialogValue1");
if(GetPlayerVehicleAccess(playerid, vehicleid) < 2)
{
ShowErrorDialog(playerid, "You are not the owner of this vehicle!");
return 1;
}
GetVehiclePos(VehicleID[vehicleid], VehiclePos[vehicleid][0], VehiclePos[vehicleid][1], VehiclePos[vehicleid][2]);
GetVehicleZAngle(VehicleID[vehicleid], VehiclePos[vehicleid][3]);
VehicleInterior[vehicleid] = GetPlayerInterior(playerid);
VehicleWorld[vehicleid] = GetPlayerVirtualWorld(playerid);
SendClientMessage(playerid, COLOR_WHITE, "You have parked this vehicle here");
UpdateVehicle(vehicleid, 1);
PutPlayerInVehicle(playerid, VehicleID[vehicleid], 0);
SaveVehicle(vehicleid);
}
case 7:
{
ShowDialog(playerid, DIALOG_VEHICLE_PLATE);
}
}
}
return 1;
}
if(dialogid == DIALOG_VEHICLE_BUY)
{
if(response)
{
if(GetPlayerVehicles(playerid) >= MAX_PLAYER_VEHICLES)
{
ShowErrorDialog(playerid, "You can't buy any more vehicles! Max: " #MAX_PLAYER_VEHICLES );
return 1;
}
new id = GetPVarInt(playerid, "DialogValue1");
if(GetPlayerMoney(playerid) < VehicleValue[id])
{
ShowErrorDialog(playerid, "You don't have enough money to buy this vehicle!");
return 1;
}
new freeid = GetFreeVehicleID();
if(!freeid)
{
ShowErrorDialog(playerid, "Vehicle dealership is out of stock!");
return 1;
}
GivePlayerMoney(playerid, -VehicleValue[id]);
new dealerid = strval(VehicleOwner[id]);
VehicleCreated[freeid] = VEHICLE_PLAYER;
VehicleModel[freeid] = VehicleModel[id];
VehiclePos[freeid] = DealershipPos[dealerid];
VehicleColor[freeid] = VehicleColor[id];
VehicleInterior[freeid] = VehicleInterior[id];
VehicleWorld[freeid] = VehicleWorld[id];
VehicleValue[freeid] = VehicleValue[id];
GetPlayerName(playerid, VehicleOwner[freeid], sizeof(VehicleOwner[]));
VehicleNumberPlate[freeid] = DEFAULT_NUMBER_PLATE;
for(new d=0; d < sizeof(VehicleTrunk[]); d++)
{
VehicleTrunk[freeid][d][0] = 0;
VehicleTrunk[freeid][d][1] = 0;
}
for(new d=0; d < sizeof(VehicleMods[]); d++)
{
VehicleMods[freeid][d] = 0;
}
VehiclePaintjob[freeid] = 255;
VehicleLock[freeid] = 0;
VehicleAlarm[freeid] = 0;
UpdateVehicle(freeid, 0);
SaveVehicle(freeid);
new msg[128];
format(msg, sizeof(msg), "You have bought this vehicle for $%d", VehicleValue[id]);
SendClientMessage(playerid, COLOR_WHITE, msg);
}
else
{
new id = GetPVarInt(playerid, "DialogValue1");
if(GetPlayerVehicleAccess(playerid, id) < 1)
{
RemovePlayerFromVehicle(playerid);
}
}
return 1;
}
if(dialogid == DIALOG_VEHICLE_SELL)
{
if(response)
{
if(GetPlayerVehicles(playerid) >= MAX_PLAYER_VEHICLES)
{
ShowErrorDialog(playerid, "You can't buy any more vehicles! Max: " #MAX_PLAYER_VEHICLES );
return 1;
}
new targetid = GetPVarInt(playerid, "DialogValue1");
new id = GetPVarInt(playerid, "DialogValue2");
new price = GetPVarInt(playerid, "DialogValue3");
if(GetPlayerMoney(playerid) < price)
{
ShowErrorDialog(playerid, "You don't have enough money to buy this vehicle!");
return 1;
}
new msg[128];
GetPlayerName(playerid, VehicleOwner[id], sizeof(VehicleOwner[]));
GivePlayerMoney(playerid, -price);
GivePlayerMoney(targetid, price);
SaveVehicle(id);
format(msg, sizeof(msg), "You have bought this vehicle for $%d", price);
SendClientMessage(playerid, COLOR_WHITE, msg);
format(msg, sizeof(msg), "%s (%d) has accepted your offer and bought the vehicle", PlayerName(playerid), playerid);
SendClientMessage(targetid, COLOR_WHITE, msg);
}
else
{
new targetid = GetPVarInt(playerid, "DialogValue1");
new msg[128];
format(msg, sizeof(msg), "%s (%d) refused your offer", PlayerName(playerid), playerid);
SendClientMessage(targetid, COLOR_WHITE, msg);
}
return 1;
}
if(dialogid == DIALOG_FINDVEHICLE)
{
if(response)
{
new id;
sscanf(inputtext[4], "d", id);
if(IsValidVehicle(id))
{
TrackCar[playerid] = VehicleID[id];
SendClientMessage(playerid, COLOR_WHITE, "Your vehicle's location is shown on your minimap");
}
}
return 1;
}
if(dialogid == DIALOG_TRUNK)
{
if(response)
{
SetPVarInt(playerid, "DialogValue2", listitem);
ShowDialog(playerid, DIALOG_TRUNK_ACTION);
}
else
{
new id = GetPVarInt(playerid, "DialogValue1");
ToggleBoot(VehicleID[id], VEHICLE_PARAMS_OFF);
}
return 1;
}
if(dialogid == DIALOG_TRUNK_ACTION)
{
if(response)
{
new id = GetPVarInt(playerid, "DialogValue1");
new slot = GetPVarInt(playerid, "DialogValue2");
switch(listitem)
{
case 0:
{
new weaponid = GetPlayerWeapon(playerid);
if(weaponid == 0)
{
ShowErrorDialog(playerid, "You don't have a weapon in your hands!");
return 1;
}
VehicleTrunk[id][slot][0] = weaponid;
if(IsMeleeWeapon(weaponid)) VehicleTrunk[id][slot][1] = 1;
else VehicleTrunk[id][slot][1] = GetPlayerAmmo(playerid);
RemovePlayerWeapon(playerid, weaponid);
SaveVehicle(id);
}
case 1:
{
if(VehicleTrunk[id][slot][1] <= 0)
{
ShowErrorDialog(playerid, "This slot is empty!");
return 1;
}
GivePlayerWeapon(playerid, VehicleTrunk[id][slot][0], VehicleTrunk[id][slot][1]);
VehicleTrunk[id][slot][0] = 0;
VehicleTrunk[id][slot][1] = 0;
SaveVehicle(id);
}
}
}
ShowDialog(playerid, DIALOG_TRUNK);
return 1;
}
if(dialogid == DIALOG_VEHICLE_PLATE)
{
if(response)
{
if(strlen(inputtext) < 1 || strlen(inputtext) >= sizeof(VehicleNumberPlate[]))
{
ShowErrorDialog(playerid, "Invalid length!");
return 1;
}
new id = GetPVarInt(playerid, "DialogValue1");
new vehicleid = VehicleID[id];
strmid(VehicleNumberPlate[id], inputtext, 0, sizeof(VehicleNumberPlate[]));
SaveVehicle(id);
SetVehicleNumberPlate(vehicleid, inputtext);
SetVehicleToRespawn(vehicleid);
new msg[128];
format(msg, sizeof(msg), "You have changed vehicle number plate to %s", inputtext);
SendClientMessage(playerid, COLOR_WHITE, msg);
}
else ShowDialog(playerid, DIALOG_VEHICLE);
return 1;
}
if(dialogid == DIALOG_FUEL)
{
if(response)
{
switch(listitem)
{
case 0:
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
{
ShowErrorDialog(playerid, "You are not driving a vehicle!");
return 1;
}
new vehicleid = GetPlayerVehicleID(playerid);
if(IsBicycle(vehicleid))
{
ShowErrorDialog(playerid, "Your vehicle doesn't have a fuel tank!");
return 1;
}
if(Fuel[vehicleid] >= 100.0)
{
ShowErrorDialog(playerid, "Your vehicle fuel tank is full!");
return 1;
}
if(GetPlayerMoney(playerid) < FUEL_PRICE)
{
ShowErrorDialog(playerid, "You don't have enough money!");
return 1;
}
RefuelTime[playerid] = 5;
SetPVarFloat(playerid, "Fuel", Fuel[vehicleid]);
GameTextForPlayer(playerid, "~w~refueling...", 2000, 3);
}
case 1:
{
if(GetPVarInt(playerid, "GasCan"))
{
ShowErrorDialog(playerid, "You already have a gas can!");
return 1;
}
if(GetPlayerMoney(playerid) < GAS_CAN_PRICE)
{
ShowErrorDialog(playerid, "You don't have enough money!");
return 1;
}
GivePlayerMoney(playerid, -GAS_CAN_PRICE);
SetPVarInt(playerid, "GasCan", 1);
SendClientMessage(playerid, COLOR_WHITE, "You have bought a gas can for $" #GAS_CAN_PRICE );
}
}
}
return 1;
}
if(dialogid == DIALOG_EDITVEHICLE)
{
if(response)
{
new id = GetPVarInt(playerid, "DialogValue1");
new nr, params[128];
sscanf(inputtext, "ds", nr, params);
switch(nr)
{
case 1:
{
new value = strval(params);
if(value < 0) value = 0;
VehicleValue[id] = value;
UpdateVehicleLabel(id, 1);
SaveVehicle(id);
ShowDialog(playerid, DIALOG_EDITVEHICLE);
}
case 2:
{
new value;
if(IsNumeric(params)) value = strval(params);
else value = GetVehicleModelIDFromName(params);
if(value < 400 || value > 611)
{
ShowErrorDialog(playerid, "Invalid vehicle model!");
return 1;
}
VehicleModel[id] = value;
for(new i=0; i < sizeof(VehicleMods[]); i++)
{
VehicleMods[id][i] = 0;
}
VehiclePaintjob[id] = 255;
UpdateVehicle(id, 1);
SaveVehicle(id);
ShowDialog(playerid, DIALOG_EDITVEHICLE);
}
case 3:
{
new color1, color2;
sscanf(params, "dd", color1, color2);
VehicleColor[id][0] = color1;
VehicleColor[id][1] = color2;
SaveVehicle(id);
ChangeVehicleColor(VehicleID[id], color1, color2);
ShowDialog(playerid, DIALOG_EDITVEHICLE);
}
case 4:
{
if(strlen(params) < 1 || strlen(params) > 8)
{
ShowErrorDialog(playerid, "Invalid length!");
return 1;
}
strmid(VehicleNumberPlate[id], params, 0, sizeof(params));
SaveVehicle(id);
SetVehicleNumberPlate(VehicleID[id], params);
SetVehicleToRespawn(VehicleID[id]);
ShowDialog(playerid, DIALOG_EDITVEHICLE);
}
case 5:
{
DestroyVehicle(VehicleID[id]);
if(VehicleCreated[id] == VEHICLE_DEALERSHIP)
{
Delete3DTextLabel(VehicleLabel[id]);
}
VehicleCreated[id] = 0;
SaveVehicle(id);
new msg[128];
format(msg, sizeof(msg), "You have deleted vehicle id %d", id);
SendClientMessage(playerid, COLOR_WHITE, msg);
}
case 6:
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
{
ShowErrorDialog(playerid, "You are not driving the vehicle!");
return 1;
}
GetVehiclePos(VehicleID[id], VehiclePos[id][0], VehiclePos[id][1], VehiclePos[id][2]);
GetVehicleZAngle(VehicleID[id], VehiclePos[id][3]);
VehicleInterior[id] = GetPlayerInterior(playerid);
VehicleWorld[id] = GetPlayerVirtualWorld(playerid);
SendClientMessage(playerid, COLOR_WHITE, "You have parked this vehicle here");
UpdateVehicle(id, 1);
PutPlayerInVehicle(playerid, VehicleID[id], 0);
SaveVehicle(id);
ShowDialog(playerid, DIALOG_EDITVEHICLE);
}
case 7:
{
new Float:x, Float:y, Float:z;
GetVehiclePos(VehicleID[id], x, y, z);
SetPlayerPos(playerid, x, y, z+1);
new msg[128];
format(msg, sizeof(msg), "You have teleported to vehicle id %d", id);
SendClientMessage(playerid, COLOR_WHITE, msg);
}
}
}
return 1;
}
return 0;
}
If you are loading it as a filterscript, then change the dialog ids of either your gamemode or the filterscript itself. One of the dialogs in your gamemode is probably interfering with the car system you are using.
As you are using this as FS. Try to recode the Dialogid == ?? to other Thats it