SA-MP Forums Archive
[Help] So many errors!!! Fuel Bar - 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: [Help] So many errors!!! Fuel Bar (/showthread.php?tid=215759)



[Help] So many errors!!! Fuel Bar - drewcasey24 - 24.01.2011

Hey im trying to make a fuel progress bar for my server but i keep getting these errors

Код:
(1197) : error 035: argument type mismatch (argument 2)
(1214) : error 035: argument type mismatch (argument 1)
(1215) : error 035: argument type mismatch (argument 1)
(1220) : error 035: argument type mismatch (argument 1)
(1221) : error 035: argument type mismatch (argument 1)
(1225) : error 035: argument type mismatch (argument 1)
(1226) : error 035: argument type mismatch (argument 1)
So on and so on like 23 errors all saying the same thing, heres the code

Код:
Line 1197
SetProgressBarValue(gGas[playerid], gas);

Lines 1214 and up

public BenzinUpdate()
{
	for(new i=0; i<MAX_PLAYERS; i++)
	{
    	if(IsPlayerConnected(i))
       	{
		    new vehicle = GetPlayerVehicleID(i);
			if(IsPlayerInAnyVehicle(i) == 1)
			{
				if(gGas[vehicle] >= 0 && gGas[vehicle] <= 3)
				{
					SetProgressBarValue(gas, 0.0);
					ShowProgressBarForAll(gas);
					TogglePlayerControllable(i, 0);
				}
				else if(gGas[vehicle] >= 0 && gGas[vehicle] <= 10)
				{
					SetProgressBarValue(gas, 10.0);
					ShowProgressBarForAll(gas);
				}
				else if(gGas[vehicle] >= 10 && gGas[vehicle] <= 20)
				{
					SetProgressBarValue(gas, 20.0);
					ShowProgressBarForAll(gas);
				}
				else if(gGas[vehicle] >= 20 && gGas[vehicle] <= 30)
				{
					SetProgressBarValue(gas, 30.0);
					ShowProgressBarForAll(gas);
				}
				else if(gGas[vehicle] >= 30 && gGas[vehicle] <= 40)
				{
					SetProgressBarValue(gas, 40.0);
					ShowProgressBarForAll(gas);
				}
				else if(gGas[vehicle] >= 40 && gGas[vehicle] <= 50)
				{
					SetProgressBarValue(gas, 50.0);
					ShowProgressBarForAll(gas);
				}
				else if(gGas[vehicle] >= 50 && gGas[vehicle] <= 60)
				{
					SetProgressBarValue(gas, 60.0);
					ShowProgressBarForAll(gas);
				}
				else if(gGas[vehicle] >= 60 && gGas[vehicle] <= 70)
				{
					SetProgressBarValue(gas, 70.0);
					ShowProgressBarForAll(gas);
				}
				else if(gGas[vehicle] >= 70 && gGas[vehicle] <= 80)
				{
					SetProgressBarValue(gas, 80.0);
					ShowProgressBarForAll(gas);
				}
				else if(gGas[vehicle] >= 80 && gGas[vehicle] <= 90)
				{
					SetProgressBarValue(gas, 90.0);
					ShowProgressBarForAll(gas);
				}
				else if(gGas[vehicle] >= 90 && gGas[vehicle] <= 100)
				{
					SetProgressBarValue(gas, 100.0);
					ShowProgressBarForAll(gas);
				}
			}
		}
	}
	return 1;
}
Yes i know it has something to do with the gas progress bar id but i cant figure out what, any help would be greatly appreciated!


Re: [Help] So many errors!!! Fuel Bar - Lorenc_ - 24.01.2011

Im guessing your warnings are coming from those:

pawn Код:
SetProgressBarValue(gas, 0.0);
//or
if(gGas[vehicle] >= 0 && gGas[vehicle] <= 3)
Because i might have a solution for the if statement

Edit: ^


Re: [Help] So many errors!!! Fuel Bar - Lorenc_ - 24.01.2011

Sorry for double posting, although

SetProgressBarValue(gGas[playerid], gas);

That dosent require a variable there? doesnt it?

You might as well put SetProgressBarValue(playerid, gas);
and with your gGas[vehicle] var, make it like

new gGas[MAX_VEHICLES];

then through that make a loop

