#1

Hey Guys,

I have this code:
pawn Код:
public CheckCarHealth()
{
    new string[256];
    new sendername[MAX_PLAYER_NAME];
    for (new i=0; i < PLAYERS; i++)
    {
        if (IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
        {
             new Float:health;
             GetVehicleHealth(GetPlayerVehicleID(i),health);
             new vehicle = GetPlayerVehicleID(i);
             if(health < 50)
             {
                        TogglePlayerControllable(i, 0);
                        SendClientMessage(i, COLOR_LIGHT_BLUE, "Your vehicle is broken, start the engine up or call a mechanic! (/exit to leave a car)");
                        engineOn[vehicle] = 0;
                        GetPlayerName(i, sendername, sizeof(sendername));
                        format(string, sizeof(string), "* Vehicle engine brakes down (( %s ))", sendername);
                        ProxDetector(30.0, i, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    }
                    if(health > 50)
                    {
                        engineOn[vehicle] = 1;
                        TogglePlayerControllable(i, 1);
                    }
             }
         }
       }
The first script suppost to turn off the engine,freeze the player,and tell everyone around that the engine is broken when the car have under 50HP .
The second script should release the player from freeze and let him turn the engine on when the car have over 50HP.

The problem is that it does'nt work,I don't get any errors..

A little help will be nice
Reply
#2

Vehicle max health is 1000. Use 500 instead of 50.
Reply
#3

I assume from public that this is run in timer? You can change "if(health > 50)" to else, because currently you have one uncovered case, when health is exactly 50. Try to drop some debug messages to see where the code stops executing
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)