SA-MP Forums Archive
SetVehicleHealth Command Please Help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: SetVehicleHealth Command Please Help (/showthread.php?tid=337029)



SetVehicleHealth Command Please Help - Scripter12345 - 24.04.2012

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


Respuesta: SetVehicleHealth Command Please Help - [DOG]irinel1996 - 24.04.2012

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!


Re: SetVehicleHealth Command Please Help - Claude - 24.04.2012

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


Re: SetVehicleHealth Command Please Help - Twisted_Insane - 24.04.2012

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.