Attempting to create a /car sell with a price option.
#1

Hey there, first of all thank you for reading this.

I have this code. ( I know it's a mess, I've just been working with the 'first written' ( original ) code I've made cuz it didn't work )

pawn Код:
CMD:car(playerid, params[])
{
    if(sscanf(params, "s[4]", Option1)) return SendClientMessage("USAGE: /car [ sell ]");
    if(strcmp(Option1, "sell") == 0)
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: You are not in any vehicle.");
        format(VehFile, sizeof(VehFile), "Cars/%d.ini", GetPlayerVehicleID(playerid));
        GetPlayerName(playerid, name10, sizeof(name10));
        if(strcmp(dini_Get(VehFile, "Owner"), name10) != 0) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: You do not own this vehicle.");
        if(dini_Int(VehFile, "ForSale") == 1) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: This vehicle is already for sale.");
        if(VehPrice == -1) return SendClientMessage(playerid, COLOR_USAGE, "USAGE: /car sell [price]");
        dini_IntSet(VehFile, "ForSale", 1);
        format(message1, sizeof(message1), "[VEHICLE] You have successfuly set your %s for sale for %d. (VehID: %d)", VehModels[GetVehicleModel(GetPlayerVehicleID(playerid))-400], VehPrice, GetPlayerVehicleID(playerid));
        SendClientMessage(playerid, COLOR_USAGE, message1);
        dini_IntSet(VehFile, "Price", VehPrice);
        GetVehiclePos(GetPlayerVehicleID(playerid), xx, yy, zz);
        dini_FloatSet(VehFile, "x", xx);
        dini_FloatSet(VehFile, "y", yy);
        dini_FloatSet(VehFile, "z", zz);
        GetVehicleZAngle(GetPlayerVehicleID(playerid), xx);
        dini_FloatSet(VehFile, "Angle", xx);
        SetVehicleParamsEx(VehID[playerid], VehInfo[VehID[playerid]][Engine], VehInfo[VehID[playerid]][Lights], VehInfo[VehID[playerid]][Alarm], 0, VehInfo[VehID[playerid]][Bonnet], VehInfo[VehID[playerid]][Boot], VehInfo[VehID[playerid]][Objective]);
        VehInfo[GetPlayerVehicleID(playerid)][Doors] == 0;
        RemovePlayerFromVehicle(playerid);
        VehID[playerid] = -1;
        return 1;
    }
    return 1;
}

I'm really not sure what it does anymore, I've been changing it for about 20 hours now and I can't fix it.

Whenever I use /car sell it returns "USAGE: /car sell [price], as I wanted it to.
But even if I do enter a price, it says the same thing, also if I use /car selll it will return the same, or.. /car selll4654.
What I mean is.. as long as it starts with /car sell it will ask for a price, which I don't want it to do.
But that problem I am sure I can solve on my own.

Anyway, I'd like you not to solve it and send me a fixed code, I'd like you to explain what's wrong, I mean.. I want to fix this alone I just need 'directions'.

Thank you in advance.

- Denying
Reply
#2

I may be completely wrong here as I might be miss-interpreting what you're saying it is doing but I'm gathering it is only showing the USAGE no matter what you type?

It may be something to do with the parameter being set to s[4].. that's only retrieving the word 'sell' it also needs to retrieve the amount it is being sold for.. the parameter is only checking for the word sell... If you understand what I mean? It might be something relating to adding a "d" or "i" after the "s[4]" so that it knows it needs to check for "sell [price]" ? I may be entirely wrong as I said.. it was just how i've read the post... Get back to me, if i'm wrong i'm still here to give you a hand
Reply
#3

You would be correct if the part I showed you was the only one.

I have a few other functions which are /car lock, /car buy, therefore I need that to check only the word sell, buy or lock ( for now ).

And then check a sub-variable in the /car sell part. At the beginning when I just created this command it used to tell me "/car [ sell / lock / buy ]" if I typed something different than all these three, which means also /car sell 1.

But I don't have that problem anymore.. I told the problem.
Reply
#4

no one?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)