Fuel system errors
#1

Screw it, no one gave me tuts, or help, just gave up on this.
Reply
#2

Ok, I edited the script slightly, I just deleted a bracket, and now I have 1 error

pawn Код:
/*
*
*  Fuel System by RyDeR - EDITED BY AYSER BANKS ( AKA LMFAOOWN )
*  DracoBlue for DCMD
*  Someone for the Gas Station Coцrdinates
*
*/

#include <a_samp>

#define dcmd(%1,%2,%3)          if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 // Credits go to DracoBlue

#define COLOR_GREY              0xAFAFAFAA
#define COLOR_GREEN             0x33FF33AA
#define COLOR_YELLOW            0xFFFF00AA
#define COLOR_WHITE             0xFFFFFFAA
#define COLOR_BRIGHTRED         0xE60000FF
#define COLOR_BLUE              0x0000FFAA
#define COLOR_PURPLE            0x9900FFAA
#define COLOR_BROWN             0x993300AA
#define COLOR_ORANGE            0xFF9933AA
#define COLOR_CYAN              0x99FFFFAA
#define COLOR_TAN               0xFFFFCCAA
#define COLOR_PINK              0xFF66FFAA
#define COLOR_KHAKI             0x999900AA
#define COLOR_LIME              0x99FF00AA
#define COLOR_BLACK             0x000000AA
#define COLOR_TURQ              0x00A3C0AA
#define COLOR_LIGHTBLUE         0x33CCFFAA
#define COLOR_DARKRED           0xAA993333
#define COLOR_VIOLET            0x9955DEEE
#define COLOR_RED               0xFB0000FF

#define DIVBY          1.300

new refilltimes[MAX_PLAYERS];
new refillcount[MAX_PLAYERS];
new refilltimer[MAX_PLAYERS];

new
    Benzin[MAX_VEHICLES],
    bool:PortableFuel[MAX_PLAYERS],
    FuelTimer;

new
    Text: Fuel[MAX_PLAYERS],
    Text: BlackBox,
    Text: Moving[MAX_PLAYERS];


public OnFilterScriptInit()
{
    FuelTimer = SetTimer("SubFuel", 12000, true);
    SetTimerEx("refillcar",1000,1,"d",playerid);
    print("----------------------------------");
    print(" Fuel System by RyDeR - EDITED BY AYSER BANKS ( AKA LMFAOOWN ) - Loaded - ");
    print("----------------------------------");

    BlackBox = TextDrawCreate(354.000000, 422.000000, "_");
    TextDrawBackgroundColor(BlackBox, 255);
    TextDrawFont(BlackBox, 1);
    TextDrawLetterSize(BlackBox, 0.509999, 1.000000);
    TextDrawColor(BlackBox, -1);
    TextDrawSetOutline(BlackBox, 0);
    TextDrawSetProportional(BlackBox, 1);
    TextDrawSetShadow(BlackBox, 1);
    TextDrawUseBox(BlackBox, 1);
    TextDrawBoxColor(BlackBox, 0xFF80001A);
    TextDrawTextSize(BlackBox, 277.000000, 51.000000);

    new
      i;

    while (i != GetMaxPlayers())
    {
        Fuel[i] = TextDrawCreate(258.000000, 421.000000, " ");
        TextDrawBackgroundColor(Fuel[i], 255);
        TextDrawFont(Fuel[i], 1);
        TextDrawLetterSize(Fuel[i], 0.250000, 1.100000);
        TextDrawColor(Fuel[i], -1);
        TextDrawSetOutline(Fuel[i], 0);
        TextDrawSetProportional(Fuel[i], 1);
        TextDrawSetShadow(Fuel[i], 1);

        Moving[i] = TextDrawCreate(354.000000, 422.000000, "_");
        TextDrawBackgroundColor(Moving[i], 255);
        TextDrawFont(Moving[i], 1);
        TextDrawLetterSize(Moving[i], 0.509999, 1.000000);
        TextDrawColor(Moving[i], -1);
        TextDrawSetOutline(Moving[i], 0);
        TextDrawSetProportional(Moving[i], 1);
        TextDrawSetShadow(Moving[i], 1);
        TextDrawUseBox(Moving[i], 1);
        TextDrawBoxColor(Moving[i], 0xFF8000C1);
        TextDrawTextSize(Moving[i], 277.000000, 51.000000);
        ++i;
    }

    new
        v;

    while (v != MAX_VEHICLES)
    {
      Benzin[v] = random(100);
        ++v;
    }
    return 1;
}

