SA-MP Forums Archive
Fuel problem - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Fuel problem (/showthread.php?tid=241368)



Fuel problem - Unknown123 - 17.03.2011

This tells me "You is not on amy gas startion" when i am ON the gas station
pawn Код:
dcmd_refill(playerid, params[])
{
    #pragma unused params
    if(!IsPlayerOnGasStation(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "You is not on amy gas startion");
    {
        RefillingTimer[playerid] = SetTimerEx("ReFuelTimer", 1000, true, "u", playerid);
        return 1;
    }
}
This tells me "You left the gas startion" when i am ON the gas station (Mayb other bugs there too?)
pawn Код:
public ReFuelTimer()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        new vehicleid = GetPlayerVehicleID(i);
        if(GetPlayerVehicleSeat(i) == 0)
        {
            if(IsPlayerOnGasStation(i))
            {
                if(Fuel[vehicleid] > 0)
                {
                    new lights, alarm, doors, bonnet, boot, objective;
                    SetVehicleParamsEx(vehicleid, true, lights, alarm, doors, bonnet, boot, objective);
                }
                else
                {
                    if(Fuel[vehicleid] == 100)
                    {
                        KillTimer(RefillingTimer[i]);
                        GameTextForPlayer(i,"~r~Tank Refilled", 5000, 4);
                        return 1;
                    }
                    else
                    {
                        Fuel[vehicleid] ++;
                        return 1;
                    }
                }
            }
            else
            {
                SendClientMessage(i, 0xFF0000FF, "You left the gas startion");
                KillTimer(RefillingTimer[i]);
                return 1;
            }
        }
    }
    return 1;
}
I think there is something wrong here then =/
pawn Код:
stock IsPlayerOnGasStation(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, 10, 2115.5422, 919.5186, 10.8203)) return 0; //Gas Station 1
    return 1;
}



Re: Fuel problem - Kwarde - 17.03.2011

Switch the 'return 1;' and 'return 0;' in that last function.


Re: Fuel problem - Unknown123 - 17.03.2011

Thanks and on the "ReFuelTimer()".. its a bug there =/

if i remove:
pawn Код:
if(IsPlayerOnGasStation(i))
            {
and
pawn Код:
else
            {
                SendClientMessage(i, 0xFF0000FF, "You left the gas startion");
                KillTimer(RefillingTimer[i]);
                return 1;
            }
then it works, but how am i supposed to kill the refuelling if he leave the gas station?


Re: Fuel problem - Marricio - 17.03.2011

pawn Код:
public IsPlayerOnGasStation(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, 10, 2115.5422, 919.5186, 10.8203)) return 1; // IS AT GAS STATION -- Gas Station 1
    return 0; // is NOT at gas station
}
Why using stock?


Re: Fuel problem - Unknown123 - 17.03.2011

never mind i fexed the problem and... Thanks Kwarde


Re: Fuel problem - Kwarde - 18.03.2011

Quote:
Originally Posted by Marricio
Посмотреть сообщение
pawn Код:
public IsPlayerOnGasStation(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, 10, 2115.5422, 919.5186, 10.8203)) return 1; // IS AT GAS STATION -- Gas Station 1
    return 0; // is NOT at gas station
}
Why using stock?

That is now an callback. You can see two words in it: "Call" and "Back". Call Back.
They are needed to call something after a happening, eg. when someone connect, you can 'call' that playerid: public OnPlayerConnect(playerid).
And the "IsPlayerOnGasStation": Do you need to call it when someone enters the gas station? With that script above, you can't. Just use stock. And you failed because you didn't put the forward on it. Don't use public for nothing...