else if(strcmp(params, "engine", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { new vehicle = GetPlayerVehicleID(playerid); new string[126]; new engine, lights, alarm, doors, bonnet, boot, objective; GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective); if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { if(Engine[vehicle] == 0) { Engine[vehicle] = 1; SetVehicleParamsEx(vehicle,1,lights,alarm,doors,bonnet,boot,objective); format(string, sizeof(string), "* %s turns the engine of their vehicle engine on.", GetPlayerNameEx(playerid)); ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); return 1; } else { Engine[vehicle] = 0; SetVehicleParamsEx(vehicle,0,lights,alarm,doors,bonnet,boot,objective); format(string, sizeof(string), "* %s turns the vehicles engine off.", GetPlayerNameEx(playerid)); ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); return 1; } } return engine; }
GetVehicleParamsEx and SetVehicleParamsEx.
You have also to know about conditions. I'll be glad to help you in your questions |
new engine, lights, alarm, doors, bonnet, boot, objective; GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective); // ONLY the engine param was changed (to 1)
Just a side note: OnVehicleSpawn is called when a vehicle re-spawns not when it's created.
|
https://sampforum.blast.hk/showthread.php?tid=441293
Hook the functions that create/add vehicles and set the engine to 0. |
stock HF_CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay)
{
new vehicleid = CreateVehicle(modelid, x, y, z, angle, color1, color2, respawn_delay);
if (vehicleid != INVALID_VEHICLE_ID) // not invalid modelid or full
{
Engine[vehicleid] = 0;
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
}
return 1;
}
#if defined _ALS_CreateVehicle
#undef CreateVehicle
#else
#define _ALS_CreateVehicle
#endif
#define CreateVehicle HF_CreateVehicle
pawn Код:
Do the same for AddStaticVehicle and AddStaticVehicleEx functions. |
stock HF_CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay)
{
new vehicleid = CreateVehicle(modelid, x, y, z, angle, color1, color2, respawn_delay);
if (vehicleid != INVALID_VEHICLE_ID) // not invalid modelid or full
{
Engine[vehicleid] = 0;
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
return vehicleid;
}
return INVALID_VEHICLE_ID;
}