what is wrong with this ? - 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: what is wrong with this ? (
/showthread.php?tid=134785)
what is wrong with this ? -
boelie - 17.03.2010
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
Re: what is wrong with this ? -
biltong - 17.03.2010
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;
}
Re: what is wrong with this ? -
boelie - 17.03.2010
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'
Re: what is wrong with this ? -
biltong - 17.03.2010
Maybe your DetectWeapon has issues or isn't detecting anything in that category.
Re: what is wrong with this ? -
boelie - 17.03.2010
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 ?