SA-MP Forums Archive
/buyinsurance [amount] confirm possile? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /buyinsurance [amount] confirm possile? (/showthread.php?tid=594728)



/buyinsurance [amount] confirm possile? - MayaEU - 22.11.2015

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;
    }



Re: /buyinsurance [amount] confirm possile? - Yashas - 22.11.2015

ZCMD & sscanf is the fastest, reliable, programmer-friendly to play with commands.

Use IZCMD and then use sscanf to obtain the number.


Re: /buyinsurance [amount] confirm possile? - MayaEU - 22.11.2015

I know, but i dont want to change the Whole script it contains 75k lines


Re: /buyinsurance [amount] confirm possile? - Yashas - 22.11.2015

You can use sscanf though without having to update the whole script.


Re: /buyinsurance [amount] confirm possile? - MayaEU - 22.11.2015

I actually like scrcmp, i just hope anyone can help me with this command


Re: /buyinsurance [amount] confirm possile? - MayaEU - 22.11.2015

Please tell me if i have to explain better


Re: /buyinsurance [amount] confirm possile? - MayaEU - 22.11.2015

Still not fixed


Re: /buyinsurance [amount] confirm possile? - N0FeaR - 22.11.2015

Why use scrcmp? sscanf and zcmd is way faster.


Re: /buyinsurance [amount] confirm possile? - MayaEU - 22.11.2015

strcmp Works fine for me


Re: /buyinsurance [amount] confirm possile? - MayaEU - 23.11.2015

Anyone?