/buycar problem.
#1

So basically, I'm implementing a new car system for my server, but the thing is, I enter the car (it displays a message saying: This Admiral is for sale for $5000 (type /buycar to buy the car), I have enough money, I'm inside the vehicle, and I don't own the vehicle.

So the issue is that every time I /buycar in the unowned vehicle, it just sort of return's zero and doesn't do anything, there's no Server: Unknown Command, it just does nothing.

Help is pretty much appreciated. Thanks.


CODE
pawn Код:
COMMAND:buycar(playerid, params[])
{
    new sendername[MAX_PLAYER_NAME], playername[MAX_PLAYER_NAME];
    new vehicleid = GetPlayerVehicleID(playerid);
    new name = GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);
    new string[128];
    if(!IsPlayerInAnyVehicle(playerid)) {
        SendClientMessage(playerid, COLOR_WHITE, "You are not in a vehicle.");
        return 1;
    }
    if(PlayerHasCar[playerid] == 1) {
        SendClientMessage(playerid, COLOR_WHITE, "You can only own one car at a time, sorry.");
        RemovePlayerFromVehicle(playerid);
        TogglePlayerControllable(playerid, 1);
        return 1;
    }
    for(new i; i<MAX_PLAYERS; i++) {
        for(new j; j<MAX_VEHICLES; j++) {
        new loopedname = GetPlayerName(i, playername, MAX_PLAYER_NAME);
        if(PlayerHasCar[playerid] == 0 && CarInfo[vehicleid][vOwned] == vehicleid && CarInfo[vehicleid][vOwnerName] == loopedname && CarInfo[vehicleid][vOwner] == j)
        SendClientMessage(playerid, COLOR_WHITE, "You may not purchase this vehicle because it's already owned.");
        return 1;
        }
    }
    if(GetPlayerMoney(playerid < CarList[vehicleid][Price])) {
        SendClientMessage(playerid, COLOR_WHITE, "You do not have enough money to purchase this vehicle.");
        return 1;
    }
    PlayerHasCar[playerid] = 1;
    CarInfo[vehicleid][vOwned] = vehicleid;
    CarInfo[vehicleid][vOwner] = playerid;
    CarInfo[vehicleid][vOwnerName] = name;
    TogglePlayerControllable(playerid, 1);
    GivePlayerMoney(playerid, -CarList[vehicleid][Price]);
    format(string,128,"You have successfully bought a(n) %s for $%d.", CarList[vehicleid][Name], CarList[vehicleid][Price]);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)