Need help converting a strcmp to zcmd command
#1

This is the code.

pawn Код:
if(strcmp(cmd, "/plate",true)== 0)
{
    new ID = GetPlayerVehicleID(playerid);

    new strings[256];
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0x00FFFFFF, "You're not in a vehicle");
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /plate <License Plate>");
    else
    {
        format(strings, sizeof(strings), "%s",tmp);
        SetVehicleNumberPlate(ID,strings);
        strmid(CarInfo[VehicleOwned[ID]][cLicense], strings, 0, strlen(strings), 255);
        SetVehicleToRespawn(ID);
        format(strings,sizeof(strings),"{00C0FF}You've changed your plate name to %s please spawn your vehicle again",tmp);
        SendClientMessage(playerid, COLOR_LIGHTRED, strings);
        PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
        new string[128];
        format(string, sizeof(string), "plates.ini");
        if(!dini_Exists(string))
        {
            dini_Create(string);
            dini_Set(string, "License Plate", tmp);
        }
        SaveCars();

    }
    return 1;
}
Reply
#2

pawn Код:
CMD:plate(playerid,params[])
{
    new ID = GetPlayerVehicleID(playerid);

    new strings[256];
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0x00FFFFFF, "You're not in a vehicle");
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /plate <License Plate>");
    else
    {
        format(strings, sizeof(strings), "%s",tmp);
        SetVehicleNumberPlate(ID,strings);
        strmid(CarInfo[VehicleOwned[ID]][cLicense], strings, 0, strlen(strings), 255);
        SetVehicleToRespawn(ID);
        format(strings,sizeof(strings),"{00C0FF}You've changed your plate name to %s please spawn your vehicle again",tmp);
        SendClientMessage(playerid, COLOR_LIGHTRED, strings);
        PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
        new string[128];
        format(string, sizeof(string), "plates.ini");
        if(!dini_Exists(string))
        {
            dini_Create(string);
            dini_Set(string, "License Plate", tmp);
        }
        SaveCars();

    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by windrush
Посмотреть сообщение
CMDlate(playerid,params[])
{
new ID = GetPlayerVehicleID(playerid);

new strings[256];
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0x00FFFFFF, "You're not in a vehicle");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /plate <License Plate>");

else
{
format(strings, sizeof(strings), "%s",tmp);
SetVehicleNumberPlate(ID,strings);
strmid(CarInfo[VehicleOwned[ID]][cLicense], strings, 0, strlen(strings), 255);
SetVehicleToRespawn(ID);
format(strings,sizeof(strings),"{00C0FF}You've changed your plate name to %s please spawn your vehicle again",tmp);
SendClientMessage(playerid, COLOR_LIGHTRED, strings);
PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
new string[128];
format(string, sizeof(string), "plates.ini");
if(!dini_Exists(string))
{
dini_Create(string);
dini_Set(string, "License Plate", tmp);
}
SaveCars();

}
return 1;
}
That's still in strcmp. Thanks for the the reply though..
Reply
#4

That is ZCMD -_-
Reply
#5

Quote:
Originally Posted by windrush
Посмотреть сообщение
That is ZCMD -_-
lol test this. Please... compile it and test it.
Reply
#6

Quote:
Originally Posted by windrush
Посмотреть сообщение
That is ZCMD -_-
That won't work.

pawn Код:
CMD:plate(playerid,params[])
{
    new ID = GetPlayerVehicleID(playerid);
    new string[128],plate[20];
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0x00FFFFFF, "You're not in a vehicle");
    if(sscanf(params,"s",plate)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /plate <License Plate>");
    SetVehicleNumberPlate(ID,plate);
    strmid(CarInfo[VehicleOwned[ID]][cLicense], string, 0, strlen(string), 255);
    SetVehicleToRespawn(ID);
    format(string,sizeof(string),"{00C0FF}You've changed your plate to %s.",plate);
    SendClientMessage(playerid, COLOR_LIGHTRED, string);
    PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
    if(!dini_Exists("plates.ini"))
    {
        dini_Create("plates.ini");
        dini_Set("plates.ini", "License Plate", plate);
    }
    SaveCars();
    return 1;
}
I have removed some logicly stupid things (ex. "plase respawn your car" and you have respawned it line before) and I have used sscanf since it's best to use sscanf with ZCMD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)