what is wrong with this ?
#1

Hello there, i made this code putting a few weapon id's into one value
I have no errors but it only checks the first 'id' every time so what am i doing wrong here ?

Код:
new DetectWeapon; 
new Fists[] ={0,1,10,11,13,14};
new Melee[]={2,3,5,6,7,8,15};
Код:
	if (strcmp(cmdtext, "/checkweps", true) == 0)//
	{
		if(GetPlayerWeapon(playerid) == DetectWeapon)
		{
			for(new w = 0; w < MAX_PLAYERS; w++)
			if (DetectWeapon == Fists[w])
			{
			SendClientMessage(playerid, COLOR_WHITE, "you have a weapon in categorie fists");
		  return 1;
			}
			
			for(new w = 0; w < MAX_PLAYERS; w++)
			if (DetectWeapon == Melee[w])
			{
			SendClientMessage(playerid, COLOR_WHITE, "you have a handwep");
			return 1;
			}
return 1;
}
return 0;
}
Thanks for any help
Reply
#2

I think it's because you are returning 1 after you check in the fists category. Oh and that's how you spell "Category." ^^

Try getting rid of the
pawn Код:
if (strcmp(cmdtext, "/checkweps", true) == 0)//
    {
        if(GetPlayerWeapon(playerid) == DetectWeapon)
        {
            for(new w = 0; w < MAX_PLAYERS; w++)
            if (DetectWeapon == Fists[w])
            {
              SendClientMessage(playerid, COLOR_WHITE, "you have a weapon in category fists");
               return 1; //this one
            }
           
            for(new w = 0; w < MAX_PLAYERS; w++)
            if (DetectWeapon == Melee[w])
            {
              SendClientMessage(playerid, COLOR_WHITE, "you have a handwep");
              return 1; //and this
            }
        return 1;
    }
    return 0;
}
*I fixed your indentation

EDIT: Hell, if you get rid of the return 1;'s your code can just look like this:
pawn Код:
if (strcmp(cmdtext, "/checkweps", true) == 0)//
    {
        if(GetPlayerWeapon(playerid) == DetectWeapon)
        {
            for(new w = 0; w < MAX_PLAYERS; w++)
            {
                if (DetectWeapon == Fists[w]) SendClientMessage(playerid, COLOR_WHITE, "you have a weapon in category fists");
            }
            for(new w = 0; w < MAX_PLAYERS; w++)
            {
                if (DetectWeapon == Melee[w]) SendClientMessage(playerid, COLOR_WHITE, "you have a handwep");
            }
        }    
        return 1;
    }
    return 0;
}
Reply
#3

Thanks for the fast reply i removed the returns but thats not it it only checks 'Fists' only weapon 0
and it isnt doing anything at all if i check 'melee'
Reply
#4

Maybe your DetectWeapon has issues or isn't detecting anything in that category.
Reply
#5

Damnit! i cant find it. it doesnt work even if i make new values like DetectWeapon; for each

EDIT:

B
U
M
P

is there anyone with other suggestions please ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)