public OnFilterScriptExit()
{
    new
        i,
        v;

    while (i != GetMaxPlayers())
    {
        TextDrawDestroy(Fuel[i]);
        TextDrawDestroy(Moving[i]);
        ++i;
    }
    TextDrawDestroy(BlackBox);
    KillTimer(FuelTimer);

    while (v != MAX_VEHICLES)
    {
      Benzin[v] = 100;
        ++v;
    }
    return 1;
}

forward SubFuel();
public SubFuel()
{
    new
      i;

    while (i != GetMaxPlayers())
    {
      if (IsPlayerInAnyVehicle(i))
      {
          new string[128];
        if(Benzin[GetPlayerVehicleID(i)] <0) Benzin[GetPlayerVehicleID(i)] = 0;
          if(IsPlayerInAnyVehicle(i))
          {
            Benzin[GetPlayerVehicleID(i)]-=1;
            format(string, 128, "Fuel:    %%%d", Benzin[GetPlayerVehicleID(i)]);
            TextDrawSetString(Fuel[i], string), TextDrawShowForPlayer(i, Fuel[i]),
                    TextDrawShowForPlayer(i, BlackBox),
                        TextDrawTextSize(Moving[i], (354.0 - (Benzin[GetPlayerVehicleID(i)] / DIVBY)), 0.000000),
                            TextDrawShowForPlayer(i, Moving[i]);
          }
          if (Benzin[GetPlayerVehicleID(i)] < 1)
            {
                Benzin[GetPlayerVehicleID(i)] = 0;
            GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~n~~w~You don't have fuel in your vehicle.", 4000, 3);
            TogglePlayerControllable(i, false);
            RemovePlayerFromVehicle(i);
            }
        }
        else
        {
          TextDrawHideForPlayer(i, Fuel[i]),
                TextDrawHideForPlayer(i, BlackBox),
                    TextDrawHideForPlayer(i, Moving[i]);
          GameTextForPlayer(i, " ", 100, 3);
          TogglePlayerControllable(i, true);
        }
        ++i;
    }
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    Benzin[vehicleid] = random(100);
}

public OnPlayerConnect(playerid)
{
    PortableFuel[playerid] = false;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    TextDrawHideForPlayer(playerid, Fuel[playerid]);
    TextDrawHideForPlayer(playerid, Moving[playerid]);
    TextDrawHideForPlayer(playerid, BlackBox);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    TextDrawHideForPlayer(playerid, Fuel[playerid]);
    TextDrawHideForPlayer(playerid, Moving[playerid]);
    TextDrawHideForPlayer(playerid, BlackBox);
    return 1;
}

forward refillcar(playerid);
public refillcar(playerid)
{
Fuel[playerid]++;
}

