Converting a string to an integer [I think]
#1

Well, I want to save a vehicles health when the player despawns it.
Here is my code, but it just sets the vehicle health to 0.

pawn Код:
CMD:despawn(playerid, params[])
{
    new string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    {
          new veh = PlayerInfo[playerid][pVeh]; //This is their personal vehicles, vehicle ID
          new Float:health;
          GetVehicleHealth(veh, health);
          if(vspawned[playerid] == 0) return SendClientMessage(playerid, COLOR_GREY, "You don't have a spawned car.");
          if(health == 400) return SendClientMessage(playerid, COLOR_RED, "This vehicle is too damaged.");
          PlayerInfo[playerid][pVehHealth] = 0; //This stores the vehicles health, so I set it to 0 here and below..
          PlayerInfo[playerid][pVehHealth] += health; //I added on the whatever the current vehicle health was..
          if(PlayerInfo[playerid][vModel] == 0) return SendClientMessage(playerid, COLOR_GREY, "You dont have vehicle in this slot.");
          {
              if(PlayerInfo[playerid][vModel])
              {
                   DestroyVehicle(PlayerInfo[playerid][pVeh]);
              }
          }
          v1spawned[playerid] = 0;
          vspawned[playerid] = 0;
          format(string, sizeof(string), "You have despawned your %s.", RVN(PlayerInfo[playerid][vModel]));
          SendClientMessage(playerid, COLOR_YELLOW, string);
    }
    return 1;
}
If I'm trying to save the vehicles health completely wrong, could you show me how I might do it correctly?
Reply


Messages In This Thread
Converting a string to an integer [I think] - by Ciarannn - 22.01.2015, 15:31
Re: Converting a string to an integer [I think] - by Schneider - 22.01.2015, 15:39
Re: Converting a string to an integer [I think] - by Ciarannn - 25.01.2015, 14:45
Re: Converting a string to an integer [I think] - by Ciarannn - 25.01.2015, 14:54
Re: Converting a string to an integer [I think] - by Sawalha - 25.01.2015, 14:54

Forum Jump:


Users browsing this thread: 3 Guest(s)