14.08.2010, 00:21
Try this:
pawn Код:
if(!strcmp("/vbuy", cmdtext, true, 5))
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, "You must be in a car!");
for(new i=0; i<MAX_CARS; i++)
{
new file[100];
format(file, sizeof(file), "cars/%s.uma", CarInfo[i][CarName]);
new vehicle = GetPlayerVehicleID(playerid);
if(vehicle != CarCreate[i]) return SendClientMessage(playerid, RED, "This car is not for sale!");
if(GetPlayerMoney(playerid) < CarInfo[i][CarCost]) return SendClientMessage(playerid, 0xF60000AA, "You don't have enough money to buy this Car!");
if(CarInfo[i][Owned] == 1) return SendClientMessage(playerid, 0xF60000AA, "This Car is already owned!");
new Pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Pname, sizeof(Pname));
dini_Set1(file, "Owner", Pname);
dini_IntSet1(file, "Owned", 1);
GivePlayerMoney(playerid, -CarInfo[i][CarCost]);
GameTextForPlayer(playerid, "~r~Car Purchased!", 2000, 3);
CarInfo[i][Owned] = 1;
format(CarInfo[i][CarOwner], 24, "%s", Pname);
break;
}
return 1;
}
if(!strcmp("/vsell", cmdtext, true, 6))
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, "You are not in a vehicle!");
for(new i=0; i<MAX_CARS; i++)
{
if(IsPlayerInAnyVehicle(playerid))
{
new Pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Pname, sizeof(Pname));
if(strfind(CarInfo[i][CarOwner], Pname, true) == -1) return SendClientMessage(playerid, RED, "WARNING: You dont own this vehicle!");
GivePlayerMoney(playerid, CarInfo[i][CarCost]);
GameTextForPlayer(playerid, "~g~Car Sold!", 2000, 3);
CarInfo[i][Owned] = 0;
CarInfo[i][CarOwner] = EOS;
dini_Unset1("Cars.ini", Pname);
break;
}
}
return 1;
}