/sellto vehicle command - help!
#1

Honestly, I've been sitting here the whole day now trying to figure this out. What I'm trying to do is a /sellto command.

Here's the command sofar, (I've tried 100 different methods and deleted them; here's the base)

pawn Код:
CMD:sellto(playerid, params[])
{
    new
    PID, veh1, veh2, veh3, color1, color2;

    if(PlayerInfo[PID][pVehicle1] == 1 && PlayerInfo[PID][pVehicle2] == 1 && PlayerInfo[PID][pVehicle3] == 1)
    return SendClientMessage(playerid, COLOR_LIGHTRED, "[Error]: You already own 3 vehicles.");

    if(GetPlayerVehicleID(playerid) == personalcar1[playerid]) { vehid = personalcar1[playerid]; }
    else if(GetPlayerVehicleID(playerid) == personalcar2[playerid]) { vehid2 = personalcar2[playerid]; }
    else if(GetPlayerVehicleID(playerid) == personalcar3[playerid]) { vehid3 = personalcar3[playerid]; }
    else { SendClientMessage(playerid, COLOR_WHITE, "You need to be in your vehicle."); return 1; }
   
    if(IsPlayerInVehicle(playerid) == personalcar1[playerid]) { PlayerInfo[playerid][pVehicle1] = 0; }
    else if(IsPlayerInVehicle(playerid) == personalcar2[playerid]) { PlayerInfo[playerid][pVehicle2] = 0; }
    else if(IsPlayerInVehicle(playerid) == personalcar3[playerid]) { PlayerInfo[playerid][pVehicle3] = 0; }
    else { SendClientMessage(playerid, COLOR_WHITE, "You need to be in your vehicle."); return 1; }

    if (sscanf(params, "dd", PID, price)) return SCM(playerid, COLOR_GREY, "[Usage]: /sellto [playerid] [price]");
    if (price < 0 || price > 1000000) return SCM(playerid, COLOR_LIGHTRED, "[Error]: Price can't be below $1 or higher than $1,000,000.");
   
    if(PlayerInfo[PID][pVehicle1] == 0)
    {
        PlayerInfo[PID][pVehicle1] = 1;
    }
    else if(PlayerInfo[PID][pVehicle2] == 0)
    {
        PlayerInfo[PID][pVehicle2] = 1;
    }
    else if(PlayerInfo[PID][pVehicle3] == 0)
    {
        PlayerInfo[PID][pVehicle3] = 1;
    }
    return 1;
}
When the player sells the car it should set the variable PlayerInfo[playerid][pVehicle1] to 0, if the player is in his car 1. If he's in car 2 then it will set the variable PlayerInfo[playerid][pVehicle2] to 0 and same to the third car. Also, it needs to check if the buyer has 3 cars and if it has three cars then he can not buy a car from the guy selling. If he has for example two cars but wants to buy a third, the car he buys should end up in slot 3 AKA the variable PlayerInfo[PID][pVehicle3] = 1. Someone please help me... I think I'm loosing my mind.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)