Car remove
#1

~~~~~~
Reply
#2

In what way does it not work? Be more specific...

Does it show an error message, does it not delete the car?
Reply
#3

This should fix it

Код:
CMD:deletecar(playerid, params[])
{
    new vehid, log[128], dvehid;
	dvehid = GetPlayerVehicleID(playerid);
    if(sscanf(params, "d", vehid))
    {
        if(Dead[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You Cannot Use This Command When You Are Dead.");
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You Must Be In A Vehicle To Use This Command.");
        if(AdminCar[dvehid] == 0) return SendClientMessage(playerid, COLOR_RED, "You Cannot Delete A Static Vehicle. You Can Only Use {FFFF00} /respawncar {FF0000}On It.");
        else if(NormalCar[dvehid] == 0) return SendClientMessage(playerid, COLOR_RED, "You Cannot Delete A Static Vehicle. You Can Only Use {FFFF00} /respawncar {FF0000}On It.");
        format(log, sizeof log, "Admin %s Has Deleted Vehicle ID %d. Model: %d.", PlayerName(playerid), dvehid, GetVehicleModel(dvehid));
        DestroyVehicle(dvehid);
        for(new a = 0; a < sizeof(AttachedObjects[dvehid]); a ++)
        if(AttachedObjects[dvehid][a] != 0)
        DestroyObject(AttachedObjects[dvehid][a]),
        AttachedObjects[dvehid][a] = 0;
        LogToFile("deletecar", log);
        return 1;
    }
    else if(!sscanf(params, "d", vehid))
    {
        if(!IsValidVehicle(vehid)) return SendClientMessage(playerid, COLOR_RED, "This Vehicle Doesn't Exist In The Server.");
        if(AdminCar[vehid] == 0) return SendClientMessage(playerid, COLOR_RED, "You Cannot Delete A Static Vehicle. You Can Only Use {FFFF00} /respawncar {FF0000}On It.");
        else if(NormalCar[vehid] == 0) return SendClientMessage(playerid, COLOR_RED, "You Cannot Delete A Static Vehicle. You Can Only Use {FFFF00} /respawncar {FF0000}On It.");
        format(log, sizeof log, "Admin %s Has Deleted Vehicle ID %d. Model: %d.", PlayerName(playerid), vehid, GetVehicleModel(vehid));
        DestroyVehicle(vehid);
        for(new a = 0; a < sizeof(AttachedObjects[]); a ++)
        if(AttachedObjects[vehid][a] != 0)
        DestroyObject(AttachedObjects[vehid][a]),
        AttachedObjects[vehid][a] = 0;
        LogToFile("deletecar", log);
        return 1;

    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
In what way does it not work? Be more specific...

Does it show an error message, does it not delete the car?
It say that i cant remove it is a static vehicle but it is not

@Ciandlah, that almost the same, you just use dvehid instead of GetPlayerVehicleID, that will work? i dont think so
Reply
#5

Sometimes placing a SAMP default code as a replacement wont work, you have to define it most of the time
Reply
#6

Wrong and wrong again.

You only really need to assign a function to a variable when you use that certain function multiple times. It saves a lot of data, so the function does have to keep getting called.

pawn Код:
CMD:deletecar(playerid, params[])
{
    //Add an admin check here??
    new vehid, log[128];
    if(sscanf(params, "d", vehid))
    {
        if(Dead[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You Cannot Use This Command When You Are Dead.");
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You Must Be In A Vehicle To Use This Command.");
        new veh = GetPlayerVehicleID(playerid);
        if(!AdminCar[veh]) return SendClientMessage(playerid, COLOR_RED, "You Cannot Delete A Static Vehicle. You Can Only Use {FFFF00} /respawncar {FF0000}On It.");
        if(!NormalCar[veh]) return SendClientMessage(playerid, COLOR_RED, "You Cannot Delete A Static Vehicle. You Can Only Use {FFFF00} /respawncar {FF0000}On It.");
        new log[128];
        format(log, sizeof(log), "Admin %s Has Deleted Vehicle ID %d. Model: %d.", PlayerName(playerid), veh, GetVehicleModel(veh));
        DestroyVehicle(veh);
        for(new a = 0; a < sizeof(AttachedObjects[]); a ++)
        if(AttachedObjects[veh][a] != 0) DestroyObject(AttachedObjects[veh][a]),
        AttachedObjects[veh][a] = 0;
        LogToFile("deletecar", log);
    }
    else if(!sscanf(params, "d", vehid))
    {
        if(!IsValidVehicle(vehid)) return SendClientMessage(playerid, COLOR_RED, "This Vehicle Doesn't Exist In The Server.");
        if(!AdminCar[vehid]) return SendClientMessage(playerid, COLOR_RED, "You Cannot Delete A Static Vehicle. You Can Only Use {FFFF00} /respawncar {FF0000}On It.");
        if(!NormalCar[vehid]) return SendClientMessage(playerid, COLOR_RED, "You Cannot Delete A Static Vehicle. You Can Only Use {FFFF00} /respawncar {FF0000}On It.");
        format(log, sizeof log, "Admin %s Has Deleted Vehicle ID %d. Model: %d.", PlayerName(playerid), vehid, GetVehicleModel(vehid));
        DestroyVehicle(vehid);
        for(new a = 0; a < sizeof(AttachedObjects[]); a ++)
        if(AttachedObjects[vehid][a] != 0) DestroyObject(AttachedObjects[vehid][a]),
        AttachedObjects[vehid][a] = 0;
        LogToFile("deletecar", log);
    }
    else return SendClientMessage(playerid, COLOR_RED, "USAGE: /deletecar [Optional: vehicle id]");
    return 1;
}
If that doesn't work, there is an error with the way you are setting AdminCar and NormalCar.
Reply
#7

~~~~~~~~
Reply
#8

Give this a shot:
pawn Код:
CMD:deletecar(playerid, params[])
{
    //Add an admin check here??
    new vehid, log[128];
    if(sscanf(params, "d", vehid))
    {
        if(Dead[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You Cannot Use This Command When You Are Dead.");
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You Must Be In A Vehicle To Use This Command.");
        new veh = GetPlayerVehicleID(playerid);
        if(!AdminCar[veh] && !NormalCar(veh)) return SendClientMessage(playerid, COLOR_RED, "You Cannot Delete A Static Vehicle. You Can Only Use {FFFF00} /respawncar {FF0000}On It.");
        new log[128];
        format(log, sizeof(log), "Admin %s Has Deleted Vehicle ID %d. Model: %d.", PlayerName(playerid), veh, GetVehicleModel(veh));
        DestroyVehicle(veh);
        for(new a = 0; a < sizeof(AttachedObjects[]); a ++)
        if(AttachedObjects[veh][a] != 0) DestroyObject(AttachedObjects[veh][a]),
        AttachedObjects[veh][a] = 0;
        LogToFile("deletecar", log);
    }
    else if(!sscanf(params, "d", vehid))
    {
        if(!IsValidVehicle(vehid)) return SendClientMessage(playerid, COLOR_RED, "This Vehicle Doesn't Exist In The Server.");
        if(!AdminCar[vehid] && !NormalCar[vehid]) return SendClientMessage(playerid, COLOR_RED, "You Cannot Delete A Static Vehicle. You Can Only Use {FFFF00} /respawncar {FF0000}On It.");
        format(log, sizeof log, "Admin %s Has Deleted Vehicle ID %d. Model: %d.", PlayerName(playerid), vehid, GetVehicleModel(vehid));
        DestroyVehicle(vehid);
        for(new a = 0; a < sizeof(AttachedObjects[]); a ++)
        if(AttachedObjects[vehid][a] != 0) DestroyObject(AttachedObjects[vehid][a]),
        AttachedObjects[vehid][a] = 0;
        LogToFile("deletecar", log);
    }
    else return SendClientMessage(playerid, COLOR_RED, "USAGE: /deletecar [Optional: vehicle id]");
    return 1;
}
Reply
#9

Ty mate +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)