engine broke doesnt work
#1

Hello Guys,
Ive got the following Problem.
Ive made an script that asks if the Vehicle health is <= 300, it should turn the engine off.
But it doesnt seems to ork... ive got no Errors but nothing happend in game, whats from with it?
Hopefully someone can answear my question cuz am doing an Banger Racing script if anyone know what Bnager Racing is and maybe intrested in it, PM me.
Cheers Lads

on onFilterScriptinit ive got this
SetTimer("EngineBroke",200,1);

then

forward EngineBroke(playerid, vehicleid);

public EngineBroke(playerid, vehicleid)
{
if(IsPlayerInAnyVehicle(playerid))
{
new Float:vhealth;
new veh;
veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, vhealth);
if(vhealth <= 300)
{
ToggleEngine(vehicleid, VEHICLE_PARAMS_OFF);
return 1;
}
return 1;
}
return 1;
}

yes, ToggleEngine is defined and works without Problems...
Reply
#2

I really do not know anything about that toggleengine function , but I'm sure its much easier to do with these

pawn Код:
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);
Reply
#3

Show your macro/define/function for ToggleEngine (if it still doesn't works)

pawn Код:
forward EngineBroke(playerid);

public EngineBroke(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new Float:vhealth;
        new veh;
        veh = GetPlayerVehicleID(playerid);
        GetVehicleHealth(veh, vhealth);
        if(vhealth < 300.0)
        {
            ToggleEngine(veh, VEHICLE_PARAMS_OFF);
        }
    }
    return 1;
}
Reply
#4

And If He already defined this

pawn Код:
new veh;
veh = GetPlayerVehicleID(playerid);
Why doesn't he use than this instead

pawn Код:
ToggleEngine(veh, VEHICLE_PARAMS_OFF);
Reply
#5

Quote:
Originally Posted by luis_mendoza
Посмотреть сообщение
And If He already defined this

pawn Код:
new veh;
veh = GetPlayerVehicleID(playerid);
Why doesn't he use than this instead

pawn Код:
ToggleEngine(veh, VEHICLE_PARAMS_OFF);
Yeah I noticed before your post, and I edited above.
Reply
#6

The problem is, the timer is not sending playerid and vehicleid params.
I suggest you doing same
SetTimer("EngineBroke",200,1);
but, changing
Код:
public EngineBroke()
{
for(new i = 0; i<MAX_PLAYERS;i++){
if(IsPlayerConnected(i)){
if(GetPlayerState(i) == PLAYER_STATE_DRIVER) {
new Float:vhealth;
        new veh;
        veh = GetPlayerVehicleID(i);
        GetVehicleHealth(veh, vhealth);
        if(vhealth < 300.0)
        {
            ToggleEngine(veh, VEHICLE_PARAMS_OFF);
        }
}
}
}
}
*Code might be faulty because written in forums without compiler*
Reply
#7

@[WSF]ThA_Devil

Thank you alot, it does work now
+ sry but am new to PAWNO Scripting, just know the Basics etc
btw

/CLOSE Cheers
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)