If statement not working
#1

Hey guys im trying to make an if statement but it is not working. When the player has the car / is in range of the area and types /vbuy still allows him to buy an other car with the dialog up.

Here is the command.
pawn Код:
COMMAND:vbuy(playerid, params[])
{
        if(VehicleInfo[playerid][Hascar] = 1) // range of dealer ship
        {
            if(IsPlayerInRangeOfPoint(playerid, 30.0,2130.2834,-1145.3992,24.6749)) // range of dealer ship
            {
                SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Loading Car buying menu.");
                ShowPlayerDialog(playerid,85,DIALOG_STYLE_LIST,"Vehicle Selection","1. Landstalker $75,000\r\n2. Buffalo $60,000\r\n3. Sentinel $40,000\r\n4. Infernus $125,000\r\n5. Bullet $100,000\r\n6. PCJ600 $50,000","Buy", "Cancel");//
            }
            else
            SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: you own the max limit of cars at the moment.");
        }
        else
        SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: you own the max limit of cars at the moment.");
        return 1;
}
Okay so basicly with the command i want it so that if the player allready has a vehicle which is defined as Vehicleinfo[playerid][hascar] = 1 then it won't allow him to buy an other car.

Okay here is the code of my dialog for when a player buys one of the cars

pawn Код:
switch(listitem)
            {
                case 0:
                {
                    VehicleInfo[playerid][Vspawned] = 1;
                    VehicleInfo[playerid][Hascar] = 1;
                    VehicleInfo[playerid][Veh1id] = 400;
                    CreateVehicle(400,2125.5361,-1134.8485,25.1767,356.4739,0,0,700); // car spawn
                    GivePlayerMoney(playerid, -75000);
                    SendClientMessage(playerid, 0x42F3F198, "You have bought a Landstalker for $75,000 type /vhelp for vehicle help.");
                }
                case 1:
                {
                    VehicleInfo[playerid][Vspawned] = 1;
                    VehicleInfo[playerid][Hascar] = 1;
                    VehicleInfo[playerid][Veh1id] = 402;
                    CreateVehicle(402,2125.5361,-1134.8485,25.1767,356.4739,0,0,700); // car spawn
                    GivePlayerMoney(playerid, -60000);
                    SendClientMessage(playerid, 0x42F3F198, "You have bought a Buffalo for $60,000 type /vhelp for vehicle help.");
                }
                case 2:
                {
                    CreateVehicle(405,2125.5361,-1134.8485,25.1767,356.4739,0,0,700); // car spawn
                    VehicleInfo[playerid][Vspawned] = 1;
                    VehicleInfo[playerid][Hascar] = 1;
                    VehicleInfo[playerid][Veh1id] = 405;
                    GivePlayerMoney(playerid, -40000);
                    SendClientMessage(playerid, 0x42F3F198, "You have bought a Sentinel for $40,000 type /vhelp for vehicle help.");
                }
                case 3:
                {
                    CreateVehicle(411,2125.5361,-1134.8485,25.1767,356.4739,0,0,700); // car spawn
                    VehicleInfo[playerid][Vspawned] = 1;
                    VehicleInfo[playerid][Hascar] = 1;
                    VehicleInfo[playerid][Veh1id] = 411;
                    GivePlayerMoney(playerid,-125000);
                    SendClientMessage(playerid, 0x42F3F198, "You have bought a Infernus for $125,000 type /vhelp for vehicle help.");
                }
                case 4:
                {
                    CreateVehicle(541,2125.5361,-1134.8485,25.1767,356.4739,0,1,-1); // car spawn
                    VehicleInfo[playerid][Vspawned] = 1;
                    VehicleInfo[playerid][Hascar] = 1;
                    VehicleInfo[playerid][Veh1id] = 541;
                    GivePlayerMoney(playerid,-100000);
                    SendClientMessage(playerid, 0x42F3F198, "You have bought a Bullet for $100,000 type /vhelp for vehicle help.");
                }
                case 5:
                {
                    CreateVehicle(461,2125.5361,-1134.8485,25.1767,356.4739,0,0,700); // car spawn
                    VehicleInfo[playerid][Vspawned] = 1;
                    VehicleInfo[playerid][Hascar] = 1;
                    VehicleInfo[playerid][Veh1id] = 461;
                    GivePlayerMoney(playerid,-50000);
                    SendClientMessage(playerid, 0x42F3F198, "You have bought a PCJ600 for $50,000 type /vhelp for vehicle help.");
                }
            }
        }
    }
Reply


Messages In This Thread
If statement not working - by jueix - 23.07.2012, 12:17
Re: If statement not working - by Cjgogo - 23.07.2012, 12:44
Re: If statement not working - by Glint - 23.07.2012, 12:47
Re: If statement not working - by Cjgogo - 23.07.2012, 12:49
Re: If statement not working - by Glint - 23.07.2012, 13:01
Re: If statement not working - by Cjgogo - 23.07.2012, 13:10

Forum Jump:


Users browsing this thread: 1 Guest(s)