17.08.2012, 01:09
I Have a dyamanic Car Syteam and everytime a place gets into a car and clicks any of the botton it will ethier buy the car(if hes got enought money) or make the player /exit but when the player /exits the player cant move
The Code
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1337)
{
if(response)
{
new
vehicleid = GetPlayerVehicleID(playerid),
model = GetVehicleModel(vehicleid),
price = VehicleStatistics[vehicleid][vehicle_price],
Floatosition[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;
}
The Code
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1337)
{
if(response)
{
new
vehicleid = GetPlayerVehicleID(playerid),
model = GetVehicleModel(vehicleid),
price = VehicleStatistics[vehicleid][vehicle_price],
Floatosition[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;
}