Remove Bike Cmd Help
#1

Hi.I Make This Cmd For Remove All Bike In Server By Vehicle id 510
But Not Work Pls Fix It TnX(+ REP) THis CmD:

Код:
dcmd_removebike(playerid,params[])
{
    #pragma unused params
    if(GetVehicleModel(vehicleid) == 510 )
    {
    DestroyVehicle(vehicleid);
	}
        }
	return 1;
	}
Reply
#2

pawn Код:
dcmd_removebike(playerid,params[])
{
    new vehicleid = GetPlayerVehicleID(playerid);
    if(GetVehicleModel(vehicleid) == 510)
    {
        DestroyVehicle(vehicleid);
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by DexterC
Посмотреть сообщение
pawn Код:
dcmd_removebike(playerid,params[])
{
    new vehicleid = GetPlayerVehicleID(playerid);
    if(GetVehicleModel(vehicleid) == 510)
    {
        DestroyVehicle(vehicleid);
    }
    return 1;
}
Not Work
Reply
#4

Try this one, works for me, but remember that you need to be inside the vehicle.
pawn Код:
dcmd_removebike(playerid,params[])
{
    new Vehicle;
    Vehicle = GetPlayerVehicleID(playerid);
    if(GetVehicleModel(vehicleid) == 510)
    {
        DestroyVehicle(Vehicle);
    }
    return 1;
}
Reply
#5

To delete all existing bikes with model-id 510, use this code.
It loops through all vehicle-id's, checks if each one has model-id 510, and if it matches, it will be deleted.
pawn Код:
dcmd_removebike(playerid,params[])
{
    #pragma unused params
    for (new vid; vid < MAX_VEHICLES; vid++)
    {
        if (GetVehicleModel(vid) == 510)
            DestroyVehicle(vid);
    }

    return 1;
}
Reply
#6

TnX PowerPC603 It Worked But How To Delet Three Model Vehicle?
Reply
#7

Quote:
Originally Posted by PowerPC603
Посмотреть сообщение
To delete all existing bikes with model-id 510, use this code.
It loops through all vehicle-id's, checks if each one has model-id 510, and if it matches, it will be deleted.
pawn Код:
dcmd_removebike(playerid,params[])
{
    #pragma unused params
    for (new vid; vid < MAX_VEHICLES; vid++)
    {
        if (GetVehicleModel(vid) == 510)
            DestroyVehicle(vid);
    }

    return 1;
}

How To Use Three Model Vehicle For Delete?
i Use It But Not Work!

Код:
for (new vid; vid < MAX_VEHICLES; vid++)
    {
        if (GetVehicleModel(vid) == 510 && 555 && 522)
            DestroyVehicle(vid);
    }
	}
    return 1;
}
Any One Fix It TnX
Reply
#8

Try this:
pawn Код:
dcmd_removebike(playerid, params[]) {
    for(new vid; vid < MAX_VEHICLES; vid++) {
        if(GetVehicleModel(vid) == 510 && GetVehicleModel(vid) == 555 && GetVehicleModel(vid) == 522) DestroyVehicle(vid);
    }
    return 1;
}
Reply
#9

pawn Код:
dcmd_removebike(playerid,params[])
{
    #pragma unused params

    // Loop through all vehicles
    for (new vid; vid < MAX_VEHICLES; vid++)
    {
        // Check the vehicle-model
        switch(GetVehicleModel(vid))
        {
            // If it's model-id 510, 522 or 555, delete the vehicle
            case 510, 522, 555:
                DestroyVehicle(vid);
        }
    }

    return 1;
}

Quote:
Originally Posted by Dystans
Посмотреть сообщение
Try this:
pawn Код:
dcmd_removebike(playerid, params[]) {
    for(new vid; vid < MAX_VEHICLES; vid++) {
        if(GetVehicleModel(vid) == 510 && GetVehicleModel(vid) == 555 && GetVehicleModel(vid) == 522) DestroyVehicle(vid);
    }
    return 1;
}
This won't work, as your code checks if the vehicle is all three models at once.
You could use || instead of the &&.

For more than 2 options, it's better to use switch-case.
Your line could get very long using when you want to check for 10 model-id's for example and the compiler might complain (input line too long).

With switch, case, you only need to add an extra number and you're set.
Reply
#10

Tnx Distanc But Not Work And Power Pc TnX For This Its Work I Reped You <3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)