dcmd_refill (playerid, params[])
{   // Declaring errors that they made in the command
    if(refillcount[playerid] == refilltimes[playerid]) killtimer(refilltimer[playerid]);
    refillcount[playerid]++;   
    /* not in a car to fill up */ if (!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, ">> You are not in any vehicle to refill!");
    /*not at gasstation */if (!IsAtGasStation(playerid)) return SendClientMessage(playerid, COLOR_RED, ">> You are not in a gas station!");
    // if (!strlen(params)) return SendClientMessage(playerid, COLOR_RED, ">> /fill [amount in 0 - 100 l]");
    miktar = strval(params);
    // if (miktar < 1 || miktar > 100) return SendClientMessage(playerid, COLOR_RED, ">> Wrong amount in liters! (0-100l)");
    /* car already has 100 fuel */ if (Benzin[GetPlayerVehicleID(playerid)] >= 100) return SendClientMessage(playerid, COLOR_RED, ">> You can't refill. Your car is full!");
    Fiyat = (miktar * 2);
    /* not enough money */ format(string2, 128, ">> You don't have money enough! You need $%d.", Fiyat);
    if (GetPlayerMoney(playerid) < Fiyat) return SendClientMessage(playerid, COLOR_RED, string2);
    GivePlayerMoney(playerid, -Fiyat);
    format(string, 128, ">> You have filled your vehicle for %d liters. Cost: $%d.", miktar, Fiyat);
if (Benzin[GetPlayerVehicleID(playerid)] > 100) Sum = miktar*2-Benzin[GetPlayerVehicleID(playerid)]+100, GivePlayerMoney(playerid, Sum), format(string4, 128, ">> You have choose a too large amount of liters that your car can't accept. Here's your change($%d).", Sum), SendClientMessage(playerid, COLOR_ORANGE, string4), Benzin[GetPlayerVehicleID(playerid)] = 100;
    format(string3, 128, "Fuel:    %%%d", Benzin[GetPlayerVehicleID(playerid)]);
    TextDrawSetString(Fuel[playerid], string3),
        TextDrawShowForPlayer(playerid, Fuel[playerid]),
            TextDrawTextSize(Moving[playerid], (354.0 - (Benzin[GetPlayerVehicleID(playerid)] / DIVBY)), 0.000000),
                TextDrawShowForPlayer(playerid, Moving[playerid]);
    return 1;
    CreateMenu("Gas Station", 0, 20, 120, 150, 400);
    AddMenuItem(zone, 0, "10-Liters");
    AddMenuItem(zone, 0, "20-Liters");
    AddMenuItem(zone, 0, "30-Liters");
    AddMenuItem(zone, 0, "40-Liters");
    AddMenuItem(zone, 0, "50-Liters");
    AddMenuItem(zone, 0, "60-Liters");
    AddMenuItem(zone, 0, "70-Liters");
    AddMenuItem(zone, 0, "80-Liters");
    AddMenuItem(zone, 0, "90-Liters");
    AddMenuItem(zone, 0, "100-Liters");

    case 0: // 10-Liters
    {
    return 1;
    }

    case 1: // 20-Liters
    {
    return 1;
    }

    case 2: // 30-Liters
    {
    return 1;
    }

    case 3: // 40-Liters
    {
    return 1;
    }
    case 4: // 50-Liters
    {
    return 1;
    }

    case 5: // 60-Liters
    {
    return 1;
    }

    case 6: // 70-Liters
    {
    return 1;
    }

    case 7: // 80-Liters
    {
    return 1;
    }

    case 8: // 00-Liters
    {
    return 1;
    }

    case 9: // 100-Liters
    {
    if (Benzin[GetPlayerVehicleID(playerid)] >= 100) return SendClientMessage(playerid, COLOR_RED, ">> You can't refill. Your car is full!");
    if (miktar < 1 || miktar > 100) return SendClientMessage(playerid, COLOR_RED, ">> Wrong amount in liters! (0-100l)");
    refilltimes[playerid] = 100-Fuel[playerid];
    refillcount[playerid] = 0;
    killtimer(refilltimer[playerid]);
    refilltimer[playerid] = SetTimerEx("refillcar",1000,1,"d",playerid);
    return 1;
    }


dcmd_fill (playerid, params[])
{
    new
        miktar,
        string[128],
        string2[128],
        string3[128],
        string4[128],
        Fiyat,
        Sum;

    if (!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, ">> You are not in any vehicle to refill!");
    if (!IsAtGasStation(playerid)) return SendClientMessage(playerid, COLOR_RED, ">> You are not in a gas station!");
    if (!strlen(params)) return SendClientMessage(playerid, COLOR_RED, ">> /fill [amount in 0 - 100 l]");
    miktar = strval(params);
    if (miktar < 1 || miktar > 100) return SendClientMessage(playerid, COLOR_RED, ">> Wrong amount in liters! (0-100l)");
    if (Benzin[GetPlayerVehicleID(playerid)] >= 100) return SendClientMessage(playerid, COLOR_RED, ">> You can't refill. Your car is full!");
    Fiyat = (miktar * 2);
    format(string2, 128, ">> You don't have money enough! You need $%d.", Fiyat);
    if (GetPlayerMoney(playerid) < Fiyat) return SendClientMessage(playerid, COLOR_RED, string2);
    GivePlayerMoney(playerid, -Fiyat);
    format(string, 128, ">> You have filled your vehicle for %d liters. Cost: $%d.", miktar, Fiyat);
    SendClientMessage(playerid, COLOR_LIME, string);
    Benzin[GetPlayerVehicleID(playerid)] += miktar;
    if (Benzin[GetPlayerVehicleID(playerid)] > 100) Sum = miktar*2-Benzin[GetPlayerVehicleID(playerid)]+100, GivePlayerMoney(playerid, Sum), format(string4, 128, ">> You have choose a too large amount of liters that your car can't accept. Here's your change($%d).", Sum), SendClientMessage(playerid, COLOR_ORANGE, string4), Benzin[GetPlayerVehicleID(playerid)] = 100;
    format(string3, 128, "Fuel:    %%%d", Benzin[GetPlayerVehicleID(playerid)]);
    TextDrawSetString(Fuel[playerid], string3),
        TextDrawShowForPlayer(playerid, Fuel[playerid]),
            TextDrawTextSize(Moving[playerid], (354.0 - (Benzin[GetPlayerVehicleID(playerid)] / DIVBY)), 0.000000),
                TextDrawShowForPlayer(playerid, Moving[playerid]);
    return 1;
}

dcmd_buyfuel (playerid, params[])
{
    #pragma unused params
    if (!IsAtGasStation(playerid)) return SendClientMessage(playerid, COLOR_RED, ">> You are not in a gas station!");
    if (PortableFuel[playerid] == true) return SendClientMessage(playerid, COLOR_RED, ">> You can't have more than one tank.");
    SendClientMessage(playerid, COLOR_LIME, ">> You have bought a little fuel tank. You can use it when your fuel is low. (/usefuel)");
    PortableFuel[playerid] = true;
    return 1;
}

dcmd_usefuel (playerid, params[])
{
    new
      string[128];

    #pragma unused params
    if (!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, ">> You are not in any vehicle!");
    if (Benzin[GetPlayerVehicleID(playerid)] >= 40) return SendClientMessage(playerid, COLOR_RED, ">> You have fuel enough.");
    SendClientMessage(playerid, COLOR_LIME, ">> You used your fuel tank. (Fuel +25)");
    Benzin[GetPlayerVehicleID(playerid)] += 25;
    PortableFuel[playerid] = false;
    format(string, 128, "Fuel:    %%%d", Benzin[GetPlayerVehicleID(playerid)]);
    TextDrawSetString(Fuel[playerid], string),
        TextDrawShowForPlayer(playerid, Fuel[playerid]),
            TextDrawTextSize(Moving[playerid], (354.0 - (Benzin[GetPlayerVehicleID(playerid)] / DIVBY)), 0.000000),
                TextDrawShowForPlayer(playerid, Moving[playerid]);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd (fill, 4, cmdtext);
    dcmd (buyfuel, 7, cmdtext);
    dcmd (usefuel, 7, cmdtext);
    return 0;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new
      string[128],
        string2[128];


    if(newstate == PLAYER_STATE_DRIVER)
    {
        format(string, 128, "Fuel:    %%%d", Benzin[GetPlayerVehicleID(playerid)]);
        TextDrawSetString(Fuel[playerid], string),
            TextDrawShowForPlayer(playerid, Fuel[playerid]),
                TextDrawShowForPlayer(playerid, BlackBox),
                    TextDrawTextSize(Moving[playerid], (354.0 - (Benzin[GetPlayerVehicleID(playerid)] / DIVBY)), 0.000000),
                        TextDrawShowForPlayer(playerid, Moving[playerid]);
      if (Benzin[GetPlayerVehicleID(playerid)] < 1)
        {
            Benzin[GetPlayerVehicleID(playerid)] = 1;
            format(string2, 128, "Fuel:    %%%d", Benzin[GetPlayerVehicleID(playerid)]);
            TextDrawSetString(Fuel[playerid], string2),
                TextDrawShowForPlayer(playerid, Fuel[playerid]),
                    TextDrawTextSize(Moving[playerid], (354.0 - (Benzin[GetPlayerVehicleID(playerid)] / DIVBY)), 0.000000),
                        TextDrawShowForPlayer(playerid, Moving[playerid]);
        }
        if(Benzin[GetPlayerVehicleID(playerid)] < 1)
        {
          Benzin[GetPlayerVehicleID(playerid)] = 0;
            GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~w~You don't have fuel in your vehicle.", 4000, 3);
        RemovePlayerFromVehicle(playerid);
        }
    }
    else if (newstate == PLAYER_STATE_ONFOOT)
    {
      TextDrawHideForPlayer(playerid, Fuel[playerid]),
            TextDrawHideForPlayer(playerid, BlackBox),
            TextDrawHideForPlayer(playerid, Moving[playerid]);
      TogglePlayerControllable(playerid, true);
    }
    return 1;
}

stock IsAtGasStation(playerid)
{
  if(IsPlayerConnected(playerid))
    {
        // LV Gas Station 1
        if(IsPlayerInRangeOfPoint(playerid, 7.0,2194.349853,2457.038330,10.820312))
        {
          return 1;
    }
        // LV Gas Station 1
        else if(IsPlayerInRangeOfPoint(playerid, 7.0,2197.349853,2457.038330,10.820312))
        {
          return 1;
    }
        // LV Gas Station 2
        else if(IsPlayerInRangeOfPoint(playerid, 7.0,2639.586914,1111.154296,10.960937))
        {
          return 1;
    }
         // LV Gas Station 2
        else if(IsPlayerInRangeOfPoint(playerid, 7.0,2639.586914,1101.549072,10.960937))
        {
          return 1;
    }
        // LV Gas Station 3
        else if(IsPlayerInRangeOfPoint(playerid, 7.0,2197.486816,2474.700683,10.995170))
        {
          return 1;
    }
         // LV Gas Station 3
        else if(IsPlayerInRangeOfPoint(playerid, 7.0,2207.102294,2474.700683,10.995170))
        {
          return 1;
    }
     return 0;
}
}
And it shows now

pawn Код:
C:\Users\Bijan.Bijan-PC.000\Desktop\Ice Cream Roleplay\filterscripts\testfuel.pwn(53) : error 017: undefined symbol "playerid"
C:\Users\Bijan.Bijan-PC.000\Desktop\Ice Cream Roleplay\filterscripts\testfuel.pwn(446) : warning 203: symbol is never used: "dcmd_refill"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase
How can I find the 'playerid' thing? or is it 'Pid' or something?
Reply
#3

LOL, "playerid" is normally in function headers eg

public OnPlayerConnect(playerid)

And you need to define your commands
eg

dcmd(refill, 6, cmdtext);
Reply
#4

Quote:
Originally Posted by kmzr
LOL, "playerid" is normally in function headers eg

public OnPlayerConnect(playerid)

And you need to define your commands
eg

dcmd(refill, 6, cmdtext);
So if I change -
pawn Код:
dcmd_refill (playerid, params[])
to
pawn Код:
dcmd(refill, 6, cmdtext);
It should work?
Reply
#5

No, Read this.. http://forum.sa-mp.com/index.php?topic=70925.0
It'll save the confusion

and https://sampwiki.blast.hk/wiki/Dcmd
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)