pawn Код:
#define LoopVehicles(%1)  for(new %1=0; %1<MAX_VEHICLES; %1++)
pawn Код:
public BenzinUpdate()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
               LoopVehicles(a) {
            new vehicle = GetPlayerVehicleID(i);
            if(IsPlayerInAnyVehicle(i) == 1)
            {
                if(gGas[vehicle] >= 0 && gGas[vehicle] <= 3)
                {
                    SetProgressBarValue(gas, 0.0);
                    ShowProgressBarForAll(gas);
                    TogglePlayerControllable(i, 0);
                }
                else if(gGas[vehicle] >= 0 && gGas[vehicle] <= 10)
                {
                    SetProgressBarValue(gas, 10.0);
                    ShowProgressBarForAll(gas);
                }
                else if(gGas[vehicle] >= 10 && gGas[vehicle] <= 20)
                {
                    SetProgressBarValue(gas, 20.0);
                    ShowProgressBarForAll(gas);
                }
                else if(gGas[vehicle] >= 20 && gGas[vehicle] <= 30)
                {
                    SetProgressBarValue(gas, 30.0);
                    ShowProgressBarForAll(gas);
                }
                else if(gGas[vehicle] >= 30 && gGas[vehicle] <= 40)
                {
                    SetProgressBarValue(gas, 40.0);
                    ShowProgressBarForAll(gas);
                }
                else if(gGas[vehicle] >= 40 && gGas[vehicle] <= 50)
                {
                    SetProgressBarValue(gas, 50.0);
                    ShowProgressBarForAll(gas);
                }
                else if(gGas[vehicle] >= 50 && gGas[vehicle] <= 60)
                {
                    SetProgressBarValue(gas, 60.0);
                    ShowProgressBarForAll(gas);
                }
                else if(gGas[vehicle] >= 60 && gGas[vehicle] <= 70)
                {
                    SetProgressBarValue(gas, 70.0);
                    ShowProgressBarForAll(gas);
                }
                else if(gGas[vehicle] >= 70 && gGas[vehicle] <= 80)
                {
                    SetProgressBarValue(gas, 80.0);
                    ShowProgressBarForAll(gas);
                }
                else if(gGas[vehicle] >= 80 && gGas[vehicle] <= 90)
                {
                    SetProgressBarValue(gas, 90.0);
                    ShowProgressBarForAll(gas);
                }
                else if(gGas[vehicle] >= 90 && gGas[vehicle] <= 100)
                {
                    SetProgressBarValue(gas, 100.0);
                    ShowProgressBarForAll(gas);
                }
            }
                    }
        }
    }
    return 1;
}
Then after replace all gGas[vehicle] with gGas[a]


Re: [Help] So many errors!!! Fuel Bar - drewcasey24 - 24.01.2011

Thanks i'll try this then let you know

Edit: Nope still getting the errors it's coming from

Код:
SetProgressBarValue(gas, 0.0);



Re: [Help] So many errors!!! Fuel Bar - Lorenc_ - 24.01.2011

I've never used that include although can you give me a code that links to gas?

and where the variable is created.


Re: [Help] So many errors!!! Fuel Bar - HyperZ - 24.01.2011

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
Sorry for double posting, although
Next time try to use that Edit Button. :P




Re: [Help] So many errors!!! Fuel Bar - iggy1 - 24.01.2011

Isn't the second argument supposed to be an integer value not a floating/fixed point value? If i remember correctly its an integer. (not sure havn't used that include in a while)

EDIT: Also you must declare the bar variable with the bar indentifier eg,
pawn Код:
new bar:gGas[MAX_PLAYERS];



Re: [Help] So many errors!!! Fuel Bar - drewcasey24 - 24.01.2011

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Isn't the second argument supposed to be an integer value not a floating/fixed point value? If i remember correctly its an integer. (not sure havn't used that include in a while)

EDIT: Also you must declare the bar variable with the bar indentifier eg,
pawn Код:
new bar:gGas[MAX_PLAYERS];
That does nothing but give me an "gGas is already defined" error.

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
I've never used that include although can you give me a code that links to gas?

and where the variable is created.
Код:
new Bar:gas[MAX_PLAYERS] = {INVALID_BAR_ID, ...};

public ProgressBar()
{
    for(new playerid; playerid < MAX_PLAYERS; playerid++)
    {
        new vehicleid;
        if((vehicleid = GetPlayerVehicleID(playerid)) && gGas[playerid] != INVALID_BAR_ID)
        {
            CheckGas(vehicleid, gGas);
            SetProgressBarValue(playerid, gas);
            UpdateProgressBar(gas[playerid], playerid);
        }
    }
}

if(newstate == PLAYER_STATE_DRIVER)
	{
	    gas[playerid] = CreateProgressBar(50.0, 300.0, _, _, 0xFF0000FF, 100.0);
        ShowProgressBarForPlayer(playerid, gas[playerid]);
This is pretty much all the code i have for it.


Re: [Help] So many errors!!! Fuel Bar - DeSantis - 24.01.2011

Yeah im having similar issues the only time i seen this in working order is in ng-gaming


Re: [Help] So many errors!!! Fuel Bar - iggy1 - 25.01.2011

Quote:
Originally Posted by drewcasey24
Посмотреть сообщение
That does nothing but give me an "gGas is already defined" error.

pawn Код:
public ProgressBar()
{
    for(new playerid; playerid < MAX_PLAYERS; playerid++)
    {
        new vehicleid;
        if((vehicleid = GetPlayerVehicleID(playerid)) && gGas[playerid] != INVALID_BAR_ID)
        {
            CheckGas(vehicleid, gGas);
            SetProgressBarValue(playerid, gas);
            UpdateProgressBar(gas[playerid], playerid);
        }
    }
}
Theres alot wrong with that code try this
pawn Код:
public ProgressBar()
{
    new vehicleid;
    for(new playerid; playerid < MAX_PLAYERS; playerid++)
    {
        vehicleid = GetPlayerVehicleID(playerid);
       
        if(gas[playerid] != INVALID_BAR_ID)
        {
            CheckGas(vehicleid, gGas);
            SetProgressBarValue(gas[playerid], 100);// this must be set to a value not a bar id change 100 for the fuel variable
            UpdateProgressBar(gas[playerid], playerid);
        }
    }
}
I have actualy compiled that without any error or warning (apart from the checkgas function).