}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new
vehicleid = GetPlayerVehicleID(playerid),
dialog_string[128];
if(VehicleStatistics[vehicleid][vehicle_onsale] == 1)
{
format(dialog_string, sizeof(dialog_string), "Would you like to buy this %s costing $%d?", GetVehicleName(vehicleid), VehicleStatistics[vehicleid][vehicle_price]);
ShowPlayerDialog(playerid, 1337, DIALOG_STYLE_MSGBOX, "Car Purchase", dialog_string, "Yes", "No");
return 1;
}
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1337)
{
if(response)
{
new
vehicleid = GetPlayerVehicleID(playerid),
model = GetVehicleModel(vehicleid),
price = VehicleStatistics[vehicleid][vehicle_price],
Float:position[5],
string[128],
dealershipid = -1,
var[32],
playername[24];
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerPos(playerid, position[1], position[2], position[3]);
GetPlayerFacingAngle(playerid, position[4]);
if(GetPVarInt(playerid, "AmountOfCars") >= MAX_OWNABLE_CARS)
return SendClientMessage(playerid, color_grey, " You already own the maximum amount of vehicles !"), RemovePlayerFromVehicle(playerid);
if(GetPlayerMoney(playerid) < price)
return SendClientMessage(playerid, color_grey, " You can't afford that !"), RemovePlayerFromVehicle(playerid);
for(new i = 1; i < MAX_DEALERSHIPS; i++)
{
if(IsPlayerInRangeOfPoint(playerid, DealershipStatistics[i][dealership_radius], DealershipStatistics[i][dealership_x], DealershipStatistics[i][dealership_y], DealershipStatistics[i][dealership_z]))
{
dealershipid = i;
break;
}
}
DealershipStatistics[dealershipid][dealership_earnings] += (price / 4);
GivePlayerMoney(playerid, -price);
RemovePlayerFromVehicle(playerid);
vehicleid = CreateVehicle(model, (position[1] + (7.5 * floatsin(-position[4], degrees))), (position[2] + (7.5 * floatcos(position[4], degrees))), position[3], position[4], 0, 0, -1);
format(string, sizeof(string), "Thank you for purchasing at %s, we hope to see you again!", DealershipStatistics[dealershipid][dealership_name]);
SendClientMessage(playerid, color_white, string);
SendClientMessage(playerid, color_white, "Your vehicle has been spawned in front of you.");
SetPVarInt(playerid, "AmountOfCars", GetPVarInt(playerid, "AmountOfCars") + 1);
format(var, sizeof(var), "Model_%d", GetPVarInt(playerid, "AmountOfCars"));
SetPVarInt(playerid, var, model);
format(var, sizeof(var), "X_%d", GetPVarInt(playerid, "AmountOfCars"));
SetPVarFloat(playerid, var, (position[1] + (7.5 * floatsin(-position[4], degrees))));
format(var, sizeof(var), "Y_%d", GetPVarInt(playerid, "AmountOfCars"));
SetPVarFloat(playerid, var, (position[2] + (7.5 * floatcos(position[4], degrees))));
format(var, sizeof(var), "Z_%d", GetPVarInt(playerid, "AmountOfCars"));
SetPVarFloat(playerid, var, position[3]);
format(var, sizeof(var), "Angle_%d", GetPVarInt(playerid, "AmountOfCars"));
SetPVarFloat(playerid, var, position[4]);
format(var, sizeof(var), "Carkey_%d", GetPVarInt(playerid, "AmountOfCars"));
SetPVarInt(playerid, var, vehicleid);
format(var, sizeof(var), "Paintjob_%d", GetPVarInt(playerid, "AmountOfCars"));
SetPVarInt(playerid, var, -1);
strmid(owner[vehicleid], playername, 0, strlen(playername), 255);
SavePlayerVehicleData(playerid);
return 1;
}
else return RemovePlayerFromVehicle(playerid);
}
return 0;
Check you GM. If you also have dialog with ID 1337 that can cause the problem .
|
Oh, so it is a gamemode problem? From the wiki it seems that if a script doesn't return 0 in the callback (assuming a case where no matching dialog is found), the callback wont fire for filterscripts.
Open up your gamemode and see if 0 is returned in case there's no dialog to display for the player. |
Debug the script.
Put prints in the code to see what's getting called. |