22.11.2015, 11:50
Hi, how can i make that i have to type */buyinsurance [amount] confirm" before i will get the Insurances?
pawn Код:
if(strcmp(cmd, "/buyinsurance", true) == 0 || strcmp(cmd, "/buyinsurances", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(!IsPlayerInRangeOfPoint(playerid,2.0,956.7999, -53.7001, 1001.5))
{
SendClientMessage(playerid, COLOR_GREY, "You can not buy insurance here.");
return 1;
}
new key2;
new amount = strval(tmp);
new price = amount * CarInfo[key2][cInsurePrice];
if(ForwardOwnCar(1,playerid)) { key2 = PlayerInfo[playerid][pCarkey]; }
else if(ForwardOwnCar(2,playerid)) { key2 = PlayerInfo[playerid][pCarkey2]; }
else if(ForwardOwnCar(3,playerid)) { key2 = PlayerInfo[playerid][pCarkey3]; }
else if(ForwardOwnCar(4,playerid)) { key2 = PlayerInfo[playerid][pCarkey4]; }
else if(ForwardOwnCar(5,playerid)) { key2 = PlayerInfo[playerid][pCarkey5]; }
else { SendClientMessage(playerid, COLOR_GREY, "You don't have a vehicle out."); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
format(string,sizeof(string),"%d policies for your %s will cost you a total of $%d ($%d each)",amount,CarInfo[key2][cDescription],price,CarInfo[key2][cInsurePrice]);
SendClientMessage(playerid,COLOR_GREY, string);
SendClientMessage(playerid, COLOR_GREY, "type /buyinsurance [number] confirm to accept.");
return 1;
}
if(!strlen(tmp))
{
format(string,sizeof(string),"%d policies for your %s will cost you a total of $%d ($%d each)",amount,CarInfo[key2][cDescription],price,CarInfo[key2][cInsurePrice]);
SendClientMessage(playerid,COLOR_GREY, string);
SendClientMessage(playerid, COLOR_GREY, "type /buyinsurance [number] confirm to accept.");
return 1;
}
if(amount < 1 || amount > 20)
return SendClientMessage(playerid, COLOR_GREY, "The company will not go below 1 and above 20.");
for(new i = 0; i < sizeof(CarInfo); i++)
{
if(GetMoney(playerid) <= price)
{
SendClientMessage(playerid, COLOR_GRAD2, "You can not afford this insurance. There is an ATM to your right.");
return 1;
}
if(CarInfo[key2][cInsure] > 19)
{
format(string,sizeof(string),"your %s already has %d policies, the company will only let you have 20.",CarInfo[key2][cDescription],CarInfo[key2][cInsure]);
SendClientMessage(playerid,COLOR_GRAD2, string);
return 1;
}
CarInfo[key2][cInsure] += amount;
GiveMoney(playerid, -price);
format(string, sizeof(string), "%s enters their details into the terminal and pays $%d for %d insurances",RemoveUnderScore(playerid),price,amount);
ProxDetector(25.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SaveCars();
UpdateAccount(playerid);
return 1;
}
}
return 1;
}