VehicleHealth HELPPP
#1

Hey, the Vehilce health show it only when u're in the car, when u outside u cant see it, u see the vehicle auto health... the normal... how to fix it?


Код:
public OnVehicleSpawn(vehicleid)
{
new newstate;
new playerid;
new oldstate;
        if(newstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
{
    new vehicle = GetPlayerVehicleID(playerid);
    new model = GetVehicleModel(vehicle);
    switch(model)
    {
        case 541: SetVehicleHealth(vehicle, 1500);
        case 596: SetVehicleHealth(vehicle, 2000);
        case 560: SetVehicleHealth(vehicle, 1500);
        case 402: SetVehicleHealth(vehicle, 1500);
        case 427: SetVehicleHealth(vehicle, 7500);
        case 528: SetVehicleHealth(vehicle, 5000);
        case 599: SetVehicleHealth(vehicle, 2000);
        case 601: SetVehicleHealth(vehicle, 4000);
        case 490: SetVehicleHealth(vehicle, 2500);
        case 433: SetVehicleHealth(vehicle, 4000);
        case 470: SetVehicleHealth(vehicle, 2500);
        case 432: SetVehicleHealth(vehicle, 10000);
        case 497: SetVehicleHealth(vehicle, 2500);
        case 487: SetVehicleHealth(vehicle, 1500);
    }
}
Reply
#2

pawn Код:
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_ONFOOT)
|| << Means OR

&& << Means and


Noob SKYPE ME
Reply
#3

pawn Код:
public OnVehicleSpawn(vehicleid)
{
    switch(GetVehicleModel(vehicleid))
    {
        case 402, 487, 541, 560: SetVehicleHealth(vehicleid, 1500);
        case 596, 599: SetVehicleHealth(vehicleid, 2000);
        case 470, 490, 497: SetVehicleHealth(vehicleid, 2500);
        case 433, 601: SetVehicleHealth(vehicleid, 4000);
        case 528: SetVehicleHealth(vehicleid, 5000);
        case 427: SetVehicleHealth(vehicleid, 7500);
        case 432: SetVehicleHealth(vehicleid, 10000);
       
    }
    return 1;
}
When a vehicle re-spawns, no players are in. You probably posted the wrong code and I don't understand what exactly you want.

Quote:
Originally Posted by Brandon_More
Посмотреть сообщение
pawn Код:
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_ONFOOT)
|| << Means OR

&& << Means and


Noob SKYPE ME
Did you also take a look at the rest of the code? newstate, playerid, oldstate will be 0. So whatever you do: either || or &&, none of them will work.
Reply
#4

Got alot of errors...
Reply
#5

Quote:
Originally Posted by yaron0600
Посмотреть сообщение
Got alot of errors...
The code I posted is fine, you probably have missing or extra bracket(s).
Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The code I posted is fine, you probably have missing or extra bracket(s).
You didn't do the coding correctly.
pawn Код:
public OnVehicleSpawn(vehicleid)
{
    switch(GetVehicleModel(vehicleid))
    {
        case 402, 487, 541, 560: { SetVehicleHealth(vehicleid, 1500); }
        case 596, 599: { SetVehicleHealth(vehicleid, 2000); }
        case 470, 490, 497: { SetVehicleHealth(vehicleid, 2500); }
        case 433, 601: { SetVehicleHealth(vehicleid, 4000); }
        case 528: { SetVehicleHealth(vehicleid, 5000); }
        case 427: { SetVehicleHealth(vehicleid, 7500); }
        case 432: { SetVehicleHealth(vehicleid, 10000); }
       
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by dannyk0ed
Посмотреть сообщение
You didn't do the coding correctly.
The code is fine, try compiling it yourself and see.

It's not necessary to use block of code { } for 1 statement/function or few of them which are separated with comma. However if you use a semicolon and more than 1 statement/function, then it must be inside { }.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)