Fuel problem
#1

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;
}
Reply
#2

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

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?
Reply
#4

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?
Reply
#5

never mind i fexed the problem and... Thanks Kwarde
Reply
#6

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...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)