Car health
#1

Hey guys, i got a little warning, and cant find out what im doing wrong.

pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
    {
    new vehicleid = GetPlayerVehicleID(playerid);
    new chealth = GetVehicleHealth(vehicleid, chealth); //<-- line 845
    if(chealth < 350)
    {
    SetVehicleParamsEx(vehicleid, false, true, true, true, false, false, false);
    TogglePlayerControllable(playerid,0);
    SendClientMessage(playerid, orange, "Your engine died. Please call a repairsman to repair it");
    return 1;
    } else if (chealth >350) {
    SetVehicleParamsEx(vehicleid, true, false, false, false, false, false, false);
    TogglePlayerControllable(playerid, 1);
    }
    return 1;
    }
Код:
C:\Users\wesley.PC_van_Kelsey\Desktop\RolePlay\gamemodes\RolePlay.pwn(845) : warning 213: tag mismatch
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
Hope you guys can help
~Wesley
Reply
#2

EDIT: i was wrong, you forgot to put Float: before the chealth. my bad!
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
    {
    new vehicleid = GetPlayerVehicleID(playerid);
    new Float:chealth;
    GetVehicleHealth(vehicleid, chealth); //<-- line 845
    if(chealth < 350)
    {
    SetVehicleParamsEx(vehicleid, false, true, true, true, false, false, false);
    TogglePlayerControllable(playerid,0);
    SendClientMessage(playerid, orange, "Your engine died. Please call a repairsman to repair it");
    return 1;
    } else if (chealth >350) {
    SetVehicleParamsEx(vehicleid, true, false, false, false, false, false, false);
    TogglePlayerControllable(playerid, 1);
    }
    return 1;
    }
Reply
#3

Hmm somehow when the cars health is below 350, it wont shut down the engine

Anyone know what to do?

pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
    {
    new vehicleid = GetPlayerVehicleID(playerid);
    new Float:chealth;
    GetVehicleHealth(vehicleid, chealth);
    if(GetVehicleHealth(vehicleid, chealth) < 350)
    {
    SetVehicleParamsEx(vehicleid, false, true, true, true, false, false, false);
    TogglePlayerControllable(playerid,0);
    SendClientMessage(playerid, orange, "Your engine died. Please call a repairsman to repair it");
    return 1;
    } else if (GetVehicleHealth(vehicleid, chealth) >350) {
    SetVehicleParamsEx(vehicleid, true, false, false, false, false, false, false);
    TogglePlayerControllable(playerid, 1);
    }
    return 1;
    }
Reply
#4

GetVehicleHealth does not return a value (well, I think it returns 1/0 on success/failure, but I'm not sure). You already stored the health in the variable chealth, so use that to check.

if(chealth < 350.0)
Reply
#5

Okie, changed it now;
When the car health is below 350 & u leave the car & after that get in, it freezes
How to make it if it gets below 350, it shuts the engine down inmediantly?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)