[HELP]error 035: argument type mismatch (argument 2)
#1

please help here code

Код:
public AracBenzin()
{
	for(new playerid; playerid < MAX_PLAYERS; playerid++)
 {
		new vehicleid;
		if((vehicleid = GetPlayerVehicleID(playerid)) && aBenzin[playerid] != INVALID_BAR_ID)
		{
			SetProgressBarValue(aBenzin[vehicleid], Fuel);
			UpdateProgressBar(aBenzin[playerid], playerid);
		}
	}
}
Reply
#2

Point out the exact line? Where does "Fuel" come from? More information please?

We are not psychic, a little more information always helps.

EDIT: Ok I just had to find the "include"(I had expected you to use a third party library for the progress bars).

The "Fuel" variable has to be a float, if it is not declared as such, well there you have it.
Reply
#3

Quote:
Originally Posted by Extremo
Посмотреть сообщение
Point out the exact line? Where does "Fuel" come from? More information please?

We are not psychic, a little more information always helps.

EDIT: Ok I just had to find the "include"(I had expected you to use a third party library for the progress bars).

The "Fuel" variable has to be a float, if it is not declared as such, well there you have it.
I create fuel system Its working but I dont create progress bar here float code

Код:
new Float:Fuel[MAX_VEHICLES] = {100.0, ...};
Reply
#4

Can you show me where you define "aBenzin"? I see you once checking the array with the index "vehicleid" and once with "playerid"?

Also, please point out the LINE the error is occuring at. I cannot guess what of them is the error line.
Reply
#5

Код:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pLevel,
    pExp,
    pSex,
    pAge,
   	Float:pPos_x,
	Float:pPos_y,
	Float:pPos_z,
	pSkin,
	pJob,
	pFaction,
	pRank,
	pAccent,
	pInterior,
	pVW,
	pDriveLic,
	pBankaHesap,
	pVIP,
	pTDefter,
	pNumber,
	pAclik,
	pQuiz

}
new PlayerInfo[MAX_PLAYERS][pInfo];
new levelcost = 25000;
new levelexp = 4;
new ScoreOld;
new ghour = 0;
new realtime = 1;
new timeshift = -1;
new shifthour;
new ntimer[MAX_PLAYERS];
new adds = 1;
new gNews[MAX_PLAYERS];
new Sirenf;
new Text:Textdraw1;
new Text:Textdraw2;
new Bar:aCan[MAX_PLAYERS] = {INVALID_BAR_ID, ...};
new Bar:aBenzin[MAX_PLAYERS] = {INVALID_BAR_ID, ...};
forward AracHasar();
forward AracBenzin();
Reply
#6

Код:
new Bar:aBenzin[MAX_PLAYERS] = {INVALID_BAR_ID, ...};
Код:
SetProgressBarValue(aBenzin[vehicleid], Fuel); // Notice how fuel has no index?
EDIT: I just edited it to make the mistakes more obvious.

I think that should be the mistake. You still havent told me what line the error is on so I can't know for sure.

EDIT 2:

pawn Код:
public AracBenzin()
{
    for(new playerid; playerid < MAX_PLAYERS; playerid++)
 {
        new vehicleid;
        if((vehicleid = GetPlayerVehicleID(playerid)) && aBenzin[playerid] != INVALID_BAR_ID)
        {
            SetProgressBarValue(aBenzin[vehicleid]/* This isn't right is it? It's supposed to be playerid */, Fuel /* which fuel? Fuel is an array but you didn't specify any index here? shouldnt you reference the array to a specific index? */);
            UpdateProgressBar(aBenzin[playerid], playerid);
        }
    }
}
Reply
#7

Quote:
Originally Posted by Extremo
Посмотреть сообщение
Код:
new Bar:aBenzin[MAX_PLAYERS] = {INVALID_BAR_ID, ...};
Код:
SetProgressBarValue(aBenzin[vehicleid], Fuel); // Notice how fuel has no index?
EDIT: I just edited it to make the mistakes more obvious.

I think that should be the mistake. You still havent told me what line the error is on so I can't know for sure.

EDIT 2:

pawn Код:
public AracBenzin()
{
    for(new playerid; playerid < MAX_PLAYERS; playerid++)
 {
        new vehicleid;
        if((vehicleid = GetPlayerVehicleID(playerid)) && aBenzin[playerid] != INVALID_BAR_ID)
        {
            SetProgressBarValue(aBenzin[vehicleid]/* This isn't right is it? It's supposed to be playerid */, Fuel /* which fuel? Fuel is an array but you didn't specify any index here? shouldnt you reference the array to a specific index? */);
            UpdateProgressBar(aBenzin[playerid], playerid);
        }
    }
}
how to fix error?

Edit:
Код:
public AracBenzin()
{
    for(new playerid; playerid < MAX_PLAYERS; playerid++)
 {
        new vehicleid;
        if((vehicleid = GetPlayerVehicleID(playerid)) && aBenzin[playerid] != INVALID_BAR_ID)
        {
            SetProgressBarValue(aBenzin[playerid]/* This isn't right is it? It's supposed to be playerid */, Float:Fuel /* which fuel? Fuel is an array but you didn't specify any index here? shouldnt you reference the array to a specific index? */);
            UpdateProgressBar(aBenzin[playerid], playerid);
        }
    }
}
Reply
#8

Ugh how much I hate that question. Here's my answer: I won't fix it for you. If I don't manage to make you understand your error in this long reply, you will come back to this forum the moment you have an error again and eventually you never actually learned anything, which is not the point.

So, let me explain to you in detail what your code does and I am sure you will see the obvious mistake right away:

