need help with OnVehicleDeath
#1

Alright I am have Issues with On Vehicle Death were if the car is a dealership car from my filter script the car won't respawn in the last place it was parked it won't appear anywere

also I have a command /vget that teleports a vehicle to me and when I use it the vehicle catches on fire. It started happening when I added this code.


my code
pawn Код:
public OnVehicleDeath(vehicleid, killerid)
{
    SetTimer("OnVehicleDeathDelay",15000,false);//this is for a delay so The car does not disappear right away
    return 1;
}
//jbcarid is a id of a car that is purchase able of for sale
public OnVehicleDeathDelay(vehicleid)
{
    if((carstate[jbcarid[vehicleid]])==1)//This checks if the car exist
    {
        if((cartype[jbcarid[vehicleid]])==2)//this checks if it is a dealership car[2] or an owned car[1]
        {
            new string[256];
            new carid = jbcarid[vehicleid];
            jbcarid[vehicleid] = 0;
            DestroyVehicle(vehicleid);
            Delete3DTextLabel(carlabel[carid]);
            format(string,sizeof(string),"%sDealership vehicle\nThis vehicle cost $%i",cardealershipid[carid],carcost[carid]);
            carlabel[carid] = Create3DTextLabel(string,YELLOW,carx[carid],cary[carid],carz[carid],DISTANCELABEL,0,0);
            car[carid] = CreateVehicle(carmodelid[carid],carx[carid],cary[carid],carz[carid],carrot[carid],carcolor1[carid],carcolor2[carid],-1);
            jbcarid[car[carid]] = carid;
            Attach3DTextLabelToVehicle(carlabel[carid],car[carid],0,0,0);
            fuel[car[carid]] = carfuel[carid];
            SaveCarData(carid);
        }//have not yet made is for owning vehicles
    }
    else//if the car is a regular and not owned
    {
        DestroyVehicle(vehicleid);
        fuel[vehicleid] = 100.0;
    }
    return 1;
}
Reply
#2

Quote:
Originally Posted by horsemeat
Посмотреть сообщение
Alright I am have Issues with On Vehicle Death were if the car is a dealership car from my filter script the car won't respawn in the last place it was parked it won't appear anywere
to make the vehicle spawn at another point of the map,
you have to destroy it and create it, with that new coordinates.

here's an example from my own mysqlbased vehicle system's park cmd
pawn Код:
YCMD:vpark(playerid, params[], help)
{
    if(help) return SendClientMessage(playerid,gray,"/vpark Is used to Park your Vehicle.");
    if(!VehicleInfo[playerid][vModel]) return SendClientMessage(playerid,red,"You don't even own a Vehicle!");
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You have to be inside a Vehicle!");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,red,"You have to be the Driver!");
    if(GetPlayerVehicleID(playerid) != VehicleInfo[playerid][vID]) return SendClientMessage(playerid,red,"This ain't your Vehicle!");
    new Float:p[3];
    GetVehicleVelocity(GetPlayerVehicleID(playerid),p[0],p[1],p[2]);
    if(floatadd(p[0],p[1])) return SendClientMessage(playerid,red,"You have to Stop the Vehicle to do that.");//stops ppls from parking their cars in the air
    GetVehiclePos(GetPlayerVehicleID(playerid),VehicleInfo[playerid][vSpawn][0],VehicleInfo[playerid][vSpawn][1],VehicleInfo[playerid][vSpawn][2]);
    GetVehicleZAngle(GetPlayerVehicleID(playerid),VehicleInfo[playerid][vSpawn][3]);
    DestroyVehicle(VehicleInfo[playerid][vID]);
    VehicleInfo[playerid][vID] = CreateVehicle(VehicleInfo[playerid][vModel],
                                               VehicleInfo[playerid][vSpawn][0],
                                               VehicleInfo[playerid][vSpawn][1],
                                               VehicleInfo[playerid][vSpawn][2],
                                               VehicleInfo[playerid][vSpawn][3],
                                               VehicleInfo[playerid][vColor][0],
                                               VehicleInfo[playerid][vColor][1],600);
    LoadVehicleTuning(VehicleInfo[playerid][vID]);//loads the vehicle components of a car if it had some.
    SendClientMessage(playerid,orange,"[INFO]"white" Spawnpoint-Set! Your Vehicle will Spawn here from now on.");
    return 1;
}
Reply
#3

never mind I think I fixed it
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)