hey I have this command
I wanna turn it to be on dialog which show me the cars he own and when I press on one it resets the correct one ho tow do that? can anyone help
PHP Code:
CMD:resetcar(playerid, params[])
{
new playername[25], string[256], giveplayerid, moneys1, tmp[256],str[130], slot=-1, loc=-1;
if (PlayerVehicles(playerid) > 1)
{
if(sscanf(params, "i", slot)) return SendClientMessage2(playerid, COLOR_WHITE, "Usage: /resetcar [slot]") && SendClientMessage2(playerid, COLOR_WHITE, "See your slots by using /myvehs");
}
else if (PlayerVehicles(playerid) == 1) slot=0;
else return SendClientMessage2(playerid, COLOR_RED, "Error: You do not own a vehicle!");
if(slot < 0 || slot > MaxOwnVehs(playerid)) return SendClientMessage2(playerid, COLOR_RED, "Error: That slot doesn't exist!");
if (!PlayerVehicleIS(playerid, slot)) return SendClientMessage2(playerid, COLOR_RED, "Error: You do not own a vehicle in that slot!");
if (IsPlayerInVehicle(playerid, pvehicle[playerid][0][slot])) return SendClientMessage2(playerid, COLOR_SILVER, "Your vehicle doesn't need relocating, you are in it!");
if (GetVehicleHealth2(pvehicle[playerid][0][slot]) == 100.0) return SendClientMessage2(playerid, COLOR_RED, "Your vehicle can't be reset due to the damage.");
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
new tvar1 = dini_Int(AddDirFile(dir_userfiles, playername), "propowned")-1;
new tvar12 = dini_Int(AddDirFile(dir_userfiles, playername), "busowned")-1;
ResetCarSlot[playerid] = slot;
format(string, 50, "V_%s_%d", playername, slot);
new tvar2 = dini_Int(AddDirFile(dir_carfiles, string), "model");
if (tvar1 != -1 && tvar12 == -1 && loc == -1)
{
if (DoesPlayerHaveMenuOpen(playerid) || GetPlayerDialog(playerid) != -1) return SendClientMessage2(playerid, COLOR_WHITE, "SERVER: Please exit your current menu first.");
ShowPlayerDialog2(playerid, DIALOG_RESET_CAR, DIALOG_STYLE_LIST, "Where do you want to reset your car?", "Police Department\nYour Property", "Select", "Cancel");
return 1;
}
else if (tvar12 != -1 && tvar1 == -1 && loc == -1)
{
if (DoesPlayerHaveMenuOpen(playerid) || GetPlayerDialog(playerid) != -1) return SendClientMessage2(playerid, COLOR_WHITE, "SERVER: Please exit your current menu first.");
ShowPlayerDialog2(playerid, DIALOG_RESET_CAR3, DIALOG_STYLE_LIST, "Where do you want to reset your car?", "Police Department\nYour Business", "Select", "Cancel");
return 1;
}
else if(tvar12 != -1 && tvar1 != -1 && loc == -1)
{
if (DoesPlayerHaveMenuOpen(playerid) || GetPlayerDialog(playerid) != -1) return SendClientMessage2(playerid, COLOR_WHITE, "SERVER: Please exit your current menu first.");
ShowPlayerDialog2(playerid, DIALOG_RESET_CAR2, DIALOG_STYLE_LIST, "Where do you want to reset your car?", "Police Department\nYour Property\nYour Business", "Select", "Cancel");
return 1;
}
new panels, doors, lights, tires, Float:health;
if (tvar1 == -1 || tvar12 != -1) {
new tvar3, tvar4, tvar5, Float:x, Float:y, Float:z, Float:a;
giveplayerid = -1;
tvar5 = vehstored[pvehicle[playerid][0][slot]];
if (tvar5 != -1) {
holdsv[tvar5] = 0;
vehstored[pvehicle[playerid][0][slot]] = -1;
}
if (GetPlayerInterior(playerid) != 0) {
new shamalid = GetPlayerShamalID(playerid);
if (shamalid != 0 && GetVehicleInterior(shamalid) == 0) {
GetVehiclePos(shamalid, x, y, z);
}
else {
x = adata[plastdoor[playerid]][ax];
y = adata[plastdoor[playerid]][ay];
z = adata[plastdoor[playerid]][az];
}
}
else {
GetPlayerPos(playerid, x, y, z);
}
for (new d = 0; d < sizeof(pdCoords); d++) {
if (PointToPoint2D(x, y, pdCoords[d][0], pdCoords[d][1]) <= PointToPoint2D(x, y, pdCoords[tvar3][0], pdCoords[tvar3][1])) {
tvar4 = -1;
for (new b = 0; b < sizeof(pdCarCoords); b++) {
if (pdCarCoords[b][4] == d+1 && holdsv[b] == 0) {
tvar4 = b;
break;
}
}
if (tvar4 != -1) {
giveplayerid = d;
moneys1 = tvar4;
}
tvar3 = d;
}
}
if (giveplayerid == -1) {
ResetCarSlot[playerid] = -1;
return SendClientMessage2(playerid, COLOR_WHITE, "Sorry there are no spaces available to relocate your vehicle.");
}
if (tvar2 == 457 || tvar2 == 596 || tvar2 == 597 || tvar2 == 598) {
for (new i = 0, playercount=GetPlayerPoolSize(); i <= playercount; i++) {
format(tmp, 12, "hpevsp%d", pvehicle[playerid][0][slot]);
if (GetPVarInt(i, tmp) == 1) {
SetPVarInt(i, tmp, 0);
}
}
}
if (bootdcp[pvehicle[playerid][0][slot]] != 0) {
DestroyDynamicCP(bootdcp[pvehicle[playerid][0][slot]]);
for (new i = 0, playercount=GetPlayerPoolSize(); i <= playercount; i++) {
if (IsPlayerConnected2(i) && pdynamiccp[i] == bootdcp[pvehicle[playerid][0][slot]]) {
CallLocalFunction("OnPlayerLeaveDynamicCP", "dd", i, pdynamiccp[i]);
}
}
cptype[bootdcp[pvehicle[playerid][0][slot]]][0] = 0;
cptype[bootdcp[pvehicle[playerid][0][slot]]][1] = -1;
bootdcp[pvehicle[playerid][0][slot]] = 0;
}
if (tvar5 == -1 && GetVehicleVirtualWorld(pvehicle[playerid][0][slot]) == 0) {
GetVehiclePos(pvehicle[playerid][0][slot], x, y, z);
GetVehicleZAngle(pvehicle[playerid][0][slot], a);
dini_FloatSet(AddDirFile(dir_carfiles, string), "X", x);
dini_FloatSet(AddDirFile(dir_carfiles, string), "Y", y);
dini_FloatSet(AddDirFile(dir_carfiles, string), "Z", z);
dini_FloatSet(AddDirFile(dir_carfiles, string), "A", a);
}
new temp1 = pvehicle[playerid][0][slot];
new temp2 = GetVehicleModel(temp1);
if (tvar2 == temp2) {
GetVehicleDamageStatus(pvehicle[playerid][0][slot], panels, doors, lights, tires);
dini_IntSet(AddDirFile(dir_carfiles, string), "panels", panels);
dini_IntSet(AddDirFile(dir_carfiles, string), "doors", doors);
dini_IntSet(AddDirFile(dir_carfiles, string), "lights", lights);
dini_IntSet(AddDirFile(dir_carfiles, string), "tires", tires);
}
else {
vmodelused[temp2-400] --;
if (vmodelused[temp2-400] == 0) vehiclemodels --;
dini_IntSet(AddDirFile(dir_carfiles, string), "panels", 0);
dini_IntSet(AddDirFile(dir_carfiles, string), "doors", 0);
dini_IntSet(AddDirFile(dir_carfiles, string), "lights", 0);
dini_IntSet(AddDirFile(dir_carfiles, string), "tires", 0);
}
GetVehicleHealth(pvehicle[playerid][0][slot], health);
dini_FloatSet(AddDirFile(dir_carfiles, string), "health", health-1000);
DestroyVehicle(pvehicle[playerid][0][slot]);
pvehicle[playerid][0][slot] = CreateVehicle(tvar2, pdCarCoords[moneys1][0], pdCarCoords[moneys1][1], pdCarCoords[moneys1][2], pdCarCoords[moneys1][3], vehcol[pvehicle[playerid][0][slot]][0], vehcol[pvehicle[playerid][0][slot]][1], -1);
if (pvehicle[playerid][0][slot] != temp1) {
vehcol[pvehicle[playerid][0][slot]][0] = vehcol[temp1][0];
vehcol[pvehicle[playerid][0][slot]][1] = vehcol[temp1][1];
vehcol[temp1][0] = 0;
vehcol[temp1][1] = 0;
if (bootdata[temp1][0][0] != 0)
{
bootdata[pvehicle[playerid][0][slot]][0][0] = bootdata[temp1][0][0];
bootdata[temp1][0][0] = 0;
bootdata[pvehicle[playerid][0][slot]][0][1] = bootdata[temp1][0][1];
bootdata[temp1][0][1] = 0;
bootdata[pvehicle[playerid][0][slot]][0][2] = bootdata[temp1][0][2];
bootdata[temp1][0][2] = 0;
bootdata[pvehicle[playerid][0][slot]][0][3] = bootdata[temp1][0][3];
bootdata[temp1][0][3] = 0;
bootdata[pvehicle[playerid][0][slot]][0][4] = bootdata[temp1][0][4];
bootdata[temp1][0][4] = 0;
}
if (bootdata[temp1][1][0] != 0)
{
bootdata[pvehicle[playerid][0][slot]][1][0] = bootdata[temp1][1][0];
bootdata[temp1][1][0] = 0;
bootdata[pvehicle[playerid][0][slot]][1][1] = bootdata[temp1][1][1];
bootdata[temp1][1][1] = 0;
bootdata[pvehicle[playerid][0][slot]][1][2] = bootdata[temp1][1][2];
bootdata[temp1][1][2] = 0;
bootdata[pvehicle[playerid][0][slot]][1][3] = bootdata[temp1][1][3];
bootdata[temp1][1][3] = 0;
bootdata[pvehicle[playerid][0][slot]][1][4] = bootdata[temp1][1][4];
bootdata[temp1][1][4] = 0;
}
if (plockedveh[playerid] == temp1) {
for (new i = 0, playercount=GetPlayerPoolSize(); i <= playercount; i++) {
if (i != playerid) {
vehiclelocked[i][temp1] = false;
vehiclelocked[i][pvehicle[playerid][0][slot]] = true;
}
}
plockedveh[playerid] = pvehicle[playerid][0][slot];
}
Gas[pvehicle[playerid][0][slot]] = Gas[temp1];
Gas[temp1] = FuelMax;
}
//
SetVehicleHealth(pvehicle[playerid][0][slot], health);
if (tvar2 == temp2) {
UpdateVehicleDamageStatus(pvehicle[playerid][0][slot], panels, doors, lights, tires);
}
for (new d = 0; d < CAR_MOD_SLOTS; d++) {
format(tmp, 24, "mod_s%d", d);
if (dini_Isset(AddDirFile(dir_carfiles, string), tmp)) {
AddVehicleComponent(pvehicle[playerid][0][slot], dini_Int(AddDirFile(dir_carfiles, string), tmp));
}
}
if (dini_Isset(AddDirFile(dir_carfiles, string), "paintjob")) {
ChangeVehiclePaintjob(pvehicle[playerid][0][slot], dini_Int(AddDirFile(dir_carfiles, string), "paintjob"));
}
if (dini_Isset(AddDirFile(dir_carfiles, string), "lplate")) {
if (dini_Isset(AddDirFile(dir_carfiles, string), "platecolor")) {
format(tmp, 32, "{%s}%s", dini_Get(AddDirFile(dir_carfiles, string), "platecolor"), dini_Get(AddDirFile(dir_carfiles, string), "lplate"));
SetVehicleNumberPlate2(pvehicle[playerid][0][slot], tmp);
}
else {
SetVehicleNumberPlate2(pvehicle[playerid][0][slot], dini_Get(AddDirFile(dir_carfiles, string), "lplate"));
}
}
vehstored[pvehicle[playerid][0][slot]] = moneys1;
holdsv[moneys1] = pvehicle[playerid][0][slot];
if( dini_Int(AddDirFile(dir_carfiles, string), "nenon11") || dini_Int(AddDirFile(dir_carfiles, string), "nenon12"))
{
dini_IntSet(AddDirFile(dir_userfiles, playername), "Neon", 0);
DestroyObject(obj3[pvehicle[playerid][0][slot]]);
DestroyObject(obj4[pvehicle[playerid][0][slot]]);
dini_Unset(AddDirFile(dir_carfiles, string), "nenon11");
dini_Unset(AddDirFile(dir_carfiles, string), "nenon12");
obj3[pvehicle[playerid][0][slot]] = 0;
obj4[pvehicle[playerid][0][slot]] = 0;
}
format(string, 128, "Your %s has been allocated to %s.", vehName[tvar2-400], pdNames[giveplayerid]);
SendClientMessage2(playerid, COLOR_ORANGE, string);
ResetCarSlot[playerid] = -1;
}
printf("[resetcar] %s (Id%d) has reset their vehicle.", playername, playerid);
return 1;
}
PHP Code:
stock UpdatePlayerVehicleSlots(player)
{
new str[128], str2[128], playername[25];
GetPlayerName(player, playername, 25);
for(new ipv=0; ipv<MaxOwnVehs(player); ipv++)
{
format(str, sizeof(str), "V_%s_%d", playername, ipv);
if(!dini_Exists(AddDirFile(dir_carfiles, str)))
{
for(new i=ipv+1; i<MaxOwnVehs(player); i++)
{
format(str2, sizeof(str2), "V_%s_%d", playername, i);
if(dini_Exists(AddDirFile(dir_carfiles, str2)))
{
DINI_frenametextfile(AddDirFile(dir_carfiles, str2), AddDirFile(dir_carfiles, str));
pvehicle[player][0][ipv] = pvehicle[player][0][i];
pvehicle[player][0][i]=0;
break;
}
}
}
}
}
stock PlayerVehicle(player, vehid)
{
new pveh=-1;
for(new ipv=0; ipv<MaxOwnVehs(player); ipv++)
{
if(pvehicle[player][0][ipv] == vehid)
{
pveh=ipv;
break;
}
}
return pveh;
}
stock PlayerVehicleIS(player, slot)
{
if(pvehicle[player][0][slot] > 0) return 1;
return 0;
}
stock PlayerVehicleLeft(player)
{
new pveh=-1;
for(new ipv=MaxOwnVehs(player)-1; ipv>=0; ipv--)
{
new str[128];
GetPlayerName(player, str, 25);
format(str, sizeof(str), "V_%s_%d", str, ipv);
if(!dini_Exists(AddDirFile(dir_carfiles, str))) pveh=ipv;
}
return pveh;
}
stock PlayerVehicles(player)
{
new pveh=0;
for(new ipv=0; ipv<MaxOwnVehs(player); ipv++)
{
new str[128];
GetPlayerName(player, str, 25);
format(str, sizeof(str), "V_%s_%d", str, ipv);
if(dini_Exists(AddDirFile(dir_carfiles, str))) pveh++;
}
return pveh;
}
stock MaxOwnVehs(player)
{
new amount=1;
if(vipmember[player]==2) amount = 6;
else if(vipmember[player]==1) amount = 3;
return amount;
}