pawn Код:
public AracBenzin()
{
    // Here you begin to loop through all players I guess you understand that the code below repeats each time.
    for(new playerid; playerid < MAX_PLAYERS; playerid++)
    {
        new vehicleid;
        // here you fetch the vehicleid the player is in and make sure that the progress bar has been created for that player
        if((vehicleid = GetPlayerVehicleID(playerid)) && aBenzin[playerid] != INVALID_BAR_ID)
        {
            // Here you change the progress bar of the >VEHICLEID< to an ARRAY without index. This line is the actual error!
            SetProgressBarValue(aBenzin[vehicleid], Fuel);
            UpdateProgressBar(aBenzin[playerid], playerid);
        }
    }
}
Let's take a closer look shall we?

pawn Код:
new Bar:aBenzin[MAX_PLAYERS];
You created an array called aBenzin that has MAX_PLAYERS amount of drawers. Each drawer can hold a number. Now the importance here is that the playerid is the key to each drawer. In order for you to open a drawer you must use the correct key. Let's take a look at the error line again:

pawn Код:
SetProgressBarValue(aBenzin[vehicleid], Fuel);
You're using the vehicleid as key here, but is it the correct key? Let's look once more at the declaration:

pawn Код:
new Bar:aBenzin[MAX_PLAYERS];
Wait a moment? Do you see what I see? It says players. So how can I use a vehicle key in order to access a drawer which requires a player key? The drawer didn't open and your Boss(the compiler) moaned at you for failing.

Now let's go have a look in the actual code again and find the correct key shall we?

pawn Код:
// Here you begin to loop through all players I guess you understand that the code below repeats each time.
    for(new playerid; playerid < MAX_PLAYERS; playerid++)
Aha, we're looping through every player, which means we basically go through every drawer, from the top to the buttom with their respected key playerid. So, in order to open the proper drawer we must use the playerid key!

pawn Код:
SetProgressBarValue(aBenzin[playerid], Fuel);
Awesome! The drawer opened! I am proud of you, but there is still one problem. Fuel is a bunch of documents all with a number written on them. Though there is only space enough for one single document in the drawer? How do we know which document to put into the drawer? Wait a second! Let's have a look at that declaration shall we?

pawn Код:
new Fuel[MAX_VEHICLES] = {100,...};
Okay! Do you see what I see? Yes! It uses the vehicle key! Now where did we find the vehicle key? Oh right! We actually check it here:
pawn Код:
if((vehicleid = GetPlayerVehicleID(playerid)) && aBenzin[playerid] != INVALID_BAR_ID)
The player is sitting in that vehicle and obviously has the key! So let's use that key to find the correct document that holds the fuel of that vehicle and put it into the drawer!

pawn Код:
SetProgressBarValue(aBenzin[playerid], Fuel[vehicleid]);
Wow! This is amazing! So we find the document that shows the fuel of the vehicle and put it into the drawer of the appropriate player bar! It works!!

Hope you get it now =).

Final Edit:

"Don't ask how to do things but ask why, because running against a wall because one said so is not smart."

I think it is very important for people to understand their code, so I hope I've managed to do a little of that for you this time and hopefully you will have learned enough to be able to investigate your error by yourself next time. =)

Regards.
Reply
#9

I don't understand sorry for my bad english Im from Turkey

Edit:I create FS version and any error and warning but fuel system doesn't work
Код:
#include <a_samp>
#include <progress>

new Bar:aCan[MAX_PLAYERS] = {INVALID_BAR_ID, ...};
new Bar:aBenzin[MAX_PLAYERS] = {INVALID_BAR_ID, ...};
forward AracHasar();
forward AracBenzin();

public OnFilterScriptInit()
{
	SetTimer("AracHasar", 500, 1);
	SetTimer("AracBenzin", 500, 1);
	return 1;
}

public AracHasar()
{
	for(new playerid; playerid < MAX_PLAYERS; playerid++)
	{
		new vehicleid;
		if((vehicleid = GetPlayerVehicleID(playerid)) && aCan[playerid] != INVALID_BAR_ID)
		{
			new Float:health;
			GetVehicleHealth(vehicleid, health);
			SetProgressBarValue(aCan[playerid], health);
			UpdateProgressBar(aCan[playerid], playerid);
		}
	}
}

public AracBenzin()
{
	for(new playerid; playerid < MAX_PLAYERS; playerid++)
 {
//		new vehicleid;
//		if((vehicleid = GetPlayerVehicleID(playerid)) && aCan[playerid] != INVALID_BAR_ID)
		{
			new Float:Fuel;
			SetProgressBarValue(aBenzin[playerid], Fuel);
			UpdateProgressBar(aBenzin[playerid], playerid);
		}
	}
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(oldstate == PLAYER_STATE_DRIVER)
	{
		DestroyProgressBar(aCan[playerid]);
		aCan[playerid] = INVALID_BAR_ID;
		DestroyProgressBar(aBenzin[playerid]);
		aBenzin[playerid] = INVALID_BAR_ID;
	}
	if(newstate == PLAYER_STATE_DRIVER)
	{
		aCan[playerid] = CreateProgressBar(502.00, 397.00, 102.50, 3.20, -132901633, 1000.0);
		aBenzin[playerid] = CreateProgressBar(502.00, 418.00, 102.50, 3.20, 161022207, 100.0);
		ShowProgressBarForPlayer(playerid, aCan[playerid]);
		ShowProgressBarForPlayer(playerid, aBenzin[playerid]);
	}
	return 1;
}
Reply
#10

Look I even told you the answer to your problem...

pawn Код:
SetProgressBarValue(aBenzin[playerid], Fuel[vehicleid]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)