SA-MP Forums Archive
How to make this into strcmp? - 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: How to make this into strcmp? (/showthread.php?tid=611704)



How to make this into strcmp? - MayaEU - 10.07.2016

Hi how to make this into strcmp?

pawn Код:
dcmd_carsanction(playerid, params[])
{
    //if(!IsPlayerPoliceOfficer(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]You can not use this command"); //Create your own stock which check if is a police officer
    if(!IsACop(playerid) && PlayerInfo[playerid][pLeader] != 3 && !(PlayerInfo[playerid][pAdmin] & ADMIN_ACCESS))
        return SendClientMessage(playerid, COLOR_GREY, "You are not a law enforcement official.");
    new vehicleid = GetVehicleIDNearPlayer(playerid);
    if(vehicleid == INVALID_VEHICLE) return SendClientMessage(playerid, COLOR_GREY, "No vehicles found within your range.");
    if(VehicleSanctionStats[vehicleid][Sanctioned] == true) return SendClientMessage(playerid, COLOR_GREY, "This vehicle already have a parkingticket");
    new sPrice, sReason[128];
    if(sscanf(params, "ds[128]", sPrice, sReason)) return SendClientMessage(playerid, COLOR_GRAD2, ""COL_SZR"Usage:"COL_WHITE" /parkingticket [price] [reason]");
    VehicleSanctionStats[vehicleid][Sanctioned] = true;
    format(VehicleSanctionStats[vehicleid][PTReason], 128, "%s", sReason);
    VehicleSanctionStats[vehicleid][PTPrice] = sPrice;

    new str[128];
    format(str, sizeof(str), "Sanctioned: vID: %d | Price: $%d | Reason: %s", vehicleid, VehicleSanctionStats[vehicleid][PTPrice], VehicleSanctionStats[vehicleid][PTReason]);
    SendClientMessage(playerid, 0x6464FF00, str);

    format(str, sizeof(str), ""COL_BIZ"Parking Ticket\nPrice: %d\nReason: %s",VehicleSanctionStats[vehicleid][PTPrice], VehicleSanctionStats[vehicleid][PTReason]);
    VehicleSanctionStats[vehicleid][sText3d] = Create3DTextLabel(str, COLOR_BIZ, 0.0, 0.0, 0.0, TD_DISTANCE, 0, 0);
    Attach3DTextLabelToVehicle(VehicleSanctionStats[vehicleid][sText3d], vehicleid, 0.0, 0.0, 0.0);
    return 1;
}



Re: How to make this into strcmp? - Gammix - 10.07.2016

pawn Код:
new cmd[35];
sscanf(cmdtext, "s[35]", cmd);
if (!strcmp(cmd, "/carsanction", true))
{
    // your code
}



Re: How to make this into strcmp? - MayaEU - 10.07.2016

Like this?

pawn Код:
new cmd[35];
    sscanf(cmdtext, "s[35]", cmd);
    if (!strcmp(cmd, "/parkingticket", true))
    {
            if(PlayerInfo[playerid][pMember] != 3)
                return SendClientMessage(playerid, COLOR_GREY, "You are not a Traffic Cop.");
            new vehicleid = GetVehicleIDNearPlayer(playerid);
            if(vehicleid == INVALID_VEHICLE) return SendClientMessage(playerid, COLOR_GREY, "No vehicles found within your range.");
            if(VehicleSanctionStats[vehicleid][Sanctioned] == true) return SendClientMessage(playerid, COLOR_GREY, "This vehicle already have a sanction");
            new sPrice, sReason[128];
            if(sscanf(cmdtext, "ds[128]", sPrice, sReason)) return SendClientMessage(playerid, COLOR_GRAD2, ""COL_SZR"Usage:"COL_WHITE" /parkingticket [price] [reason]");
            if(sPrice < 1 || sPrice > 1500) { SendClientMessage(playerid, COLOR_GREY, "The sanction can't be below $1 or higher then $1,500."); return 1; }
            VehicleSanctionStats[vehicleid][Sanctioned] = true;
            format(VehicleSanctionStats[vehicleid][PTReason], 128, "%s", sReason);
            VehicleSanctionStats[vehicleid][PTPrice] = sPrice;
            if(IsAnOwnableCar(vehicleid))
            {
                CarInfo[VehicleOwned[vehicleid]][cPTicket] = 1;
                CarInfo[VehicleOwned[vehicleid]][cPTPrice] = VehicleSanctionStats[vehicleid][PTPrice];
                format(sReason, sizeof(sReason), VehicleSanctionStats[vehicleid][PTReason]);
                strmid(CarInfo[VehicleOwned[vehicleid]][cPTReason], sReason, 0, strlen(sReason), 255);
                SaveCars();
            }
            new str[128];
            format(str, sizeof(str), "Sanctioned: vID: %d | Price: $%d | Reason: %s", vehicleid, VehicleSanctionStats[vehicleid][PTPrice], VehicleSanctionStats[vehicleid][PTReason]);
            SendClientMessage(playerid, 0x6464FF00, str);
            format(str, sizeof(str), "* %s writes down a vehicle sanction, and places it on the %s's windshield wiper.", RemoveUnderScore(playerid),vehName[GetVehicleModel(vehicleid)-400]);
            ProxDetector(30.0, playerid, str, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);

            format(str, sizeof(str), ""COL_BIZ"Vehicle Sanction\nPrice: $%d\nReason: %s",VehicleSanctionStats[vehicleid][PTPrice], VehicleSanctionStats[vehicleid][PTReason]);
            VehicleSanctionStats[vehicleid][sText3d] = Create3DTextLabel(str, COLOR_BIZ, 0.0, 0.0, 0.0, TD_DISTANCE, 0, 0);
            Attach3DTextLabelToVehicle(VehicleSanctionStats[vehicleid][sText3d], vehicleid, 0.0, 0.0, 0.0);
            return 1;
    }