SA-MP Forums Archive
Should return a value - 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: Should return a value (/showthread.php?tid=506031)



Should return a value - Dziugsas - 11.04.2014

Hello Guys!

I'm having some problem :/

pawn Код:
CMD:pylti(playerid, params[])
{
    for(new i=1; i < MAX_FUEL_STATIONS; i++)
    {
        if(FuelStationCreated[i])
        {
            new vehicleid = GetPlayerVehicleID(playerid);
            if(!ToggleEngine(vehicleid, VEHICLE_PARAMS_OFF)) return SendClientMessage(playerid, COLOR_RED, "Isjunkite varikli pries pildami kura!"); // Error line <<<<,
            if(IsPlayerInRangeOfPoint(playerid, 15.0, FuelStationPos[i][0], FuelStationPos[i][1], FuelStationPos[i][2]))
            {
                SetPVarInt(playerid, "FuelStation", i);
                ShowDialog(playerid, DIALOG_FUEL);
                return 1;
            }
        }
    }
    SendClientMessage(playerid, COLOR_RED, "You are not in a fuel station!");
    return 1;
}
Error

pawn Код:
(1617) : warning 209: function "ToggleEngine" should return a value



Re: Should return a value - Konstantinos - 11.04.2014

Post ToggleEngine funcion. It doesn't return anything when it should.


Re: Should return a value - Dziugsas - 11.04.2014

pawn Код:
stock ToggleEngine(vehicleid, toggle)
{
    new engine, lights, alarm, doors, bonnet, boot, objective;
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    SetVehicleParamsEx(vehicleid, toggle, lights, alarm, doors, bonnet, boot, objective);
}



Re: Should return a value - BroZeus - 11.04.2014

usee this
pawn Код:
stock ToggleEngine(vehicleid, toggle)
{
    new engine, lights, alarm, doors, bonnet, boot, objective;
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    SetVehicleParamsEx(vehicleid, toggle, lights, alarm, doors, bonnet, boot, objective);
    return 1;
}



Re: Should return a value - Dziugsas - 11.04.2014

Yeah i thought that to , but this error only shows when i add this
pawn Код:
if(!ToggleEngine(vehicleid, VEHICLE_PARAMS_OFF)) return SendClientMessage(playerid, COLOR_RED, "Isjunkite varikli pries pildami kura!"); // Error line <<<<



Re: Should return a value - Konstantinos - 11.04.2014

Actually the function meant to be used as a function for only toggling the engine. You check if it returns false and you return an error (which I don't know what it means).

You can return the toggle but in my opinion is pointless.


Re: Should return a value - Dziugsas - 11.04.2014

I just want to make when player is refueling vehicle to toggle it off , and when finished toggle it on , or just send message to turn off engine.


Re: Should return a value - Conradus - 11.04.2014

Change your CMD to this:
Код:
CMD:pylti(playerid, params[])
{
    for(new i=1; i < MAX_FUEL_STATIONS; i++)
    {
        if(FuelStationCreated[i])
        {
            new vehicleid = GetPlayerVehicleID(playerid);
            if(IsEngineRunning(vehicleid) == 1) return SendClientMessage(playerid, COLOR_RED, "Isjunkite varikli pries pildami kura!");
            if(IsPlayerInRangeOfPoint(playerid, 15.0, FuelStationPos[i][0], FuelStationPos[i][1], FuelStationPos[i][2]))
            {
                SetPVarInt(playerid, "FuelStation", i);
                ShowDialog(playerid, DIALOG_FUEL);
                return 1;
            }
        }
    }
    SendClientMessage(playerid, COLOR_RED, "You are not in a fuel station!");
    return 1;
}
Replace your ToggleEngine function with this:
Код:
stock IsEngineRunning(vehicleid)
{
    new engine, lights, alarm, doors, bonnet, boot, objective;
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    return engine;
}