Car Health[Problem]
#1

Help i made a thingy..but doesent work..if vehicle health is smaller than 300 and then car stops and after the stop i can start engine then engine stops then i statr it..i doesent work..

PHP код:
public CheckCarHealth()
                {
                new 
string[128];
                new 
sendername[MAX_PLAYER_NAME];
                for (new 
i=0MAX_PLAYERSi++)
                {
                if (
IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
                {
                new 
Float:health;
                
GetVehicleHealth(GetPlayerVehicleID(i),health);
                new 
newcar GetPlayerVehicleID(i);
    if (
health <= 300 && !IsModelABoat(newcar) && !IsModelABike(newcar) && !IsModelAPlane(newcar) && !IsASweeper(newcar))
                {
                 if(
engineOn[GetPlayerVehicleID(i)] == 1)
                 {
                    if(
GetPlayerState(i) == PLAYER_STATE_DRIVER)
                    {
                        
TogglePlayerControllable(i0);
                         
SendClientMessage(iCOLOR_GREY"Motorul sa stricat,poti suna mecanicul!");
                          
engineOn[GetPlayerVehicleID(i)] = false;
                           
GetPlayerName(isendernamesizeof(sendername));
                         
format(stringsizeof(string), "* Motorul sa stricat! (( %s ))"sendername);
                        
ProxDetector(30.0istringCOLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                    }
                 }
                }
                }
                }
                } 
Reply
#2

First of all, what's up with these functions:
pawn Код:
!IsModelABoat(newcar)
If I'm not wrong, you're trying to see if a given vehicle model is a boat, correct? Then why do you get the ID of the vehicle? ID has nothing to do with model. So, let me give you an example:
pawn Код:
new newcar = GetVehicleModel(GetPlayerVehicleID(i))

// Now, what this function will do? Will get the model of the vehicle driven by the "i".
And now you'll be able to check if the model is a boat, bike or whatever.
Reply
#3

Quote:
Originally Posted by antonio112
Посмотреть сообщение
First of all, what's up with these functions:
pawn Код:
!IsModelABoat(newcar)
If I'm not wrong, you're trying to see if a given vehicle model is a boat, correct? Then why do you get the ID of the vehicle? ID has nothing to do with model. So, let me give you an example:
pawn Код:
new newcar = GetVehicleModel(GetPlayerVehicleID(i))

// Now, what this function will do? Will get the model of the vehicle driven by the "i".
And now you'll be able to check if the model is a boat, bike or whatever.
IsModelABoat can be a custom callback, and if this is the case then it is not needed to define this again.
Reply
#4

so what do i do?
Reply
#5

i did look doesent work..

PHP код:
     public CheckCarHealth()
                {
                new 
string[128];
                new 
sendername[MAX_PLAYER_NAME];
                for (new 
i=0MAX_PLAYERSi++)
                {
                if (
IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
                {
                new 
Float:health;
                
GetVehicleHealth(GetPlayerVehicleID(i),health);
                new 
newcar GetPlayerVehicleID(i))
                if (
health <= 300))
                {
                 if(
engineOn[GetPlayerVehicleID(i)] == 1)
                 {
                    if(
GetPlayerState(i) == PLAYER_STATE_DRIVER)
                    {
                        
TogglePlayerControllable(i0);
                         
SendClientMessage(iCOLOR_GREY"Motorul sa stricat,poti suna mecanicul!");
                          
engineOn[GetPlayerVehicleID(i)] = false;
                           
GetPlayerName(isendernamesizeof(sendername));
                         
format(stringsizeof(string), "* Motorul sa stricat! (( %s ))"sendername);
                        
ProxDetector(30.0istringCOLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                    }
                 }
                }
                }
                }
                } 
Reply
#6

pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid) {
    new Float:v;
    GetVehicleHealth(vehicleid, v);
    if(v <= 300) {
        SendClientMessage(playerid, -1, "Motorul sa stricat,poti suna mecanicul!");
        SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_OFF, 0, 0, 0, VEHICLE_PARAMS_ON, 0, 0);
        SetVehicleHealth(vehicleid, 300);
    }
    return true;
}
Reply
#7

i put that and no work..the fire comes and gos boom..dont want that..it should stop engine.
Reply
#8

if i hit the car more this happens the message appears like 3 times do i need a timer?

PHP код:
        public OnVehicleDamageStatusUpdate(vehicleidplayerid)
                {
                new 
Float:v;
                
GetVehicleHealth(vehicleidv);
                if(
<= 300) { TogglePlayerControllable(playerid0); {
                
SendClientMessage(playerid, -1"Motorul sa stricat,poti suna mecanicul!");
                
SetVehicleParamsEx(vehicleidVEHICLE_PARAMS_OFF000VEHICLE_PARAMS_ON00);
                
SetVehicleHealth(vehicleid300);
                }
                }
                return 
1;
                } 
Reply
#9

pawn Код:
new bool:a[MAX_PLAYERS];

//
public OnVehicleDamageStatusUpdate(vehicleid, playerid) {
    new Float:v;
    GetVehicleHealth(vehicleid, v);
    if(v <= 300 && a[playerid] == false) {
        SendClientMessage(playerid, -1, "Motorul sa stricat,poti suna mecanicul!");
        SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_OFF, 0, 0, 0, VEHICLE_PARAMS_ON, 0, 0);
        SetVehicleHealth(vehicleid, 300);
        a[playerid] = true;
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)