SetVehicleHealth Command Please Help
#1

Why is this not working atall


pawn Код:
CMD:setvehiclehealth(playerid, params[])
{
    if(PlayerData[ID][AdminLevel] >= 1)
    {
        new VehicleHealth;
        new vehicleid = GetPlayerVehicleID(playerid);
        if(sscanf(params, "ui", VehicleHealth)) return SendClientMessage(playerid, COLOR_GREEN, "/setvehiclehealth [Health]");
        GetPlayerName(playerid,pname,sizeof(pname));
        new pstring[256];
        format(pstring,sizeof(pstring),"You have set your vehicle health to %s",VehicleHealth);
        SetVehicleHealth(vehicleid,VehicleHealth);
    }
    return 1;
}

Thank You


Please Help Me Please
Reply
#2

Try this:
pawn Код:
CMD:setvehiclehealth(playerid, params[])
{
    if(PlayerData[ID][AdminLevel] >= 1)
    {
        new VehicleHealth;
        new vehicleid = GetPlayerVehicleID(playerid);
        if(sscanf(params, "f", VehicleHealth)) return SendClientMessage(playerid, COLOR_GREEN, "/setvehiclehealth [Health]");
        GetPlayerName(playerid,pname,sizeof(pname));
        new pstring[128];
        format(pstring,sizeof(pstring),"You have set your vehicle health to %f",VehicleHealth);
        SetVehicleHealth(vehicleid,VehicleHealth);
    }
    return 1;
}
Best regards!
Reply
#3

You are assigning an integer to a float.
You have two options to fix this.
Replacing
pawn Код:
new VehicleHealth;
with
pawn Код:
new Float:VehicleHealth;
Or replacing
pawn Код:
SetVehicleHealth(vehicleid,VehicleHealth);
with
pawn Код:
SetVehicleHealth(vehicleid,float(VehicleHealth));
EDIT: Or what the guy above me said
Reply
#4

pawn Код:
if(sscanf(params, "ui", VehicleHealth)) return SendClientMessage(playerid, COLOR_GREEN, "/setvehiclehealth [Health]");
This should be ^:

pawn Код:
if(sscanf(params, "f", VehicleHealth)) return SendClientMessage(playerid, COLOR_GREEN, "/setvehiclehealth [Health]");
The vehiclehealth gotta be a float, so why should you use "ui"? (integers)? The 'f' - specifier is for a float, that's also what the guys above me told you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)